-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
122 lines (98 loc) · 3.38 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
##
## EPITECH PROJECT, 2022
## Makefile
## File description:
## Makefile for ftrace
##
NAME = ftrace
INCLUDE = -I include/ -I include/lib/ -L lib/ \
-lmy -lmyprintf -lformatstring -lelf
CFLAGS += -Wall -Wextra -pedantic \
-Wstrict-prototypes -fstack-protector\
-Wold-style-definition -std=c99 \
-O0 -Wl,-z,norelro -fno-stack-protector \
-pipe $(INCLUDE)
SOURCES = src/
MAIN = $(SOURCES)main.c
SRC = $(SOURCES)ftrace.c \
$(SOURCES)stack.c \
$(SOURCES)get_symbol.c \
$(SOURCES)get_maps.c \
$(SOURCES)get_errno_code.c \
$(SOURCES)get_syscall.c \
$(SOURCES)print_syscall.c \
$(SOURCES)check_syscall.c \
$(SOURCES)check_funccall.c \
$(SOURCES)print/print_env.c \
$(SOURCES)print/print_num.c \
$(SOURCES)print/print_string.c \
$(SOURCES)print/print_pointer.c \
$(SOURCES)print/print_struct_stat.c \
$(SOURCES)print/print_void_ptr.c \
TESTS = tests/syscalls.c \
tests/print.c \
tests/ftrace.c \
SRC_COUNT = $(words $(SRC))
NB = 0
OBJ = $(SRC:.c=.o)
OBJ += $(MAIN:.c=.o)
TEMPFILES = *~ *vgcore* *.gcda *.html *.gcno unit_tests #*#
RM = rm -f
ECHO = /bin/echo -e
DEFAULT = "\033[00m"
BOLD = "\e[1m"
RED = "\e[31m"
GREEN = "\e[32m"
LIGHT_BLUE = "\e[94m"
WHITE = "\e[1;37m"
all: $(NAME)
$(NAME): $(OBJ)
@echo
@($(ECHO) $(BOLD) $(GREEN)✓$(LIGHT_BLUE) \
"SRC files sucessfully build. "$(DEFAULT))
@make -C lib/my/ --no-print-directory
@make -C lib/myprintf/ --no-print-directory
@make -C lib/formatstring/ --no-print-directory
@gcc -o $(NAME) $(OBJ) $(INCLUDE) \
&& $(ECHO) $(BOLD) $(GREEN)"\n► BUILD SUCCESS !"$(DEFAULT) \
|| ($(ECHO) $(BOLD) $(RED)"\n► BUILD FAILED"$(DEFAULT) && exit 1)
debug: CFLAGS += -g3 -pg
debug: all
clean:
@make -C lib/my/ clean --no-print-directory
@make -C lib/myprintf/ clean --no-print-directory
@make -C lib/formatstring/ clean --no-print-directory
@$(RM) $(OBJ)
@$(RM) $(TEMPFILES)
@($(ECHO) $(BOLD) $(GREEN)✓$(LIGHT_BLUE)" Clean SRC "$(DEFAULT))
fclean: clean
@make -C lib/myprintf/ fclean --no-print-directory
@make -C lib/formatstring/ fclean --no-print-directory
@make -C lib/my/ fclean --no-print-directory
@$(RM) $(NAME)
@$(RM) $(OBJ)
@$(RM) $(TEMPFILES)
@($(ECHO) $(BOLD) $(GREEN)✓$(LIGHT_BLUE)" Fclean SRC "$(DEFAULT))
re:
@make fclean --no-print-directory
@make --no-print-directory
tests_run:
@make -C lib/my/ --no-print-directory
@make -C lib/myprintf/ --no-print-directory
@make -C lib/formatstring/ --no-print-directory
@gcc -o unit_tests -Wall -Wextra $(SRC) $(TESTS) $(INCLUDE) \
-lcriterion --coverage
@./unit_tests
coverage: tests_run
@gcovr -r . --exclude tests/
@gcovr -b --exclude tests/
@gcovr --exclude tests/ --html --html-details -o coverage.html
@xdg-open coverage.html
docs: fclean
@doxygen Doxyfile
@xdg-open doc/html/index.html
%.o: %.c
@$(eval NB=$(shell echo $$(($(NB)+1))))
@gcc -c -o $@ $^ $(CFLAGS) && python3 build/build.py $< $(NB) \
$(SRC_COUNT)
.PHONY: all re clean fclean debug