mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
106 lines
2.3 KiB
Makefile
106 lines
2.3 KiB
Makefile
NAME = minishell
|
|
DEBUG = -g
|
|
# -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
|
|
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/buffer/buffer.c \
|
|
src/env/env.c \
|
|
src/env/env_convert.c \
|
|
src/env/env_manip.c \
|
|
src/env/envp.c \
|
|
src/ft_errno.c \
|
|
src/get_command.c \
|
|
src/parser/matchers/blank.c \
|
|
src/parser/matchers/identifier.c \
|
|
src/parser/matchers/metacharacter.c \
|
|
src/parser/matchers/operator_combo.c \
|
|
src/parser/matchers/operator_start.c \
|
|
src/parser/worddesc/worddesc.c \
|
|
src/parser/wordlist/wordlist.c \
|
|
src/parser/wordsplit/tokenizing_1_5.c \
|
|
src/parser/wordsplit/tokenizing_6_10.c \
|
|
src/parser/wordsplit/wordsplit.c \
|
|
src/parser/wordsplit/wordsplit_utils.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 ctests ctestsa ctestsub ctestst
|
|
|
|
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 libft | grep -v OK || true
|
|
|
|
tests:
|
|
@echo "Running tests with AddressSanitizer..."
|
|
+CFLAGS="$(CFLAGS) $(ASAN)" make re
|
|
shellspec
|
|
+make ctestsa
|
|
|
|
@echo "Running tests with UndefinedBehaviourSanitizer..."
|
|
+CFLAGS="$(CFLAGS) $(UBSAN)" make re
|
|
shellspec
|
|
+make ctestsub
|
|
|
|
@echo "Running tests with ThreadSanitizer..."
|
|
+CFLAGS="$(CFLAGS) $(TSAN)" make re
|
|
shellspec
|
|
+make ctestst
|
|
|
|
@echo "All tests passed!"
|
|
|
|
ctests: $(LIBFT)
|
|
+make -C tests
|
|
|
|
ctestsa: CFLAGS += $(ASAN)
|
|
ctestsa: ctests
|
|
ctestsub: CFLAGS += $(UBSAN)
|
|
ctestsub: ctests
|
|
ctestst: CFLAGS += $(TSAN)
|
|
ctestst: ctests
|