-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
106 lines (82 loc) · 2.44 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
.DEFAULT_GOAL := a
UTILS = utils/sigsegv.cpp utils/color.cpp utils/check.cpp
UTILS_O = $(UTILS:.cpp=.o)
TESTS_PATH = tests/
MANDATORY = strlen strcpy strcmp write read strdup
BONUS = atoi_base list_push_front list_size list_sort list_remove_if
ALL = $(MANDATORY) $(BONUS)
ALL := $(addprefix ft_, $(addsuffix _test.cpp, $(ALL)))
ALL := $(addprefix $(TESTS_PATH), $(ALL))
OBJECTS = $(UTILS:.cpp=.o) $(ALL:.cpp=.o)
VMANDATORY = $(addprefix v, $(MANDATORY))
VBONUS = $(addprefix v, $(BONUS))
VSOPEN = $(addprefix vs, $(MANDATORY)) $(addprefix vs, $(BONUS))
VIOPEN = $(addprefix vi, $(MANDATORY)) $(addprefix vi, $(BONUS))
# Code editors, you can change them to your preferred ones
CODE = code
VI = vim
DEBUG ?= 0
UPD ?= 1
CC = clang++
CFLAGS = -g3 -std=c++11 -I utils/ -I.
CFLAGS += -Wl,-z,noexecstack -Wno-unused-result -Wno-unknown-warning-option -Wno-unused-command-line-argument
VALGRIND = valgrind -q --leak-check=full
$(MANDATORY): %: mandatory_start $(UTILS_O) $(TESTS_PATH)ft_%_test.o
$(CC) $(CFLAGS) -fsanitize=address $(UTILS_O) $(TESTS_PATH)ft_$*_test.o -L.. -lasm
./a.out
ifneq ($(DEBUG), 1)
rm -f a.out
endif
$(VMANDATORY): v%: mandatory_start $(UTILS_O) $(TESTS_PATH)ft_%_test.o
$(CC) $(CFLAGS) $(UTILS_O) $(TESTS_PATH)ft_$*_test.o -L.. -lasm
$(VALGRIND) ./a.out
ifneq ($(DEBUG), 1)
rm -f a.out
endif
$(BONUS): %: bonus_start $(UTILS_O) $(TESTS_PATH)ft_%_test.o
$(CC) $(CFLAGS) -fsanitize=address $(UTILS_O) $(TESTS_PATH)ft_$*_test.o -L.. -lasm
./a.out
ifneq ($(DEBUG), 1)
rm -f a.out
endif
$(VBONUS): v%: bonus_start $(UTILS_O) $(TESTS_PATH)ft_%_test.o
$(CC) $(CFLAGS) $(UTILS_O) $(TESTS_PATH)ft_$*_test.o -L.. -lasm
$(VALGRIND) ./a.out
ifneq ($(DEBUG), 1)
rm -f a.out
endif
%.o: %.cpp
$(CC) $(CFLAGS) -c $< -o $@
$(VSOPEN): vs%:
$(CODE) $(TESTS_PATH)ft_$*_test.cpp
$(VIOPEN): vi%:
$(VI) $(TESTS_PATH)ft_$*_test.cpp
mandatory_start: update
tput setaf 6
make -C ..
tput setaf 4 && echo [Mandatory]
bonus_start: update
tput setaf 6
make bonus -C ..
tput setaf 5 && echo [Bonus]
update:
ifeq ($(UPD), 1)
tput setaf 3 && echo "[Checking for updates]"
git pull
else
tput setaf 3 && echo "[Skipping update check]"
endif
m: $(MANDATORY)
b: $(BONUS)
a: m b
vm: $(VMANDATORY)
vb: $(VBONUS)
va: vm vb
oclean:
rm -rf $(OBJECTS)
clean: oclean
make clean -C ..
fclean: oclean
make fclean -C ..
.PHONY: mandatory_start m vm bonus_start b vb a va oclean clean fclean update $(VSOPEN) $(VIOPEN)
.SILENT: