minishell/Makefile

189 lines
4.6 KiB
Makefile
Raw Normal View History

2025-02-06 13:43:26 +01:00
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
2025-02-06 13:43:26 +01:00
TSAN = -fsanitize=thread
UBSAN = -fsanitize=undefined
LDLIBS = \
-lreadline \
2025-02-12 14:51:05 +01:00
-lft
LIBFTDIR = ./libft/
LIBFT = $(LIBFTDIR)libft.a
IFLAGS = -I$(LIBFTDIR)
LINCLUDE = -L$(LIBFTDIR)
2025-02-06 13:43:26 +01:00
ifeq ($(CFLAGS),)
CFLAGS = $(DEBUG)
# CFLAGS = -Wall -Wextra -Werror $(DEBUG)
2025-02-06 13:43:26 +01:00
endif
export CFLAGS
srcs = \
src/buffer/buffer.c \
src/buffer/buffer_charptr.c \
2025-04-11 16:49:26 +02:00
src/destroy_cmds.c \
src/env/env.c \
src/env/env_convert.c \
src/env/env_manip.c \
src/env/envp.c \
2025-03-07 11:52:28 +01:00
src/executing/here_doc/here_doc.c \
src/executing/here_doc/here_doc_errors.c \
2025-03-13 17:26:44 +01:00
src/executing/here_doc/here_doc_expand_line.c \
src/executing/here_doc/random_filename.c \
src/executing/here_doc/strip_newline.c \
src/executing/simple_cmd/builtin_cd.c \
2025-04-01 13:53:53 +02:00
src/executing/simple_cmd/builtin_export.c \
2025-03-31 14:53:05 +02:00
src/executing/simple_cmd/builtin_invalid.c \
src/executing/simple_cmd/builtin_pwd.c \
src/executing/simple_cmd/builtins.c \
src/executing/simple_cmd/simple_cmd_execute.c \
2025-02-17 16:52:17 +01:00
src/ft_errno.c \
src/get_command.c \
2025-03-11 15:20:19 +01:00
src/parser/cmdgroup/cmdgroup.c \
src/parser/cmdgroup/cmdgroup_builder.c \
src/parser/cmdgroup/paren.c \
src/parser/cmdlist/cmdlist.c \
src/parser/cmdlist/cmdlist_builder.c \
src/parser/cmdlist/cmdlist_debug.c \
src/parser/cmdlist/cmdlist_item.c \
src/parser/cmdlist/operator.c \
src/parser/matchers/blank.c \
src/parser/matchers/identifier.c \
2025-02-18 15:07:05 +01:00
src/parser/matchers/metacharacter.c \
2025-02-17 16:14:14 +01:00
src/parser/matchers/operator_combo.c \
src/parser/matchers/operator_start.c \
2025-02-21 14:13:51 +01:00
src/parser/matchers/pipe.c \
2025-02-20 13:22:32 +01:00
src/parser/matchers/quote.c \
src/parser/pipeline/pipeline.c \
src/parser/pipeline/pipeline_debug.c \
2025-03-20 17:34:07 +01:00
src/parser/pipeline/pipeline_parse.c \
src/parser/pipeline/pipeline_parse_baseops.c \
2025-03-20 17:34:07 +01:00
src/parser/remove_quotes/cmdgroup_remove_quotes.c \
src/parser/remove_quotes/remove_quotes.c \
src/parser/simple_cmd/simple_cmd.c \
src/parser/worddesc/worddesc.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 \
2025-02-20 12:06:34 +01:00
src/parser/wordsplit/rule_utils.c \
2025-02-19 18:41:26 +01:00
src/parser/wordsplit/tokenizing_1_5.c \
src/parser/wordsplit/tokenizing_6_10.c \
src/parser/wordsplit/wordsplit.c \
2025-02-19 18:41:26 +01:00
src/parser/wordsplit/wordsplit_utils.c \
src/postprocess/expansion/expand_vars.c \
src/subst/path_split.c \
src/subst/replace_substr.c \
src/subst/simple_filename_exp.c \
src/subst/simple_filename_exp_utils.c \
2025-03-06 12:45:05 +01:00
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
2025-02-06 13:43:26 +01:00
objs = $(srcs:.c=.o)
export objs
2025-02-06 13:43:26 +01:00
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
2025-02-06 13:43:26 +01:00
all: $(NAME)
-include $(deps)
2025-02-12 14:51:05 +01:00
$(NAME): $(minishell_objs) $(LIBFT)
$(CC) $(CFLAGS) -o $@ $(minishell_objs) $(LINCLUDE) $(LDLIBS)
$(LIBFT):
+$(MAKE) -C $(LIBFTDIR)
2025-02-06 13:43:26 +01:00
%.o: %.c
2025-02-12 14:51:05 +01:00
$(CC) -c $(CFLAGS) $(IFLAGS) -o $*.o $*.c
$(CC) -MM $(CFLAGS) $(IFLAGS) $*.c > $*.d
2025-02-06 13:43:26 +01:00
clean:
2025-02-12 14:51:05 +01:00
+$(MAKE) -C $(LIBFTDIR) clean
2025-02-06 13:43:26 +01:00
find . -name '*.o' -print -delete
find . -name '*.d' -print -delete
fclean: clean
2025-02-12 14:51:05 +01:00
$(MAKE) -C $(LIBFTDIR) fclean
2025-02-06 13:43:26 +01:00
rm -f $(NAME)
+make -C tests fclean
2025-02-06 13:43:26 +01:00
re:
+make fclean
+make all
2025-02-06 13:45:29 +01:00
norm:
norminette src libft | grep -v OK || true
2025-02-06 15:13:34 +01:00
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
2025-02-12 15:10:12 +01:00
ctests: $(LIBFT) all
2025-02-12 15:10:12 +01:00
+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