-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
124 lines (89 loc) · 2.29 KB
/
Makefile
File metadata and controls
124 lines (89 loc) · 2.29 KB
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
##
## EPITECH PROJECT, 2024
## liblinked
## File description:
## Makefile
##
NAME = linked
LIB = lib$(NAME).a
INC = include/linked.h
CC = gcc
TMPDIR = tmp
INST_BIN_DIR = /usr/local/lib/
INST_INC_DIR = /usr/local/include
# Sources
SRC = list_add.c \
list_insert.c \
list_create.c \
list_destroy.c \
list_handle.c \
list_node_utils.c \
list_positional_utils.c \
list_remove.c \
list_size.c \
list_utils.c \
list_handle_if.c \
comparators/list_int_comp.c \
comparators/list_float_comp.c \
comparators/list_double_comp.c \
comparators/list_char_comp.c \
comparators/list_str_comp.c \
list_find.c \
SRC := $(addprefix src/,$(SRC))
OBJ = $(SRC:%.c=$(TMPDIR)/%.o)
CFLAGS += -W -Wall -Wextra -Iinclude
# Tests
TNAME = unit_tests
TSRC = list_add_tests.c \
list_insert_tests.c \
list_create_tests.c \
list_destroy_tests.c \
list_handle_tests.c \
list_remove_tests.c \
list_size_tests.c \
list_utils_tests.c \
test_utils.c \
comparators/list_int_comp_tests.c \
comparators/list_float_comp_tests.c \
comparators/list_double_comp_tests.c\
comparators/list_char_comp_tests.c \
comparators/list_str_comp_tests.c \
list_find_tests.c \
TSRC := $(addprefix tests/unit_tests/,$(TSRC))
TOBJ = $(TSRC:%.c=$(TMPDIR)/%.o)
MAIN = tests/main.c
MOBJ = $(MAIN:%.c=$(TMPDIR)/%.o) $(OBJ)
TFLAGS = -lcriterion -lgcov --coverage -Itests/include
VFLAGS = --track-origins=yes --leak-check=full --show-leak-kinds=all
# Rules
$(LIB): $(OBJ)
ar rc $(LIB) $(OBJ)
all: $(LIB)
install: $(LIB)
sudo cp $(LIB) $(INST_BIN_DIR)
sudo cp $(INC) $(INST_INC_DIR)
sudo ldconfig
uninstall:
sudo rm -f $(INST_BIN_DIR)/$(LIB)
sudo rm -f $(INST_INC_DIR)/$(INC)
sudo ldconfig
reinstall: uninstall install
clean:
rm -rf $(TMPDIR)
rm -f $(shell find . -type f -name '*.gc*')
fclean: clean
rm -f $(LIB)
rm -f $(NAME)
rm -f $(TNAME)
re: clean all
$(TNAME): CFLAGS += $(TFLAGS)
$(TNAME): $(TOBJ) $(OBJ)
$(CC) -o $@ $^ $(CFLAGS)
tests_run: $(TNAME)
./$(TNAME)
$(TMPDIR)/%.o: %.c
@mkdir -p $(@D)
gcc -o $@ -c $< $(CFLAGS) $(LDFLAGS)
val_tests: unit_tests
valgrind $(VFLAGS) ./unit_tests
.PHONY: all install uninstall reinstall clean fclean re tests_run val_tests