minishell/Makefile

67 lines
1.3 KiB
Makefile
Raw Normal View History

2025-02-06 13:43:26 +01:00
NAME = minishell
DEBUG = -g
ASAN = -fsanitize=address
TSAN = -fsanitize=thread
UBSAN = -fsanitize=undefined
LDLIBS = \
-lreadline \
2025-02-06 13:43:26 +01:00
ifeq ($(CFLAGS),)
CFLAGS = -Wall -Wextra -Werror $(DEBUG)
endif
export CFLAGS
srcs = \
src/parser/matchers/metacharacter.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)
2025-02-06 15:13:34 +01:00
.PHONY: all clean fclean re norm tests
2025-02-06 13:43:26 +01:00
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
2025-02-06 13:43:26 +01:00
re:
+make fclean
+make all
2025-02-06 13:45:29 +01:00
norm:
norminette src | grep -v OK || true
2025-02-06 15:13:34 +01:00
tests:
@echo "Running tests with AddressSanitizer..."
2025-02-06 15:13:34 +01:00
+CFLAGS="$(CFLAGS) $(ASAN)" make re
shellspec
+CFLAGS="$(CFLAGS) $(ASAN)" make -C tests
@echo "Running tests with UndefinedBehaviourSanitizer..."
2025-02-06 15:13:34 +01:00
+CFLAGS="$(CFLAGS) $(UBSAN)" make re
shellspec
+CFLAGS="$(CFLAGS) $(UBTSAN)" make -C tests
@echo "Running tests with ThreadSanitizer..."
2025-02-06 15:13:34 +01:00
+CFLAGS="$(CFLAGS) $(TSAN)" make re
shellspec
+CFLAGS="$(CFLAGS) $(TSAN)" make -C tests
2025-02-06 15:13:34 +01:00
@echo "All tests passed!"