NAME = minishell DEBUG = -g ASAN = -fsanitize=address 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/parser/matchers/metacharacter.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 all: $(NAME) -include $(deps) $(NAME): $(minishell_objs) $(LIBFT) $(CC) $(CFLAGS) -o $@ $(minishell_objs) $(LINCLUDE) $(LDLIBS) $(LIBFT): +$(MAKE) -C $(LIBFTDIR) %.o: %.c $(CC) -c $(CFLAGS) $(IFLAGS) -o $*.o $*.c $(CC) -MM $(CFLAGS) $(IFLAGS) $*.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 | grep -v OK || true tests: @echo "Running tests with AddressSanitizer..." +CFLAGS="$(CFLAGS) $(ASAN)" make re shellspec +CFLAGS="$(CFLAGS) $(ASAN)" make -C tests @echo "Running tests with UndefinedBehaviourSanitizer..." +CFLAGS="$(CFLAGS) $(UBSAN)" make re shellspec +CFLAGS="$(CFLAGS) $(UBTSAN)" make -C tests @echo "Running tests with ThreadSanitizer..." +CFLAGS="$(CFLAGS) $(TSAN)" make re shellspec +CFLAGS="$(CFLAGS) $(TSAN)" make -C tests @echo "All tests passed!"