2025-02-06 13:43:26 +01:00
|
|
|
NAME = minishell
|
2025-02-26 14:07:55 +01:00
|
|
|
DEBUG = -g -O0
|
2025-02-14 13:30:18 +01:00
|
|
|
# -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
|
2025-02-06 13:58:50 +01:00
|
|
|
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:58:50 +01:00
|
|
|
|
2025-02-06 13:43:26 +01:00
|
|
|
ifeq ($(CFLAGS),)
|
|
|
|
|
CFLAGS = -Wall -Wextra -Werror $(DEBUG)
|
|
|
|
|
endif
|
|
|
|
|
export CFLAGS
|
|
|
|
|
srcs = \
|
2025-02-14 17:55:26 +01:00
|
|
|
src/buffer/buffer.c \
|
2025-02-19 13:29:44 +01:00
|
|
|
src/env/env.c \
|
|
|
|
|
src/env/env_convert.c \
|
|
|
|
|
src/env/env_manip.c \
|
|
|
|
|
src/env/envp.c \
|
2025-02-17 16:52:17 +01:00
|
|
|
src/ft_errno.c \
|
2025-02-19 18:04:34 +01:00
|
|
|
src/get_command.c \
|
2025-02-25 15:24:52 +01:00
|
|
|
src/parser/command_list/command_list_builder.c \
|
2025-02-24 17:52:05 +01:00
|
|
|
src/parser/command_list/command_list.c \
|
2025-02-25 15:24:52 +01:00
|
|
|
src/parser/command_list/operator.c \
|
2025-02-14 15:06:01 +01:00
|
|
|
src/parser/matchers/blank.c \
|
2025-02-19 13:29:44 +01:00
|
|
|
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 \
|
2025-02-21 13:44:51 +01:00
|
|
|
src/parser/pipeline/pipeline.c \
|
2025-02-21 16:04:47 +01:00
|
|
|
src/parser/pipeline/pipeline_parse_baseops.c \
|
|
|
|
|
src/parser/pipeline/pipeline_parse.c \
|
2025-02-28 13:51:16 +01:00
|
|
|
src/parser/remove_quotes/remove_quotes.c \
|
2025-02-21 12:35:51 +01:00
|
|
|
src/parser/simple_cmd/simple_cmd.c \
|
2025-02-13 15:17:30 +01:00
|
|
|
src/parser/worddesc/worddesc.c \
|
|
|
|
|
src/parser/wordlist/wordlist.c \
|
2025-02-26 14:07:55 +01:00
|
|
|
src/parser/wordlist/wordlist_copy.c \
|
2025-02-24 18:18:15 +01:00
|
|
|
src/parser/wordlist/wordlist_debug.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 \
|
2025-02-13 15:17:30 +01:00
|
|
|
src/parser/wordsplit/wordsplit.c \
|
2025-02-19 18:41:26 +01:00
|
|
|
src/parser/wordsplit/wordsplit_utils.c \
|
2025-03-07 13:34:47 +01:00
|
|
|
src/postprocess/redirections/redirection.c \
|
2025-03-07 13:34:47 +01:00
|
|
|
src/postprocess/redirections/redirection_list.c \
|
2025-03-07 13:34:47 +01:00
|
|
|
src/postprocess/redirections/redirection_parsing.c \
|
2025-02-06 13:43:26 +01:00
|
|
|
|
|
|
|
|
objs = $(srcs:.c=.o)
|
2025-02-06 15:48:48 +01:00
|
|
|
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)
|
|
|
|
|
|
2025-02-14 13:32:21 +01:00
|
|
|
.PHONY: all clean fclean re norm tests ctests ctestsa ctestsub ctestst
|
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)
|
2025-02-06 15:48:48 +01:00
|
|
|
+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:
|
2025-02-12 16:53:48 +01:00
|
|
|
norminette src libft | grep -v OK || true
|
2025-02-06 15:13:34 +01:00
|
|
|
|
|
|
|
|
tests:
|
2025-02-06 15:48:48 +01:00
|
|
|
@echo "Running tests with AddressSanitizer..."
|
2025-02-06 15:13:34 +01:00
|
|
|
+CFLAGS="$(CFLAGS) $(ASAN)" make re
|
|
|
|
|
shellspec
|
2025-02-14 13:32:21 +01:00
|
|
|
+make ctestsa
|
2025-02-06 15:48:48 +01:00
|
|
|
|
|
|
|
|
@echo "Running tests with UndefinedBehaviourSanitizer..."
|
2025-02-06 15:13:34 +01:00
|
|
|
+CFLAGS="$(CFLAGS) $(UBSAN)" make re
|
|
|
|
|
shellspec
|
2025-02-14 13:32:21 +01:00
|
|
|
+make ctestsub
|
2025-02-06 15:48:48 +01:00
|
|
|
|
|
|
|
|
@echo "Running tests with ThreadSanitizer..."
|
2025-02-06 15:13:34 +01:00
|
|
|
+CFLAGS="$(CFLAGS) $(TSAN)" make re
|
|
|
|
|
shellspec
|
2025-02-14 13:32:21 +01:00
|
|
|
+make ctestst
|
2025-02-06 15:48:48 +01:00
|
|
|
|
2025-02-06 15:13:34 +01:00
|
|
|
@echo "All tests passed!"
|
2025-02-12 15:10:12 +01:00
|
|
|
|
2025-02-13 15:17:30 +01:00
|
|
|
ctests: $(LIBFT)
|
2025-02-12 15:10:12 +01:00
|
|
|
+make -C tests
|
2025-02-14 13:32:21 +01:00
|
|
|
|
|
|
|
|
ctestsa: CFLAGS += $(ASAN)
|
|
|
|
|
ctestsa: ctests
|
|
|
|
|
ctestsub: CFLAGS += $(UBSAN)
|
|
|
|
|
ctestsub: ctests
|
|
|
|
|
ctestst: CFLAGS += $(TSAN)
|
|
|
|
|
ctestst: ctests
|