-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
62 lines (45 loc) · 1.17 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
SRC := $(wildcard src/*.cpp)
OBJ := $(SRC:.cpp=.o)
BINSRC := $(wildcard src/bin-*.cpp)
BINOBJ := $(BINSRC:.cpp=.o)
TESTSRC := $(wildcard test/*.cpp)
TESTOBJ := $(TESTSRC:.cpp=.o)
LIBOBJ := $(OBJ)
LIBOBJ := $(filter-out $(BINOBJ),$(LIBOBJ))
LIBOBJ := $(filter-out $(TESTOBJ),$(LIBOBJ))
DEP := $(SRC:.cpp=.P)
HDR := $(wildcard src/*.h)
# C++ compiler flags
CXXFLAGS += --std=c++14
CXXFLAGS += -fPIC
CXXFLAGS += -fopenmp
CXXFLAGS += -Wall
CXXFLAGS += -O3
# Libraries
LIBS += -lboost_program_options
LIBS += -lboost_system
LIBS += -lboost_log
# Includes
INCLUDES += -Iinclude
# Commands
all: $(OBJ) $(BIN)
-include $(DEP)
profile: CXXFLAGS += -g3 -pg
profile: all
debug: CXXFLAGS += -O0 -g3
debug: all
BIN = agdmhs
TEST = agdmhs-test
all: $(OBJ) $(BIN) $(TEST)
agdmhs: $(LIBOBJ) $(BINOBJ)
$(CXX) $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) $^ -o $@ $(LIBS)
agdmhs-test: $(LIBOBJ) $(TESTOBJ)
$(CXX) $(LDFLAGS) $(CXXFLAGS) $^ -o $@ $(LIBS)
%.o: %.cpp
$(CXX) -MD $(CXXFLAGS) $(INCLUDES) -o $@ -c $<
@cp $*.d $*.P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
rm -f $*.d
clean:
-rm -vf $(EXEC) $(OBJ) $(TESTOBJ) $(DEP) $(BIN) $(TEST)