NAME = minishell DEBUG = -g ASAN = -fsanitize=address TSAN = -fsanitize=thread UBSAN = -fsanitize=undefined LDLIBS = \ -lreadline \ 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) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(minishell_objs) $(LDLIBS) %.o: %.c $(CC) -c $(CFLAGS) $(LDFLAGS) -o $*.o $*.c $(CC) -MM $(CFLAGS) $(LDFLAGS) $*.c > $*.d clean: find . -name '*.o' -print -delete find . -name '*.d' -print -delete fclean: clean 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!"