-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
179 lines (147 loc) · 4.91 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
##
## EPITECH PROJECT, 2023
## 42sh
## File description:
## The main Makefile of our project
##
NAME = 42sh
CC = gcc
DEBUG_MODE =
BUILDDIR = ./build
SRCDIR = ./src
SRCS = ../src/main.c
SRCS += ../src/builtins/about.c
SRCS += ../src/builtins/alias.c
SRCS += ../src/builtins/cd.c
SRCS += ../src/builtins/echo.c
SRCS += ../src/builtins/else.c
SRCS += ../src/builtins/end.c
SRCS += ../src/builtins/endif.c
SRCS += ../src/builtins/env.c
SRCS += ../src/builtins/exec.c
SRCS += ../src/builtins/exit.c
SRCS += ../src/builtins/foreach.c
SRCS += ../src/builtins/help.c
SRCS += ../src/builtins/history.c
SRCS += ../src/builtins/if.c
SRCS += ../src/builtins/repeat.c
SRCS += ../src/builtins/set.c
SRCS += ../src/builtins/setenv.c
SRCS += ../src/builtins/source.c
SRCS += ../src/builtins/unalias.c
SRCS += ../src/builtins/unset.c
SRCS += ../src/builtins/unsetenv.c
SRCS += ../src/builtins/where.c
SRCS += ../src/builtins/which.c
SRCS += ../src/globbing/globbing.c
SRCS += ../src/history/history_file.c
SRCS += ../src/history/event.c
SRCS += ../src/inhibitors/array_separators.c
SRCS += ../src/inhibitors/array_string.c
SRCS += ../src/inhibitors/inhibitors.c
SRCS += ../src/line-editing/ansi.c
SRCS += ../src/line-editing/my_getline.c
SRCS += ../src/line-editing/termios.c
SRCS += ../src/parsing/condition.c
SRCS += ../src/parsing/input_command.c
SRCS += ../src/parsing/parsing.c
SRCS += ../src/parsing/replace_alias.c
SRCS += ../src/parsing/replace_variable.c
SRCS += ../src/parsing/tilde.c
SRCS += ../src/prompt/prompt.c
SRCS += ../src/prompt/git_repository.c
SRCS += ../src/prompt/title.c
SRCS += ../src/separators/backticks.c
SRCS += ../src/separators/left_redirections.c
SRCS += ../src/separators/multiple_commands.c
SRCS += ../src/separators/operators.c
SRCS += ../src/separators/parentheses.c
SRCS += ../src/separators/pipes.c
SRCS += ../src/separators/redirections.c
SRCS += ../src/separators/right_redirections.c
SRCS += ../src/command.c
SRCS += ../src/config_file.c
SRCS += ../src/environnement.c
SRCS += ../src/scripting.c
SRCS += ../src/shell.c
SRCS += ../src/signals.c
OBJS = $(addprefix $(BUILDDIR)/, $(notdir $(SRCS:.c=.o)))
CFLAGS = -Werror -Wextra -I./include/
DEBUGFLAGS = -g3
OPTIMIZEFLAGS = -O3
VALGRINDFLAGS = --leak-check=full --show-leak-kinds=all --track-origins=yes
OUTPUT = valgrind.log
LDFLAGS = -L./lib/ -lmymemory -lmylist -lmy
.PHONY: all libs create-build debug clean fclean re re_debug \
tests unit_tests tests_run doc
all: create-build libs $(BUILDDIR) $(NAME)
@echo -e "\033[1;33m42sh compiled.\033[0m"
libs:
@make --no-print-directory -C ./lib/my/ $(DEBUG_MODE)
@make --no-print-directory -C ./lib/mylist/ $(DEBUG_MODE)
@make --no-print-directory -C ./lib/mymemory/ $(DEBUG_MODE)
@echo -e "\033[1;33mLibs made.\033[0m"
create-build:
@mkdir -p $(BUILDDIR)
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $(OPTIMIZEFLAGS) $(LDFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: $(SRCDIR)/builtins/%.c
$(CC) $(CFLAGS) $(OPTIMIZEFLAGS) $(LDFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: $(SRCDIR)/globbing/%.c
$(CC) $(CFLAGS) $(OPTIMIZEFLAGS) $(LDFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: $(SRCDIR)/history/%.c
$(CC) $(CFLAGS) $(OPTIMIZEFLAGS) $(LDFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: $(SRCDIR)/inhibitors/%.c
$(CC) $(CFLAGS) $(OPTIMIZEFLAGS) $(LDFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: $(SRCDIR)/line-editing/%.c
$(CC) $(CFLAGS) $(OPTIMIZEFLAGS) $(LDFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: $(SRCDIR)/parsing/%.c
$(CC) $(CFLAGS) $(OPTIMIZEFLAGS) $(LDFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: $(SRCDIR)/prompt/%.c
$(CC) $(CFLAGS) $(OPTIMIZEFLAGS) $(LDFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: $(SRCDIR)/separators/%.c
$(CC) $(CFLAGS) $(OPTIMIZEFLAGS) $(LDFLAGS) -c $< -o $@
debug: CFLAGS += $(DEBUGFLAGS)
debug: OPTIMIZEFLAGS =
debug: DEBUG_MODE = debug
debug: all
$(NAME): $(OBJS)
@$(CC) $(OBJS) $(CFLAGS) $(LDFLAGS) -o $(NAME)
clean:
@rm -rf $(BUILDDIR)
@echo -e "\033[1;31mAll .o deleted.\033[0m"
fclean: clean
@find -type f -name "*.a" -exec rm -f {} \;
@rm -rf unit_tests*
@rm -rf tests/unit_tests*
@rm -rf vgcore*
@rm -rf *.log
@rm -rf $(NAME)
@echo -e "\033[1;31mProject cleaned.\033[0m"
re: fclean all
re_debug: fclean debug
valgrind: fclean debug
@echo -e "\033[0;36mExecuting valgrind...\033[0m"
@valgrind $(VALGRINDFLAGS) ./$(NAME) 2> $(OUTPUT)
tests: re
@./tester.sh
# Unit tests Makefile
unit_tests:
@make unit_tests --no-print-directory -C./tests/
tests_run:
@make tests_run --no-print-directory -C./tests/
@gcovr \
--exclude lib/my/my_printf/round_flag_a.c \
--exclude lib/mylist/my_list_to_array.c \
--exclude lib/mylist/my_show_list.c
# Documentation
doc: tests_run
@doxygen Doxyfile
@gcovr \
--exclude lib/my/my_printf/round_flag_a.c \
--exclude lib/mylist/my_list_to_array.c \
--exclude lib/mylist/my_show_list.c \
--branch --html-details docs/tests/test.html
@echo -e "\033[1;33mDocumentation generated.\033[0m"
@google-chrome docs/html/index.html
@google-chrome docs/tests/test.html