forked from DanielSurf10/minishell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
165 lines (148 loc) · 5.11 KB
/
Makefile
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: danbarbo <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/03/23 21:20:35 by danbarbo #+# #+# #
# Updated: 2024/06/18 11:02:59 by danbarbo ### ########.fr #
# #
# **************************************************************************** #
NAME := minishell
NAME_BONUS := minishell_bonus
CFLAGS := -Wextra -Wall -Werror -g3
# CFLAGS := -g3
LIBFT_DIR := lib/libft
LIBFT := ${LIBFT_DIR}/libft.a
LIBS := ${LIBFT} -lreadline
HEADERS := -I include \
-I ${LIBFT_DIR}/include
SRCS := src/expander/expand_string_here_doc.c \
src/expander/utils.c \
src/expander/envp_list.c \
src/expander/expand_command.c \
src/expander/string_list.c \
src/expander/expand_string.c \
src/expander/utils_envp_list.c \
src/lexing/state.c \
src/lexing/token_list.c \
src/lexing/state_change_1.c \
src/lexing/utils.c \
src/lexing/utils_list.c \
src/lexing/state_change_2.c \
src/lexing/get_token_list.c \
src/utils_main.c \
src/executor/exec_pipe.c \
src/executor/exec_and_or.c \
src/executor/built-ins/exit.c \
src/executor/built-ins/exec_builtin.c \
src/executor/built-ins/export.c \
src/executor/built-ins/cd.c \
src/executor/built-ins/pwd.c \
src/executor/built-ins/echo.c \
src/executor/built-ins/utiils.c \
src/executor/built-ins/env.c \
src/executor/built-ins/unset.c \
src/executor/built-ins/utils_export.c \
src/executor/utils.c \
src/executor/exec_cmd.c \
src/executor/fd_list.c \
src/executor/signals/signals.c \
src/executor/signals/signal_handler.c \
src/executor/signals/signals_macros.c \
src/executor/exec_cmd_fork.c \
src/executor/exec_tree.c \
src/executor/create_argv.c \
src/parsing/get_tree.c \
src/parsing/make_tree_cmd.c \
src/parsing/here_doc.c \
src/parsing/make_tree_cmd_recursive.c \
src/parsing/make_tree.c \
src/main.c
OBJS := ${SRCS:src/%.c=obj/%.o}
SRCS_BONUS := src/expander/expand_string_here_doc.c \
src/expander/utils.c \
src/expander/envp_list.c \
src/expander/expand_command.c \
src/expander/string_list.c \
src/expander/expand_string.c \
src/expander/utils_envp_list.c \
src/lexing/state.c \
src/lexing/token_list.c \
src/lexing/state_change_1.c \
src/lexing/utils.c \
src/lexing/utils_list.c \
src/lexing/state_change_2.c \
src/lexing/get_token_list.c \
src/utils_main.c \
src/executor/exec_pipe.c \
src/executor/exec_and_or.c \
src/executor/built-ins/exit.c \
src/executor/built-ins/exec_builtin.c \
src/executor/built-ins/export.c \
src/executor/built-ins/cd.c \
src/executor/built-ins/pwd.c \
src/executor/built-ins/echo.c \
src/executor/built-ins/utiils.c \
src/executor/built-ins/env.c \
src/executor/built-ins/unset.c \
src/executor/built-ins/utils_export.c \
src/executor/utils.c \
src/executor/exec_cmd.c \
src/executor/fd_list.c \
src/executor/signals/signals.c \
src/executor/signals/signal_handler.c \
src/executor/signals/signals_macros.c \
src/executor/exec_cmd_fork.c \
src/executor/exec_tree.c \
src/executor/create_argv.c \
src/parsing/get_tree.c \
src/parsing/make_tree_cmd.c \
src/parsing/here_doc.c \
src/parsing/make_tree_cmd_recursive.c \
src/parsing/make_tree.c \
src/main.c
OBJS_BONUS := ${SRCS_BONUS:src_bonus/%.c=obj/%.o}
all: ${NAME}
bonus: all
${NAME}: ${LIBFT} ${OBJS}
@${CC} ${CFLAGS} ${HEADERS} ${OBJS} ${LIBS} -o ${NAME}
${NAME_BONUS}: ${LIBFT} ${OBJS_BONUS}
@${CC} ${CFLAGS} ${HEADERS} ${OBJS_BONUS} ${LIBS} -o ${NAME_BONUS}
obj/%.o: src/%.c
@mkdir -p ${dir $@}
@${CC} ${CFLAGS} -c ${HEADERS} $< -o $@
@printf "Compiling: ${notdir $<}\n"
obj/%.o: src_bonus/%.c
@mkdir -p ${dir $@}
@${CC} ${CFLAGS} -c ${HEADERS} $< -o $@
@printf "Compiling: ${notdir $<}\n"
${LIBFT}:
@make -C ${LIBFT_DIR} all
clean:
@rm -rf obj
@make -C ${LIBFT_DIR} clean
fclean: clean
@rm -f ${NAME}
@rm -f ${NAME_BONUS}
@make -C ${LIBFT_DIR} fclean
val: readline.supp all
@valgrind -q --suppressions=readline.supp \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--track-fds=yes \
--trace-children=yes \
--trace-children-skip='*/bin/*,*/sbin/*,/usr/bin/*' \
./${NAME}
readline.supp:
@echo '{' > $@
@echo ' ignore_libreadline_memory_errors' >> $@
@echo ' Memcheck:Leak' >> $@
@echo ' ...' >> $@
@echo ' obj:*/libreadline.so.*' >> $@
@echo '}' >> $@
re: fclean all
re_bonus: fclean bonus
.PHONY: all bonus clean fclean re re_bonus val