-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
111 lines (75 loc) · 1.9 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
##
## EPITECH PROJECT, 2022
## Makefile
## File description:
## makefile
##
NAME = libmy_malloc.so
BIN = malloc
#########################################
############ COMPILIATION ###############
#########################################
CC = gcc
SRC_DIR = src/
SRC = $(SRC_DIR)my_malloc.c \
$(SRC_DIR)free.c \
$(SRC_DIR)calloc.c \
$(SRC_DIR)core.c \
$(SRC_DIR)realloc.c \
$(SRC_DIR)reallocarray.c \
# $(SRC_DIR)debug.c \
OBJ = $(SRC:.c=.o)
CFLAGS = -Wall -Wextra -fPIC
CPPFLAGS = -I./include
INCL = -I./include
#########################################
################# TESTS #################
#########################################
TESTS = unit_tests
GCOVR = gcovr
CRIT = -lcriterion
COVER = --coverage
BRANCH = --branches
EXCLUD = --exclude
TESTS_SRC = $(SRC_DIR)my_malloc.c \
UNIT_TEST = tests/tests_my_malloc.c \
#########################################
################# CLEAN #################
#########################################
RM = rm -f
#########################################
################# RULES #################
#########################################
all: $(NAME)
$(NAME): $(OBJ)
$(CC) -shared -fPIC -o $(NAME) $(OBJ) $(INCL)
db: CFLAGS += -g3
db: $(OBJ)
$(CC) -o $(NAME) $(OBJ) $(LIB)
x:
$(CC) -o $(BIN) $(INCL) $(SRC_DIR)main.c
LD_PRELOAD=./$(NAME) ./$(BIN)
xdb: $(OBJ)
$(CC) -o $(BIN) $(INCL) $(OBJ) $(SRC_DIR)main.c -g3
LD_PRELOAD=./$(NAME) gdb $(BIN)
ls:
LD_PRELOAD=./$(NAME) ls
lsl:
LD_PRELOAD=./$(NAME) ls -l
tree:
LD_PRELOAD=./$(NAME) tree
unit_test: fclean
$(CC) -o $(TESTS) $(TESTS_SRC) $(UNIT_TEST) $(LIB)$(INCL) $(COVER) $(CRIT)
tests_run: unit_test
./$(TESTS)
$(GCOVR) $(EXCLUD) $(TESTS_DIR)
$(GCOVR) $(EXCLUD) $(TESTS_DIR) $(BRANCH)
clean:
$(RM) $(OBJ) *gc*
fclean: clean
$(RM) $(NAME) $(TESTS)
$(RM) $(BIN)
$(RM) vgcore*
re: fclean all
redb: fclean db
.PHONY: all tests fclean re db redb