-
Notifications
You must be signed in to change notification settings - Fork 6
/
makefile-static
60 lines (44 loc) · 1.57 KB
/
makefile-static
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
# Declaration of variables
CC = g++
CC_FLAGS = -std=c++17 -Wall -O3 -I ./algorithm -I ./pugixml -I ./report -I ./common -I ./graph -I ./lib -I . -DCGI_MODE
# File names
EXEC = ./bin/Linux/Release/GraphOffline
ALGORITHM_DIR = ./algorithm/
PUGIXML_DIR = ./pugixml/
REPORT_DIR = ./report/
COMMON_DIR = ./common/
GRAPH_DIR = ./graph/
OBJ_DIR = ./bin/Linux/obj/
SOURCES = $(wildcard *.cpp) $(wildcard */*.cpp)
# Create obejcts files in $(OBJ_DIR)
OBJECTS = $(patsubst %.cpp,$(OBJ_DIR)%.o, $(SOURCES))
# Main target
$(EXEC): $(OBJ_DIR)$(GRAPH_DIR) $(OBJ_DIR)$(COMMON_DIR) $(OBJ_DIR)$(REPORT_DIR) $(OBJ_DIR)$(ALGORITHM_DIR) $(OBJ_DIR)$(PUGIXML_DIR) $(OBJECTS)
$(CC) $(OBJECTS) -lpthread -lm /usr/lib/gcc/x86_64-linux-gnu/7.5.0/libstdc++.a -o $(EXEC)
# To obtain object files
$(OBJ_DIR)$(ALGORITHM_DIR)%.o: $(ALGORITHM_DIR)%.cpp
$(CC) -c $(CC_FLAGS) $< -o $@
$(OBJ_DIR)$(PUGIXML_DIR)%.o: $(PUGIXML_DIR)%.cpp
$(CC) -c $(CC_FLAGS) $< -o $@
$(OBJ_DIR)$(REPORT_DIR)%.o: $(REPORT_DIR)%.cpp
$(CC) -c $(CC_FLAGS) $< -o $@
$(OBJ_DIR)$(COMMON_DIR)%.o: $(REPORT_DIR)%.cpp
$(CC) -c $(CC_FLAGS) $< -o $@
$(OBJ_DIR)$(GRAPH_DIR)%.o: $(REPORT_DIR)%.cpp
$(CC) -c $(CC_FLAGS) $< -o $@
$(OBJ_DIR)%.o: %.cpp
$(CC) -c $(CC_FLAGS) $< -o $@
# make dirs
$(OBJ_DIR)$(ALGORITHM_DIR):
mkdir -p $(OBJ_DIR)$(ALGORITHM_DIR)
$(OBJ_DIR)$(PUGIXML_DIR):
mkdir -p $(OBJ_DIR)$(PUGIXML_DIR)
$(OBJ_DIR)$(REPORT_DIR):
mkdir -p $(OBJ_DIR)$(REPORT_DIR)
$(OBJ_DIR)$(COMMON_DIR):
mkdir -p $(OBJ_DIR)$(COMMON_DIR)
$(OBJ_DIR)$(GRAPH_DIR):
mkdir -p $(OBJ_DIR)$(GRAPH_DIR)
# To remove generated files
clean:
rm -f $(EXEC) $(OBJECTS)