mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
213 lines
5.6 KiB
Makefile
213 lines
5.6 KiB
Makefile
NAME = minishell
|
|
DEBUG = -g -O0
|
|
# -fno-omit-frame-pointer is to prevent malloc stacktraces from being truncated,
|
|
# see "My malloc stacktraces are too short" here:
|
|
# https://github.com/google/sanitizers/wiki/AddressSanitizer
|
|
ASAN = -fsanitize=address -fno-omit-frame-pointer
|
|
TSAN = -fsanitize=thread
|
|
UBSAN = -fsanitize=undefined
|
|
LDLIBS = \
|
|
-lreadline \
|
|
-lft
|
|
LIBFTDIR = ./libft/
|
|
LIBFT = $(LIBFTDIR)libft.a
|
|
IFLAGS = -I$(LIBFTDIR)
|
|
LINCLUDE = -L$(LIBFTDIR)
|
|
|
|
ifeq ($(CFLAGS),)
|
|
CFLAGS = -Wall -Wextra -Werror \
|
|
$(DEBUG) \
|
|
|
|
endif
|
|
export CFLAGS
|
|
srcs = \
|
|
src/buffer/buffer.c \
|
|
src/buffer/buffer_charptr.c \
|
|
src/env/env.c \
|
|
src/env/env_convert.c \
|
|
src/env/env_manip.c \
|
|
src/env/envp.c \
|
|
src/executing/cmd/cmd_execute.c \
|
|
src/executing/common/do_waitpid.c \
|
|
src/executing/connec_cmd/connec_cmd_execute.c \
|
|
src/executing/connec_cmd/connec_pipe_cmd_execute.c \
|
|
src/executing/group_cmd/group_cmd_execute.c \
|
|
src/executing/here_doc/here_doc.c \
|
|
src/executing/here_doc/here_doc_errors.c \
|
|
src/executing/here_doc/here_doc_expand_line.c \
|
|
src/executing/here_doc/here_doc_utils.c \
|
|
src/executing/here_doc/random_filename.c \
|
|
src/executing/here_doc/strip_newline.c \
|
|
src/executing/simple_cmd/builtin_cd.c \
|
|
src/executing/simple_cmd/builtin_echo.c \
|
|
src/executing/simple_cmd/builtin_env.c \
|
|
src/executing/simple_cmd/builtin_exit.c \
|
|
src/executing/simple_cmd/builtin_export.c \
|
|
src/executing/simple_cmd/builtin_invalid.c \
|
|
src/executing/simple_cmd/builtin_pwd.c \
|
|
src/executing/simple_cmd/builtin_unset.c \
|
|
src/executing/simple_cmd/builtins.c \
|
|
src/executing/simple_cmd/handle_redirections.c \
|
|
src/executing/simple_cmd/simple_cmd_execute.c \
|
|
src/executing/simple_cmd/simple_cmd_execute_debug.c \
|
|
src/executing/simple_cmd/subprocess.c \
|
|
src/ft_errno.c \
|
|
src/get_command.c \
|
|
src/parser/cmd/cmd.c \
|
|
src/parser/cmd/cmd_debug.c \
|
|
src/parser/cmd/cmd_destroy.c \
|
|
src/parser/cmd/cmds_parse.c \
|
|
src/parser/cmd/opt_cmds_parse.c \
|
|
src/parser/connec_cmd/connec_cmd_debug.c \
|
|
src/parser/connec_cmd/connec_reorient_subtree.c \
|
|
src/parser/group_cmd/group_cmd_debug.c \
|
|
src/parser/group_cmd/group_cmd_parse.c \
|
|
src/parser/matchers/blank.c \
|
|
src/parser/matchers/identifier.c \
|
|
src/parser/matchers/metacharacter.c \
|
|
src/parser/matchers/operator_combo.c \
|
|
src/parser/matchers/operator_start.c \
|
|
src/parser/matchers/pipe.c \
|
|
src/parser/matchers/quote.c \
|
|
src/parser/pipeline/optional_pipeline_parse.c \
|
|
src/parser/pipeline/pipeline_parse.c \
|
|
src/parser/redirect/redirect.c \
|
|
src/parser/redirect/redirect_debug.c \
|
|
src/parser/redirect/redirect_from_words.c \
|
|
src/parser/redirect/redirect_parse.c \
|
|
src/parser/remove_quotes/cmdgroup_remove_quotes.c \
|
|
src/parser/remove_quotes/remove_quotes.c \
|
|
src/parser/simple_cmd/simple_cmd.c \
|
|
src/parser/simple_cmd/simple_cmd_parse.c \
|
|
src/parser/worddesc/worddesc.c \
|
|
src/parser/worddesc/worddesc_debug.c \
|
|
src/parser/wordlist/wordlist.c \
|
|
src/parser/wordlist/wordlist_copy.c \
|
|
src/parser/wordlist/wordlist_debug.c \
|
|
src/parser/wordlist/wordlist_idx.c \
|
|
src/parser/wordlist/wordlist_quicksort.c \
|
|
src/parser/wordlist/wordlist_utils.c \
|
|
src/parser/wordsplit/get_token_type.c \
|
|
src/parser/wordsplit/rule_utils.c \
|
|
src/parser/wordsplit/tokenizing_1_5.c \
|
|
src/parser/wordsplit/tokenizing_6_10.c \
|
|
src/parser/wordsplit/wordsplit.c \
|
|
src/parser/wordsplit/wordsplit_utils.c \
|
|
src/postprocess/expansion/expand_vars.c \
|
|
src/postprocess/expansion/expand_wildcard.c \
|
|
src/postprocess/fieldsplit/fieldsplit.c \
|
|
src/postprocess/fieldsplit/redirect_fieldsplit.c \
|
|
src/sig/sig.c \
|
|
src/sig/sig_handlers.c \
|
|
src/subst/path_split.c \
|
|
src/subst/replace_substr.c \
|
|
src/subst/simple_filename_exp.c \
|
|
src/subst/simple_filename_exp_utils.c \
|
|
src/subst/variable_subst.c \
|
|
src/subst/variable_subst_utils.c \
|
|
src/subst/wildcard_exp.c \
|
|
src/subst/wildcard_exp_utils.c \
|
|
src/subst/wildcard_exp_utils2.c \
|
|
src/treedrawing.c \
|
|
src/parser/cmd_parsing.c
|
|
|
|
|
|
objs = $(srcs:.c=.o)
|
|
export objs
|
|
minishell_objs = $(addsuffix .o,src/$(NAME)) $(objs)
|
|
all_objs = $(minishell_objs)
|
|
deps = $(all_objs:.o=.d)
|
|
|
|
.PHONY: all clean fclean re norm tests ctests ctestsa ctestsub ctestst alla \
|
|
allub allt testsa testsub testst inttests inttestsa inttestsub inttestst
|
|
|
|
all: $(NAME)
|
|
|
|
-include $(deps)
|
|
|
|
$(NAME): $(minishell_objs) $(LIBFT)
|
|
$(CC) $(CFLAGS) -o $@ $(minishell_objs) $(LINCLUDE) $(LDLIBS)
|
|
|
|
$(LIBFT): CFLAGS+=-DBUFFER_SIZE=1
|
|
$(LIBFT):
|
|
+$(MAKE) -C $(LIBFTDIR)
|
|
|
|
%.o: %.c
|
|
$(CC) -c $(CFLAGS) $(IFLAGS) -o $*.o $*.c
|
|
$(CC) -MM $(CFLAGS) $(IFLAGS) -MT $*.o $*.c > $*.d
|
|
|
|
clean:
|
|
+$(MAKE) -C $(LIBFTDIR) clean
|
|
find . -name '*.o' -print -delete
|
|
find . -name '*.d' -print -delete
|
|
|
|
fclean: clean
|
|
$(MAKE) -C $(LIBFTDIR) fclean
|
|
rm -f $(NAME)
|
|
+make -C tests fclean
|
|
|
|
re:
|
|
+make fclean
|
|
+make all
|
|
|
|
norm:
|
|
norminette src libft | grep -v OK || true
|
|
|
|
tests:
|
|
+make fclean
|
|
+make testsa
|
|
+make fclean
|
|
+make testsub
|
|
+make fclean
|
|
+make testst
|
|
@echo "All tests passed!"
|
|
|
|
testsa: CFLAGS += $(ASAN)
|
|
testsa:
|
|
@echo "Running tests with AddressSanitizer..."
|
|
+make inttests
|
|
+make ctests
|
|
|
|
testsub: CFLAGS += $(UBSAN)
|
|
testsub: all
|
|
@echo "Running tests with UndefinedBehaviourSanitizer..."
|
|
+make inttests
|
|
+make ctests
|
|
|
|
testst: CFLAGS += $(TSAN)
|
|
testst: all
|
|
@echo "Running tests with ThreadSanitizer..."
|
|
+make inttests
|
|
+make ctests
|
|
|
|
inttests: all
|
|
./test.sh
|
|
|
|
inttestsa: CFLAGS += $(ASAN)
|
|
inttestsa: all
|
|
./test.sh
|
|
|
|
inttestsub: CFLAGS += $(UBSAN)
|
|
inttestsub: all
|
|
./test.sh
|
|
|
|
inttestst: CFLAGS += $(TSAN)
|
|
inttestst: all
|
|
./test.sh
|
|
|
|
ctests: $(LIBFT) all
|
|
+make -C tests
|
|
|
|
ctestsa: CFLAGS += $(ASAN)
|
|
ctestsa: ctests
|
|
ctestsub: CFLAGS += $(UBSAN)
|
|
ctestsub: ctests
|
|
ctestst: CFLAGS += $(TSAN)
|
|
ctestst: ctests
|
|
|
|
alla: CFLAGS += $(ASAN)
|
|
alla: all
|
|
allub: CFLAGS += $(UBSAN)
|
|
allub: all
|
|
allt: CFLAGS += $(TSAN)
|
|
allt: all
|