-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
63 lines (57 loc) · 1.6 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
SHELL = /bin/sh
#specify .o names
SRC_DIR = ./src
OBJ_DIR = ./build
TEST_OBJ_DIR = ./tests/build_tests
SRCS = $(shell find ${SRC_DIR} -name '*.cpp')
OBJS = hood.o clouster_matrix.o fill.o index_matrix.o path.o \
percolation.o sep.o size_clouster.o main1_code.o
TESTSDIR = ./tests
#specify to the compiler where to find the headers
INCLUDES = -I "./include"
#compiler specifications
CXX = g++
CXXFLAGS = -Wall
OPTIMIZATIONFLAG = -O3
SANITIZERS = -fsanitize=leak -fsanitize=address -fsanitize=leak
DEBUGFLAG = -g
PROFILEFLAG= -pg
#File list used for each test
FILESTESTSIZE = clouster_matrix.cpp percolation.cpp index_matrix.cpp
TESTFLAG = $(shell pkg-config --cflags catch2)
#specify profile report name
PROF_REPORT = prof_report.txt
#specify where to find the .cpp files
vpath %.cpp ./src
vpath %.o ./build
foo: ${OBJS}
${CXX} ${CXXFLAGS} ${PROFILEFLAG} ${SANITIZERS} ${INCLUDES} -o $@ \
$(shell find ${OBJ_DIR} -name '*.o')
clean:
-rm -f ${OBJ_DIR}/*.o foo* *.out ${PROF_REPORT}
-cd tests; make clean
#implicit rule for making .o from .cpp
.cpp.o:
@ -mkdir build
${CXX} ${CXXFLAGS} ${PROFILEFLAG} ${SANITIZERS} ${INCLUDES} -c $< -o ${OBJ_DIR}/$@
#format .cpp files using clang format
format:
clang-format -i --dry-run src/*.cpp
clang-format -i --dry-run include/*.hpp
#debug the code
debug:
${CXX} ${DEBUGFLAG} ${INCLUDES} ${SRCS} -o foo_debug
chmod +x init_debug.sh
./init_debug.sh
report:
pdflatex main.tex
simu1:
./foo 4 0.6 1
profile:
./foo 8 0.5 2
gprof foo gmon.out>${PROF_REPORT}
cat ${PROF_REPORT}
test:
cp -v -u ./build/*.o tests/build_tests/
rm tests/build_tests/main1_code.o
cd tests; make; ./test.x