-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
80 lines (56 loc) · 1.7 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
.PHONY: redo clean debug all
ARG :=
CXX ?= clang++
SRC = $(wildcard src/*.cpp)
SRC += $(wildcard src/**/*.cpp)
SRC_C_H = src/**/*.cpp src/**/*.hpp
STRICT = -Werror
CSTD = -std=gnu++11
CSTD_LINT = --std=c++11
DEBUG = -g -DDEBUG -ggdb3 -pg
BIN = ./build/vr
CFLAGS := -Wall -Wextra -Wpedantic -ffast-math -Wno-unused
CFLAGS += -finline-functions -fno-strict-aliasing -funroll-loops
CFLAGS += -march=native -mtune=native -Wwrite-strings -fno-exceptions
#CFLAGS += -static
ANALYZE :=
ifeq ($(CXX), gcc)
ANALYZE = -fanalyzer
CFLAGS += -Wcast-align=strict
else ifeq ($(CXX), clang++)
#ANALYZE = -Xanalyzer
CFLAGS += -Wcast-align
else
CFLAGS +=
endif
all: format
@cmake --build build
redo: gen build all
@echo done
gen:
@cmake -S . -B build -G Ninja
scan:
@rm -r output
@scan-build -o ./output $(CXX) $(SRC) -o $(BIN) $(CFLAGS) $(DEBUG) $(CSTD) $(LIB)
@scan-view ./output/
fast:
$(CXX) $(SRC) -o $(BIN) $(CFLAGS) $(ANALYZE) $(CSTD) $(LIB) -Ofast $(FLAG)
debug:
$(CXX) $(SRC) -o $(BIN) $(CFLAGS) $(ANALYZE) $(DEBUG) $(CSTD) $(LIB) $(FLAG)
debug_gdb: debug
gdb --tui $(BIN)
#hidden_debug:
# @$(CXX) $(SRC) -o $(BIN) $(CFLAGS) $(ANALYZE) $(DEBUG) $(CSTD) $(LIB) -fsanitize=undefined
clean:
@rm -r output
@rm -r build
memcheck: debug
@valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -s $(BIN) ./main.vr
lint:
@cppcheck $(SRC_C_H) $(CSTD_LINT) --enable=all --check-config --quiet
format:
@clang-format -i src/**/*.cpp src/**/*.hpp
release:
$(CXX) $(SRC) -O2 -Ofast -o $(BIN) $(CFLAGS) $(CSTD) $(LIB) $(ANALYZE) -Werror $(STRICT) $(FLAG) -s
release_min_size:
$(CXX) $(SRC) -O2 -Oz -o $(BIN) $(CFLAGS) $(CSTD) $(LIB) $(ANALYZE) -Werror $(STRICT) $(FLAG) -s -fvpt -ftree-loop-optimize