-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (36 loc) · 1.33 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
COMPILER = g++
CFLAGS := -std=c++2a -g -ggdb -O0 -Wall -Wextra $(shell pkg-config --cflags openssl libcurl) -Idate/include
LDFLAGS := -pthread $(shell pkg-config --libs openssl libcurl)
CC = $(COMPILER) $(strip $(CFLAGS) $(CHECKFLAGS))
CHECKFLAGS :=
MKBUILD := mkdir -p build
ifeq ($(CHECK), asan)
CHECKFLAGS += -fsanitize=address -fno-common
else ifeq ($(CHECK), msan)
CHECKFLAGS += -fsanitize=memory -fno-common
endif
.PHONY: all test clean depend mkbuild
all: Makefile
SOURCES := $(shell find -L src -name '*.cpp' | sed -nE '/(tests?|test_.+)\.cpp$$/!p')
OBJECTS := $(patsubst src/%.cpp,build/%.o, $(SOURCES))
sinclude $(shell find src -name 'targets.mk')
all: $(OBJECTS) build/tests
test: build/tests
./build/tests
grind: build/tests
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --show-reachable=yes ./build/tests
clean:
rm -rf build
build/%.o: src/%.cpp
@ mkdir -p "$(shell dirname "$@")"
$(CC) $(strip $(CPPFLAGS) $(CXXFLAGS) -Iinclude -c) $< -o $@
DEPFILE = .dep
DEPTOKEN = "\# MAKEDEPENDS"
DEPFLAGS = -f $(DEPFILE) -s $(DEPTOKEN)
depend:
@ echo $(DEPTOKEN) > $(DEPFILE)
makedepend $(DEPFLAGS) -- $(CC) -Iinclude -- $(SOURCES) 2>/dev/null
@ sed -i.sed 's/^src\//build\//' $(DEPFILE)
@ sed -i.sed '/\/usr\/include\//d' $(DEPFILE)
@ rm $(DEPFILE).bak $(DEPFILE).sed
sinclude $(DEPFILE)