-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (79 loc) · 2.9 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
# compiler:
CXX = g++
# compiler flags:
CXXFLAGS = -std=c++14 -O3 -march=native -pedantic -Wall
# libraries to use:
LIBS = -lboost_timer -lboost_program_options -lboost_system -fopenmp
# find source and object files.
#SRCS = $(wildcard src/*.cxx)
SRCS = src/utils.cxx src/heap.cxx src/steiner.cxx src/checker.cxx
OBJS = $(subst .cxx,.o,$(SRCS))
# target executable to build:
TARGET = steiner_solver
# graph data file to read:
ifndef FILE
FILE = big8.gph
endif
# files that are coverage-test specific:
COVERAGEOBJS = $(subst .cxx,.cover,$(SRCS))
GCNOS = $(subst .cxx,.cover.gcno,$(SRCS))
GCDAS = $(subst .cxx,.cover.gcda,$(SRCS))
# flags to use for cppcheck:
CPPCHECKFLAGS = --enable=all --inconclusive --std=posix
.PHONY: all doc test coverage check clean
# use number of threads specified also in this make file - faster when compiling the object-files.
all:
$(MAKE) -j$(THREADS) $(OBJS)
$(MAKE) $(TARGET)
# runs the test specified in the exercise requirement.
test:
$(MAKE) -j$(THREADS) $(OBJS)
$(MAKE) $(TARGET)
./$(TARGET) $(HOME)/SP/$(FILE)
# if threads is not defined, then compile without passing the threads number as a compiler option.
ifndef THREADS
$(TARGET): $(OBJS) src/$(TARGET).cxx
$(CXX) $(CXXFLAGS) $(OBJS) src/$(TARGET).cxx -o $(TARGET) $(LIBS)
else
# else compile it with the custom option that THREADS = number of threads specified.
$(TARGET): $(OBJS) src/$(TARGET).cxx
$(CXX) -DTHREADS=$(THREADS) $(CXXFLAGS) $(OBJS) src/$(TARGET).cxx -o $(TARGET) $(LIBS)
endif
# compile the objects but do not link them.
$(OBJS): src/%.o:src/%.cxx
$(CXX) $(CXXFLAGS) -c $< -o $@
# compile the objects for coverage test without linking them...
$(COVERAGEOBJS): src/%.cover:src/%.cxx
$(CXX) $(CXXFLAGS) --coverage -c $< -o $@
doc:
doxygen -g
doxygen Doxyfile
sed -i 's/PROJECT_NAME.*=.*/$/PROJECT_NAME = "Exercise 10"/' Doxyfile
sed -i 's/EXTRACT_ALL.*=.*/$/EXTRACT_ALL = YES/' Doxyfile
sed -i 's/EXTRACT_PRIVATE.*=.*/$/EXTRACT_PRIVATE = YES/' Doxyfile
sed -i 's/BUILTIN_STL_SUPPORT.*=.*/$/BUILTIN_STL_SUPPORT = YES/' Doxyfile
# if more than one doxygen-readable file is present in directory:
(cat Doxyfile; echo "INPUT = src/") | doxygen -
# otherwise:
# doxygen Doxyfile
# coverage test
coverage:
$(MAKE) -j4 $(COVERAGEOBJS)
$(CXX) $(CXXFLAGS) --coverage $(COVERAGEOBJS) src/$(TARGET).cxx -o $(TARGET) $(LIBS)
mkdir -p gcov
./$(TARGET) $(HOME)/SP/$(FILE) 1 --help
./$(TARGET) $(HOME)/SP/$(FILE) 10 -s
./$(TARGET) $(HOME)/SP/b15.gph
mv $(TARGET).gcno $(TARGET).gcda gcov
lcov -t "result" -o result.info -c -d gcov
genhtml -o result result.info
# static checker
check:
# if cppcheck binary is in the same folder as source file:
# ./cppcheck $(CPPCHECKFLAGS) $(TARGET).cxx
# otherwise, if cppcheck is an installed library:
cppcheck $(CPPCHECKFLAGS) src/$(TARGET).cxx
cleancoverage:
rm -f $(GCNOS) $(GCDAS) $(COVERAGEOBJS) result.info
clean:
rm -f $(OBJS) $(GCNOS) $(GCDAS) $(COVERAGEOBJS) result.info