-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
59 lines (47 loc) · 1.32 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
SHELL=/bin/sh
.SUFFIXES:
.SUFFIXES: .cpp .h .o
CXX=g++
CXXFLAGS=-c -Wall -march=native -std=c++11 -DTERMINALCOLORS
FASTFLAGS=-O3
DEBUGFLAGS=-g
CLUSTERCXXFLAGS=-c -Wall -std=c++11 -O3
#LDFLAGS=-pthread
LDFLAGS=
SRC_DIR=tool target
BUILD_DIR=build
SOURCES=$(foreach srcdir,$(SRC_DIR),$(wildcard $(srcdir)/*.cpp))
#OBJECTS=$(addprefix build/,${SOURCES:.cpp=.o})
OBJECTS=$(foreach srcdir,$(SRC_DIR),$(patsubst $(srcdir)/%.cpp,$(BUILD_DIR)/%.o,$(filter $(srcdir)/%.cpp,$(SOURCES))))
INCLUDES=$(addprefix -I,$(SRC_DIR))
vpath %.cpp $(SRC_DIR)
vpath %.h $(SRC_DIR)
vpath %.hpp $(SRC_DIR)
TITLE=lin
.PHONY : all clean
# make all
all: fast
# make fast
fast: CXXFLAGS += $(FASTFLAGS)
fast: $(TITLE)
# make fastdebug
fastdebug: CXXFLAGS += $(FASTFLAGS) $(DEBUGFLAGS)
fastdebug: $(TITLE)
# make debug
debug: CXXFLAGS += $(DEBUGFLAGS)
debug: $(TITLE)
# make cluster
cluster: CXXFLAGS = $(CLUSTERCXXFLAGS)
cluster: $(TITLE)
# make
$(TITLE): $(OBJECTS) $(BUILD_DIR)/tinyxml2.o
$(CXX) -g -o $@ $^ $(INCLUDES) $(LDFLAGS)
# make %.o
$(BUILD_DIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -o $@ $< -MMD -MF ./[email protected] $(INCLUDES) $(LDFLAGS)
$(BUILD_DIR)/tinyxml2.o: tinyxml2/tinyxml2.cpp
$(CXX) $(CXXFLAGS) -o $@ tinyxml2/tinyxml2.cpp -MMD -MF ./[email protected] $(LDFLAGS)
# make clean
clean:
rm -f $(BUILD_DIR)/*.o $(BUILD_DIR)/*.d $(TITLE)
-include $(wildcard $(BUILD_DIR)/*.d)