This repository has been archived by the owner on Nov 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (55 loc) · 1.81 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
LIB_NAME = main
CLI_ARGUMENTS = input/glossy.ini
CXX = clang++ -std=c++20
GCOV = gcov
GCOVR = gcovr
COV_FLAGS = -lgcov -coverage
GCOV_FLAGS = -r . --html --html-details
DEBUG_FLAGS = -Wall -Wextra -pedantic -g
RELEASE_FLAGS = -O2 -DNDEBUG -g
SRC_DIR = src
OUT_DIR = build
LIB_DIR = lib
TST_DIR = test
OUTPUT_DIR = output
SRCS = $(shell find $(SRC_DIR) -name '*.cc')
TSTS = $(shell find $(TST_DIR) -name '*.cc')
TESTED = src/vectorUtils.cc
export OUTDIR = $(OUTPUT_DIR)/
.PHONY: run clean valgrind coverage format gdb
$(LIB_NAME):
mkdir -p $(OUT_DIR)
$(CXX) -c $(SRCS) $(RELEASE_FLAGS)
$(CXX) *.o -o $(OUT_DIR)/$(LIB_NAME) -lsfml-graphics -lsfml-window -lsfml-system
rm -f *.o
debug: # analyze
mkdir -p $(OUT_DIR)
$(CXX) -c $(SRCS) $(DEBUG_FLAGS)
$(CXX) *.o -o $(OUT_DIR)/$(LIB_NAME) -lsfml-graphics -lsfml-window -lsfml-system
rm -f *.o
analyze:
$(CXX) --analyze -Xanalyzer -analyzer-output=text $(SRCS)
run: $(LIB_NAME)
./build/main $(CLI_ARGUMENTS)
runDebug: debug
./$(OUT_DIR)/main $(CLI_ARGUMENTS)
buildTest:
$(CXX) $(DEBUG_FLAGS) $(TSTS) -L$(LIB_DIR) -o $(OUT_DIR)/test -lsfml-graphics -lsfml-system -I$(SRC_DIR) $(TESTED)
rm -f *.o
test: buildTest
./$(OUT_DIR)/test
valgrind: debug
valgrind --tool=memcheck --leak-check=full --show-reachable=yes --track-origins=yes ./$(OUT_DIR)/$(LIB_NAME)
valgrind-v: debug
valgrind --tool=memcheck -v --leak-check=full --show-reachable=yes --track-origins=yes ./$(OUT_DIR)/$(LIB_NAME)
callgrind: debug
rm -f $(OUT_DIR)/callgrind.out.*
valgrind --tool=callgrind ./$(OUT_DIR)/$(LIB_NAME)
mv callgrind.out.* build/
kcachegrind $(OUT_DIR)/callgrind.out.*
format:
clang-format -i $(shell find . -name '*.cc') $(shell find . -name '*.hpp' ! -name 'catch_amalgamated.hpp') -style=webkit
clean:
-rm -rf $(OUT_DIR) $(COV_DIR)
gdb: debug
gdb ./$(OUT_DIR)/$(LIB_NAME)