forked from Viraj3f/QFace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
170 lines (134 loc) · 4.54 KB
/
Makefile
File metadata and controls
170 lines (134 loc) · 4.54 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
include Makefile.variable
# ----- Build Settings, you shouldn't really need to touch these ------
PROJECT = Turbo
# Directories where the source file will be compiled
BIN_DIR = ./bin
OBJ_DIR = $(BIN_DIR)/obj
# Source file directories
SRC_DIR = ./src/cpp
SRC_DIR_MODELS = $(SRC_DIR)/models
SRC_DIR_VIEWS = $(SRC_DIR)/views
SRC_DIR_CONTROLLERS = $(SRC_DIR)/controllers
SRC_DIR_TEST = $(SRC_DIR)/test
LIB_DIR = ./lib
# Compiler Settings
CXX = $(EMSCRIPTEN_HOME)/em++
CXXFLAGS = -Wall \
-Wextra \
-std=c++11 \
-I$(SRC_DIR) \
-O1 \
--bind \
LDFLAGS = \
--preload-file data \
-s NO_EXIT_RUNTIME=1 \
-s ASSERTIONS=2 \
--llvm-lto 1 \
-s DISABLE_EXCEPTION_CATCHING=0 \
-s DEMANGLE_SUPPORT=1 \
-s TOTAL_MEMORY=117440512 # 112MB
# The source file themselves
MAIN = $(SRC_DIR)/main.cpp
SOURCES = $(MAIN)
SOURCES += $(wildcard $(SRC_DIR_MODELS)/*.cpp)
SOURCES += $(wildcard $(SRC_DIR_VIEWS)/*.cpp)
SOURCES += $(wildcard $(SRC_DIR_CONTROLLERS)/*.cpp)
COMPILED_JS = $(BIN_DIR)/$(PROJECT).asm.js
COMPILED_BC = $(BIN_DIR)/$(PROJECT).bc
# Automatic header dependecy management. Not 100% how it works.
DEPS = $(OBJECTS:%.o=%.d)
-include $(DEPS)
TEST_OBJECTS = $(addprefix $(OBJ_DIR)/, $(notdir $(patsubst %.cpp, %.o, $(TEST_SOURCES))))
# The executible file itself
PROJECT = Turbo
COMPILED_JS = $(BIN_DIR)/$(PROJECT).asm.js
COMPILED_BC = $(BIN_DIR)/$(PROJECT).bc
TEST_COMPILED_JS = $(BIN_DIR)/$(PROJECT).test.asm.js
# json
JSON_INCLUDE = $(LIB_DIR)/json
BASE64_INCLUDE = $(LIB_DIR)/base64
INCLUDE = \
-I$(JSON_INCLUDE) \
-I$(BASE64_INCLUDE)
# ----- OpenCV Dependencies -----
OPENCV_DIR = $(LIB_DIR)/opencv_3.1.0
OPENCV_INCLUDE = $(OPENCV_DIR)/modules
OPENCV_LIB = $(OPENCV_DIR)/precompiled
OPENCV_3RD_PARTY = $(OPENCV_DIR)/share/OpenCV/3rdparty/lib
# Libs
INCLUDE += \
-I$(OPENCV_INCLUDE)/core/include \
-I$(OPENCV_INCLUDE)/flann/include \
-I$(OPENCV_INCLUDE)/ml/include \
-I$(OPENCV_INCLUDE)/photo/include \
-I$(OPENCV_INCLUDE)/shape/include \
-I$(OPENCV_INCLUDE)/imgproc/include \
-I$(OPENCV_INCLUDE)/calib3d/include \
-I$(OPENCV_INCLUDE)/features2d/include \
-I$(OPENCV_INCLUDE)/video/include \
-I$(OPENCV_INCLUDE)/objdetect/include \
-I$(OPENCV_INCLUDE)/imgcodecs/include \
-I$(OPENCV_INCLUDE)/hal/include \
-I$(OPENCV_INCLUDE)/face/include \
# Do NOT change the order of these libs. The order matters.
LIBS = \
$(OPENCV_LIB)/libopencv_shape.a \
$(OPENCV_LIB)/libopencv_objdetect.a \
$(OPENCV_LIB)/libopencv_imgcodecs.a \
$(OPENCV_LIB)/libopencv_highgui.a \
$(OPENCV_3RD_PARTY)/liblibpng.a \
$(OPENCV_3RD_PARTY)/liblibjpeg.a \
$(OPENCV_LIB)/libopencv_imgproc.a \
$(OPENCV_LIB)/libopencv_flann.a \
$(OPENCV_LIB)/libopencv_face.a \
$(OPENCV_LIB)/libopencv_core.a \
$(OPENCV_3RD_PARTY)/libzlib.a
# Specify the executible
ifeq ($(MAKECMDGOALS), test)
$(info Building with unit tests.)
COMPILED_BC = $(BIN_DIR)/$(PROJECT).test.bc
COMPILED_JS = $(BIN_DIR)/$(PROJECT).test.js
LDFLAGS += --preload-file test_data
SOURCES += $(wildcard $(SRC_DIR_TEST)/*.cpp)
CXXFLAGS += -D TEST_ENV
endif
ifeq ($(MAKECMDGOALS), release)
$(info Building released WebAssembly)
LDFLAGS += -s WASM=1
CXXFLAGS -= -O1
endif
# Object Directory
OBJECTS = $(addprefix $(OBJ_DIR)/, $(notdir $(patsubst %.cpp, %.o, $(SOURCES))))
# ----- Actual Build targets. Add new ones as needed. ------
test: all
release: clean all
all: $(COMPILED_JS)
$(COMPILED_JS): $(COMPILED_BC)
$(info ---- Compiling bitcode into $(COMPILED_JS) ----)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(COMPILED_BC) -o $(COMPILED_JS)
$(COMPILED_BC): $(OBJECTS)
$(info ---- Linking with 3rd party libs ----)
$(CXX) $(CXXFLAGS) $^ $(LIBS) -o $(COMPILED_BC)
# ---- Compiling C++/Headers in objects. -------
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(info ---- Compiling $^ ----)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c -MMD $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR_MODELS)/%.cpp
$(info ---- Compiling $^ ----)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c -MMD $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR_VIEWS)/%.cpp
$(info ---- Compiling $^ ----)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c -MMD $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR_CONTROLLERS)/%.cpp
$(info ---- Compiling $^ ----)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c -MMD $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR_TEST)/%.cpp
$(info ---- Compiling $^ ----)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c -MMD $< -o $@
# ----- Other useful scripts ------
server:
$(PYTHON3) server.py
clean:
-rm $(BIN_DIR)/$(PROJECT).* $(OBJ_DIR)/*.o $(OBJ_DIR)/*.d $(BIN_DIR)/*.bc
lint:
$(CPPLINT) --filter=-legal/copyright --recursive src/cpp