-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
207 lines (182 loc) · 6.77 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# **************************************************************************** #
# #
# :::::::: #
# Makefile :+: :+: :+: #
# +:+ #
# By: dbasting <[email protected]> +#+ #
# +#+ #
# Created: 2022/12/28 12:06:53 by dbasting #+# #+# #
# Updated: 2023/09/18 14:40:54 by dbasting ### ########.fr #
# #
# **************************************************************************** #
NAME := minishell
OS := $(shell uname -s)
SRC_FILES := main.c\
builtins/cd.c\
builtins/echo.c\
builtins/env.c\
builtins/exit.c\
builtins/export.c\
builtins/pwd.c\
builtins/unset.c\
env/env.c\
env/env_append_val.c\
env/env_basevars.c\
env/env_search.c\
env/env_set.c\
env/env_set_main.c\
env/env_unset.c\
env/env_update.c\
env/env_utils.c\
execute/execute.c\
execute/execute_bin.c\
execute/execute_cmd.c\
execute/execute_pipeline.c\
execute/execute_subsh.c\
execute/execute_wait.c\
execute/path.c\
expand/expand.c\
expand/expand_fieldsplit.c\
expand/expand_glob.c\
expand/expand_spec_exit.c\
expand/expand_spec_nparam.c\
expand/expand_spec_opts.c\
expand/expand_spec_pid.c\
expand/expand_spec_pos.c\
expand/expand_spec_shname.c\
expand/expand_utils.c\
expand/expand_var.c\
expand/glob/ft_glob.c\
expand/glob/ft_glob_destroy.c\
expand/glob/ft_glob_init.c\
expand/glob/glob_add.c\
expand/glob/glob_cmp.c\
expand/glob/glob_patcmp.c\
expand/glob/glob_readdir.c\
expand/glob/glob_sortdir.c\
lex/lex.c\
minishell/cmd.c\
minishell/cmdline.c\
minishell/cmdline_prompt.c\
minishell/cmdtree.c\
minishell/error.c\
minishell/heredoc.c\
minishell/heredoc_read.c\
minishell/msh_loop.c\
minishell/prompt.c\
minishell/signal.c\
parse/parse.c\
parse/parse_cmd.c\
parse/parse_cmdtree.c\
parse/parse_in.c\
parse/parse_operator.c\
parse/parse_out.c\
parse/parse_pipe.c\
parse/parse_pipeline.c\
parse/parse_utils.c\
parse/parse_word.c\
syntax/syntax.c\
syntax/syntax_process.c\
token/token.c\
token/token_read.c\
token/token_type.c\
utils/path_canonicalize.c\
utils/utils.c\
utils/utils_list.c\
utils/utils_quotes.c\
var/var.c\
var/var_parse.c\
var/var_utils.c\
\
debug.c
OBJ_FILES := $(patsubst %.c,%.o,$(SRC_FILES))
HDR_FILES := msh.h\
msh_error.h\
msh_env.h\
msh_execute.h\
msh_expand.h\
msh_parse.h\
msh_prompt.h\
msh_token.h\
msh_utils.h\
msh_var.h\
\
ft_glob.h\
ft_glob_utils.h\
list_utils.h\
msh_debug.h
LIB_FILES := libft.a
SRC_DIR := ./source/
SRC_SUBDIRS := builtins/ env/ execute/ expand/ expand/glob lex/ minishell/\
parse/ syntax/ test/ token/ utils/ var/
OBJ_DIR := ./object/
OBJ_SUBDIRS := $(SRC_SUBDIRS)
HDR_DIR := ./include/
LIB_DIR := ./lib/
CFLAGS += -Wall -Wextra -Werror -I$(LIB_DIR)libft/include/ -I$(HDR_DIR)
LDFLAGS := -lreadline
ifeq ($(OS),Darwin)
LDFLAGS += -L$(HOME)/.brew/opt/readline/lib/
CFLAGS += -I$(HOME)/.brew/opt/readline/include
endif
.PHONY: all bonus clean fclean re
all: $(NAME)
bonus: $(NAME)
@echo "Bonus is basis, vrind."
$(NAME): $(addprefix $(OBJ_DIR),$(OBJ_FILES)) $(addprefix $(LIB_DIR),$(LIB_FILES))
@$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
$(OBJ_DIR)%.o: $(SRC_DIR)%.c $(addprefix $(HDR_DIR),$(HDR_FILES))
@mkdir -p $(addprefix $(OBJ_DIR),$(OBJ_SUBDIRS))
@$(CC) $(CFLAGS) -I$(HDR_DIR) $< -c -o $@
$(LIB_DIR)%.a:
@$(MAKE) -j --directory=$(LIB_DIR)
clean:
@$(MAKE) -j --directory=$(LIB_DIR) clean
@rm -f $(addprefix $(OBJ_DIR),$(OBJ_FILES))
fclean: clean
@$(MAKE) -j --directory=$(LIB_DIR) fclean
@rm -f $(NAME)
re: fclean all
test_cd:
$(MAKE) -j -C lib/libft
cc $(CFLAGS) -lcriterion source/builtins/cd.c source/env/env.c source/env/env_append_val.c source/env/env_search.c source/env/env_set.c source/env/env_set_main.c source/env/env_update.c source/env/env_utils.c source/env/env_basevars.c source/minishell/error.c source/var/var_parse.c test/builtins/cd/cd_unittest.c lib/libft/libft.a && ./a.out
rm a.out
test_echo:
$(MAKE) -j -C lib/libft
cc $(CFLAGS) -lcriterion source/builtins/echo.c test/builtins/echo/echo_unittest.c lib/libft/libft.a && ./a.out
rm a.out
test_env:
$(MAKE) -j -C lib/libft
cc $(CFLAGS) -lcriterion source/builtins/env.c source/env/env_append_val.c source/env/env_utils.c test/builtins/env/env_unittest.c lib/libft/libft.a && ./a.out
rm a.out
test_export:
$(MAKE) -j -C lib/libft
cc $(CFLAGS) -lcriterion source/builtins/export.c source/env/env.c source/env/env_append_val.c source/env/env_utils.c source/env/env_search.c source/env/env_set.c source/env/env_set_main.c source/env/env_basevars.c source/var/var_parse.c test/builtins/export/export_unittest.c lib/libft/libft.a && ./a.out
rm a.out
test_pwd:
$(MAKE) -j -C lib/libft
cc $(CFLAGS) -lcriterion source/builtins/pwd.c test/builtins/pwd/pwd_unittest.c lib/libft/libft.a && ./a.out
rm a.out
test_unset:
$(MAKE) -j -C lib/libft
cc $(CFLAGS) -lcriterion source/env/env_append_val.c source/builtins/unset.c source/env/env.c source/env/env_unset.c source/env/env_basevars.c source/env/env_utils.c source/env/env_search.c source/env/env_set.c source/env/env_set_main.c source/var/var_parse.c source/var/var_utils.c test/builtins/unset/unset_unittest.c lib/libft/libft.a && ./a.out
rm a.out
test_lexer:
$(MAKE) -j -C lib/libft
cc $(CFLAGS) -lcriterion source/lex/token.c test/msh/lex/lex_unittest.c lib/libft/libft.a && ./a.out
rm a.out
test_expander:
$(MAKE) -j -C lib/libft
cc $(CFLAGS) -lcriterion test/msh/expand/expand_unittest.c source/expand/*.c source/var/var.c source/var/var_parse.c source/env/*.c source/utils/*.c lib/libft/libft.a && ./a.out
rm a.out
test_parser:
$(MAKE) -j -C lib/libft
cc $(CFLAGS) -lcriterion test/msh/parse/parse_unittest.c source/parse/parse_utils.c lib/libft/libft.a && ./a.out
rm a.out
test_msh_env:
$(MAKE) -j -C lib/libft
cc $(CFLAGS) -lcriterion source/env/env.c source/env/env_utils.c source/env/env_search.c source/env/env_unset.c source/env/env_set.c source/env/env_set_main.c source/env/env_append_val.c source/env/env_update.c source/env/env_basevars.c source/var/var_parse.c test/msh/env/env_unittest.c lib/libft/libft.a && ./a.out
rm a.out
test_glob:
$(MAKE) -j -C lib/libft
cc $(CFLAGS) -Wl,--wrap=glob_readdir test/msh/glob/glob_unittest.c test/msh/glob/custom_glob_readdir.c source/utils/utils_list.c source/expand/glob/* lib/libft/libft.a