-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
109 lines (80 loc) · 2.52 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
98
99
100
101
102
103
104
105
106
107
108
109
ifndef $(BUILD)
BUILD := release
endif
ifndef $(CONFIG)
CONFIG := default
endif
UNAME_S := $(shell uname -s)
CURR_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
BASE_BUILDDIR:=$(CURR_DIR)/build
BUILDDIR=$(BASE_BUILDDIR)/$(BUILD)
SOURCES = $(wildcard $(CURR_DIR)/*.cpp) \
$(wildcard $(CURR_DIR)/traffic/*.cpp) \
$(wildcard $(CURR_DIR)/topology/*.cpp) \
$(wildcard $(CURR_DIR)/utils/*.cpp) \
$(wildcard $(CURR_DIR)/simulation/*.cpp) \
$(wildcard $(CURR_DIR)/devtests/*.cpp)
ANALYSIS_SOURCES = $(wildcard $(CURR_DIR)/data-analysis/*.cpp)
OBJECTS = $(patsubst $(CURR_DIR)/%,$(BUILDDIR)/%,$(SOURCES:.cpp=.o))
DEPENDS = $(patsubst $(CURR_DIR)/%,$(BUILDDIR)/%,$(SOURCES:.cpp=.d))
ANALYSIS_OBJECTS = $(patsubst $(CURR_DIR)/%,$(BUILDDIR)/%,$(ANALYSIS_SOURCES:.cpp=.o))
ANALYSIS_DEPENDS = $(patsubst $(CURR_DIR)/%,$(BUILDDIR)/%,$(ANALYSIS_SOURCES:.cpp=.d))
RELEASE_BINARY := syndb-sim
DEBUG_BINARY := syndb-sim-debug
PROFILE_BINARY := syndb-sim-prof
ANALYSIS_RELEASE_BINARY := syndb-analysis
ANALYSIS_DEBUG_BINARY := syndb-analysis-debug
ANALYSIS_PROFILE_BINARY := syndb-analysis-profile
CXXFLAGS = -I$(CURR_DIR) \
-std=c++11
LDLIBS = -lpthread \
-lfmt \
-lspdlog
ifeq ($(BUILD), release)
CXXFLAGS += -O3
OUTPUT_BINARY := $(RELEASE_BINARY)
ANALYSIS_BINARY := $(ANALYSIS_RELEASE_BINARY)
endif
ifeq ($(BUILD), debug)
CXXFLAGS += -O0 -g3 -DDEBUG
OUTPUT_BINARY := $(DEBUG_BINARY)
ANALYSIS_BINARY := $(ANALYSIS_DEBUG_BINARY)
endif
ifeq ($(CONFIG), default)
CXXFLAGS += -DCONFIG=0
endif
ifeq ($(CONFIG), validation)
CXXFLAGS += -DCONFIG=1
endif
ifeq ($(CONFIG), evaluation)
CXXFLAGS += -DCONFIG=2
endif
ifeq ($(CONFIG), profiling)
CXXFLAGS += -pg -DCONFIG=3
OUTPUT_BINARY := $(PROFILE_BINARY)
ANALYSIS_BINARY := $(ANALYSIS_PROFILE_BINARY)
endif
ifeq ($(CONFIG), test)
CXXFLAGS += -DCONFIG=4
endif
.PHONY: all clean cleaner
all: $(OUTPUT_BINARY)
analysis: $(ANALYSIS_BINARY)
clean:
@$(RM) -rf $(BUILDDIR)
@$(RM) $(OUTPUT_BINARY)
@$(RM) $(ANALYSIS_BINARY)
cleaner:
@$(RM) -rf $(BASE_BUILDDIR)
@$(RM) $(RELEASE_BINARY) $(DEBUG_BINARY) $(PROFILE_BINARY)
@$(RM) $(ANALYSIS_RELEASE_BINARY) $(ANALYSIS_DEBUG_BINARY) $(ANALYSIS_PROFILE_BINARY)
# Linking the executable from the object files
$(OUTPUT_BINARY): $(OBJECTS)
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDLIBS)
$(ANALYSIS_BINARY): $(ANALYSIS_OBJECTS)
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDLIBS)
-include $(DEPENDS)
# -MMD -MP are related to generating the .d depends file
$(BUILDDIR)/%.o: $(CURR_DIR)/%.cpp Makefile
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@