-
Notifications
You must be signed in to change notification settings - Fork 2
/
makefile
80 lines (62 loc) · 1.74 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
#!/usr/bin/env make
BIN = einsim
BIN_DBG = $(BIN).d
BIN_LIB = lib$(BIN).so
BUILD_DIR = build
DOXY_DIR = doxygen
SRC_DIR = src
SOURCES := $(wildcard $(SRC_DIR)/*.cpp $(SRC_DIR)/*/*.cpp)
SUBDIRS := $(sort $(dir ${SOURCES}))
OBJS = $(SOURCES:%=$(BUILD_DIR)/%.o)
OBJS_DBG = $(SOURCES:%=$(BUILD_DIR)/%.do)
OBJS_SO = $(SOURCES:%=$(BUILD_DIR)/%.so)
DEPS = $(OBJS:%=%.d)
DEPS_DBG = $(OBJS_DBG:%=%.d)
DEPS_SO = $(OBJS_SO:%=%.d)
CC = g++
LD = g++
INCLUDE_DIRS = $(SRC_DIR) lib lib/eigen_3.3.7 lib/libtp lib/cxxopts lib/rapidjson
CFLAGS_OPT = -g -Wfatal-errors -Werror -Wall -O3 $(INCLUDE_DIRS:%=-I%) -std=c++11 -pthread
CFLAGS_DBG = -ggdb -Wfatal-errors -Werror -Wall -O0 $(INCLUDE_DIRS:%=-I%) -std=c++11 -pthread
CFLAGS_LIB = $(CFLAGS_OPT) -fPIC -DDYNAMIC_LIB
LDFLAGS = -pthread
LDFLAGS_DBG = -pthread
LDFLAGS_LIB = -shared
# $(info SOURCES : $(SOURCES))
# $(info OBJS : $(OBJS))
# $(info DEPS : $(DEPS))
# $(info SOURCES : $(SOURCES))
.SUFFIXES:
.PHONY: default jall all release debug clean doc lib
default: release
release: $(BIN)
doc:
doxygen
debug: $(BIN_DBG)
lib: $(BIN_LIB)
all: release debug lib
jall:
$(MAKE) -j 8 all
-include $(DEPS)
-include $(DEPS_DBG)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
mkdir -p $(SUBDIRS:%=$(BUILD_DIR)/%)
$(BUILD_DIR)/%.cpp.o: %.cpp | $(BUILD_DIR)
$(CC) $(CFLAGS_OPT) -c -MMD -MF [email protected] -o $@ $<
$(BUILD_DIR)/%.cpp.do: %.cpp | $(BUILD_DIR)
$(CC) $(CFLAGS_DBG) -c -MMD -MF [email protected] -o $@ $<
$(BUILD_DIR)/%.cpp.so: %.cpp | $(BUILD_DIR)
$(CC) $(CFLAGS_LIB) -c -MMD -MF [email protected] -o $@ $<
$(BIN): $(OBJS)
$(LD) $(LDFLAGS) $^ -o $@
$(BIN_DBG): $(OBJS_DBG)
$(LD) $(LDFLAGS_DBG) $^ -o $@
$(BIN_LIB): $(OBJS_SO)
$(LD) $(LDFLAGS_LIB) $^ -o $@
clean:
rm -f $(BIN)
rm -f $(BIN_DBG)
rm -f $(BIN_LIB)
rm -rf $(BUILD_DIR)
rm -rf $(DOXY_DIR)