-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
189 lines (155 loc) · 4.08 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
##
## EPITECH PROJECT, 2022
## 42sh
## File description:
## Makefile
##
BUILTIN_DIR = builtin
BUILTIN_SRC = alias.c \
builtin.c \
directories.c \
history.c \
home.c \
localenv.c \
silent.c \
silent_dirs.c \
unalias.c
COMMAND_DIR = command
COMMAND_SRC = errors.c \
execution.c \
executor.c \
input.c \
logical.c \
output.c \
parsing.c \
paths.c \
redirections.c \
signal.c
REDIRECTION_DIR = redirection
REDIRECTION_SRC = files.c \
pipes.c
UTILS_DIR = utils
UTILS_SRC = home.c \
lists.c \
logical.c \
redirections.c \
replacements.c \
startup.c \
strings.c \
prompt.c \
tests.c \
variables.c \
status.c \
graphics/arrows.c \
graphics/init.c \
graphics/input.c \
graphics/lines.c \
graphics/operations.c \
history/history.c \
history/interact.c \
history/substitutions.c \
history/add.c \
history/save.c
ENV_DIR = environment
ENV_SRC = environment.c \
environment_utils.c \
variables.c \
local/localenv_utils.c \
local/localenv_load.c \
local/localset_checks.c \
local/localenv.c
JOB_DIR = job_control
JOB_SRC = handle_job.c \
remove_job.c \
builtin_job.c \
silent_job.c \
BASE_DIR = src
BASE_SRC = shell.c \
$(addprefix $(BUILTIN_DIR)/, $(BUILTIN_SRC)) \
$(addprefix $(COMMAND_DIR)/, $(COMMAND_SRC)) \
$(addprefix $(REDIRECTION_DIR)/, $(REDIRECTION_SRC)) \
$(addprefix $(UTILS_DIR)/, $(UTILS_SRC)) \
$(addprefix $(ENV_DIR)/, $(ENV_SRC)) \
$(addprefix $(JOB_DIR)/, $(JOB_SRC))
TESTS_DIR = tests/src
TESTS_SRC = test_shell.c \
builtin/tests_alias.c \
builtin/tests_cd.c \
builtin/tests_env.c \
builtin/tests_exit.c \
builtin/tests_history.c \
builtin/tests_localenv.c \
separators/tests_and.c \
separators/tests_or.c \
separators/tests_semicolon.c \
test_builtin.c \
test_redirections.c
MAIN = main.c
SRC = $(addprefix $(BASE_DIR)/, $(BASE_SRC)) \
$(addprefix $(BASE_DIR)/, $(MAIN))
TEST = $(addprefix $(BASE_DIR)/, $(BASE_SRC)) \
$(addprefix $(TESTS_DIR)/, $(TESTS_SRC))
OBJ = $(SRC:.c=.o)
TEST_OBJ = $(TEST:.c=.o)
LIBS = my
LIB_DIRS = $(addprefix lib/, $(LIBS))
BINARY = 42sh
TEST_BINARY = $(BINARY).test
DEBUG_BINARY = $(BINARY).debug
HEADERS_DIRS = include/ \
$(LIB_DIRS:%=%/include/)
CFLAGS = -Wall -Wextra
CPPFLAGS = $(HEADERS_DIRS:%=-iquote %)
LDLIBS = $(addprefix -l, $(LIBS)) -lncurses
LDFLAGS = $(addprefix -L, $(LIB_DIRS))
VG_FLAGS = --leak-check=full --track-origins=yes --show-leak-kinds=all \
--error-limit=no --trace-children=no
CC = gcc
VG = valgrind $(VG_FLAGS)
all: $(BINARY)
$(BINARY): $(OBJ)
$(MAKE) $(LIBS)
$(CC) -o $(BINARY) $(OBJ) $(LDFLAGS) $(LDLIBS)
$(TEST_BINARY): LDLIBS += -lcriterion -lgcov
$(TEST_BINARY): CFLAGS += -ftest-coverage -fprofile-arcs
$(TEST_BINARY): $(TEST_OBJ)
$(MAKE) $(LIBS)
$(CC) -o $(TEST_BINARY) $(TEST_OBJ) $(LDFLAGS) $(LDLIBS)
$(DEBUG_BINARY): CFLAGS += -g
$(DEBUG_BINARY): $(OBJ) $(LIBS)
$(MAKE) $(LIBS)
$(CC) -o $(DEBUG_BINARY) $(OBJ) $(LDFLAGS) $(LDLIBS)
$(LIBS):
$(MAKE) -C $(@:%=lib/%)
clean:
$(RM) $(OBJ) $(TEST_OBJ)
fclean: clean
$(RM) $(BINARY) $(TEST_BINARY) $(DEBUG_BINARY)
clean_coverage: fclean
@find \( -name '*.gcno' -o -name '*.gcda' \) -delete
re: fclean all
debug_run: fclean $(DEBUG_BINARY)
$(VG) ./$(DEBUG_BINARY) $(ARGS)
tests_all:
$(MAKE) func_tests
$(MAKE) tests_run
$(MAKE) mem_checks
tests_run:
@$(MAKE) clean_coverage > /dev/null
@$(MAKE) $(TEST_BINARY) > /dev/null
./$(TEST_BINARY)
func_tests:
@$(MAKE) re > /dev/null
@python3 -m pip install termcolor > /dev/null
python3 tests/functional/tester.py -adc
mem_checks:
@$(MAKE) fclean > /dev/null
@$(MAKE) $(DEBUG_BINARY) > /dev/null
@python3 -m pip install termcolor > /dev/null
python3 tests/memory_checker.py -pcd
norm_checks:
@$(MAKE) fclean > /dev/null
@python3 -m pip install termcolor > /dev/null
python3 tests/norm/style.py ./$(BASE_DIR)
.PHONY: all clean fclean clean_coverage re debug_run tests_all tests_run \
func_tests mem_checks norm_checks