-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
127 lines (106 loc) · 4.12 KB
/
Makefile
File metadata and controls
127 lines (106 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: yboumanz <yboumanz@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/01/14 13:04:12 by yboumanz #+# #+# #
# Updated: 2025/01/14 13:04:14 by yboumanz ### ########.fr #
# #
# **************************************************************************** #
NAME = minishell
CC = cc
CFLAGS = -Wall -Wextra -Werror
RM = rm -f
SRCS = srcs/main.c \
srcs/garbage_collector.c \
srcs/garbage_collector_utils.c \
srcs/signal_handler.c \
srcs/builtins/builtins.c \
srcs/builtins/builtins_utils.c \
srcs/builtins/builtins_utils2.c \
srcs/exec/exec.c \
srcs/exec/pipe_handler.c \
srcs/exec/redirection.c \
srcs/parser/tokenizer.c \
srcs/parser/tokenizer_utils.c \
srcs/parser/tokenizer_utils2.c \
srcs/parser/tokenizer_utils3.c \
srcs/parser/process_tokens.c \
srcs/parser/cmd_parser.c \
srcs/parser/cmd_parser_utils.c \
srcs/parser/parser_utils.c \
srcs/parser/split_with_quotes.c \
srcs/parser/split_utils.c \
srcs/parser/check_syntax_utils.c \
srcs/parser/check_syntax.c \
srcs/parser/expand_env_utils.c \
srcs/parser/expand_env.c \
srcs/utils.c
OBJS = $(SRCS:.c=.o)
LIBFT_DIR = libft
LIBFT = $(LIBFT_DIR)/libft.a
INCLUDES = -I./includes -I./$(LIBFT_DIR)
LIBS = -L$(LIBFT_DIR) -lft -L/usr/local/lib -lreadline
VALGRIND = valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -s --trace-children=yes --track-fds=yes $(V_FLAG)
VALGRIND_OTHER = valgrind --vgdb=yes
V_FLAG = --suppressions="valgrind_supp"
HELLGRIND = valgrind --tool=helgrind -g3
all: $(LIBFT) $(NAME)
@echo "Build completed successfully."
$(LIBFT):
@make -C $(LIBFT_DIR)
$(NAME): $(OBJS)
@$(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $(NAME)
%.o: %.c
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
@$(RM) $(OBJS)
@make -C $(LIBFT_DIR) clean
fclean: clean
@$(RM) $(NAME)
@make -C $(LIBFT_DIR) fclean
re: fclean all
run: $(NAME)
@echo "Running tests and comparing with Bash POSIX..."
@while read -r line; do \
echo "----------------------------------------"; \
echo "Running test: $$line"; \
echo "----------------------------------------"; \
echo "$$line" | ./$(NAME) > output_minishell.txt; \
echo "Minishell output:"; \
cat output_minishell.txt; \
echo "----------------------------------------"; \
echo "$$line" | /bin/bash --posix > output_bash.txt; \
echo "Bash POSIX output:"; \
cat output_bash.txt; \
echo "----------------------------------------"; \
done < tests/test
@$(RM) output_minishell.txt output_bash.txt
runv: $(NAME)
@echo "Running tests with Valgrind and comparing with Bash POSIX..."
@while read -r line; do \
echo "----------------------------------------"; \
echo "Running test: $$line"; \
echo "----------------------------------------"; \
echo "$$line" | ./$(NAME) > output_minishell.txt; \
echo "Minishell output:"; \
cat output_minishell.txt; \
echo "----------------------------------------"; \
echo "$$line" | /bin/bash --posix > output_bash.txt; \
echo "Bash POSIX output:"; \
cat output_bash.txt; \
echo "----------------------------------------"; \
echo "Running Valgrind..."; \
echo "$$line" | $(VALGRIND) ./$(NAME); \
echo "----------------------------------------"; \
done < data/test
@$(RM) output_minishell.txt output_bash.txt
valgrind: $(NAME)
@$(VALGRIND) ./$(NAME)
valgrind_other: $(NAME)
@$(VALGRIND_OTHER) ./$(NAME)
helgrind: $(NAME)
@$(HELLGRIND) ./$(NAME)
.PHONY: all clean fclean re run runv valgrind valgrind_other helgrind