-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmakefile
295 lines (198 loc) · 15.9 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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# Detect if the distro is one that uses external fmt
EXTERNAL_FMT_CHECK := $(shell grep -q 'void' /etc/os-release && echo "true" || echo "false")
# Set extra compiler flags for Arch Linux
ifeq ($(EXTERNAL_FMT_CHECK),true)
FLAGS+= -D SPDLOG_FMT_EXTERNAL
endif
PROTO_DIR = protos
PROTO_FILES = $(wildcard $(PROTO_DIR)/*.proto)
PROTO_CPP_FILES = $(patsubst %.proto, %.pb.cc, $(PROTO_FILES))
PROTO_H_FILES = $(patsubst %.proto, %.pb.h, $(PROTO_FILES))
INCLUDES = -Iinclude -I/usr/local/include -Iinclude/imgui -Itracy/public
# add -p for profiling with gprof
LOADER_FLAGS = -march=native -funroll-loops
SQLITE_SOURCES = $(wildcard src/sqlite/*.cpp)
SQLITE_OBJECTS = $(patsubst src/sqlite/%.cpp, build/%.o, $(SQLITE_SOURCES))
ALL_OBJECTS = build/ControlMappings.o build/Config.o build/systems/Player.o build/MultiPlayer/Server.o build/MultiPlayer/Client.o build/MultiPlayer/Gui.o build/screen.o build/systems/Light.o build/components/Light.o build/systems/Boot.o build/components/Bootable.o build/IndexPool.o build/WindowManager/Space.o build/systems/Move.o build/systems/ApplyTranslation.o build/systems/Derivative.o build/systems/Update.o build/systems/Intersections.o build/systems/Scripts.o build/components/Scriptable.o build/components/Parent.o build/components/RotateMovement.o build/components/Lock.o build/components/Key.o build/systems/KeyAndLock.o build/systems/Door.o build/systems/ApplyRotation.o build/persister.o build/engineGui.o build/entity.o build/renderer.o build/shader.o build/texture.o build/world.o build/camera.o build/api.o build/controls.o build/app.o build/WindowManager/WindowManager.o build/logger.o build/engine.o build/cube.o build/chunk.o build/mesher.o build/loader.o build/utility.o build/blocks.o build/dynamicObject.o build/assets.o build/model.o build/mesh.o build/imgui/imgui.o build/imgui/imgui_draw.o build/imgui/imgui_impl_opengl3.o build/imgui/imgui_widgets.o build/imgui/imgui_demo.o build/imgui/imgui_impl_glfw.o build/imgui/imgui_tables.o build/enkimi.o build/miniz.o src/api.pb.cc src/glad.c src/glad_glx.c $(SQLITE_OBJECTS) tracy/public/TracyClient.cpp
LIBS = -lzmq -lX11 -lXcomposite -lXtst -lXext -lXfixes -lprotobuf -lspdlog -lfmt -Llib $(shell pkg-config --libs glfw3) -lGL -lpthread -lassimp -lsqlite3 $(shell pkg-config --libs protobuf)
all: FLAGS+=-O3 -g
all: tracy include/protos/api.pb.h matrix trampoline build/diagnosis tools/deployTools/bootServer
profiled: FLAGS+=-O3 -g -D TRACY_ENABLE
profiled: matrix
tracy:
git submodule update --init
matrix: $(ALL_OBJECTS) build/main.o
g++ -std=c++20 $(FLAGS) -g -o matrix build/main.o $(ALL_OBJECTS) $(LIBS) -Wl,--as-needed $(INCLUDES)
trampoline: src/trampoline.cpp build/x-raise
g++ -o trampoline src/trampoline.cpp
tools/deployTools/bootServer: build/MultiPlayer/Server.o
mkdir -p tools
mkdir -p deployTools
mkdir -p build/deployTools
g++ -std=c++20 $(FLAGS) -o build/deployTools/bootServer.o -c src/MultiPlayer/bootServer.cpp $(INCLUDES)
g++ -o tools/deployTools/bootServer build/deployTools/bootServer.o build/MultiPlayer/Server.o $(INCLUDES) $(LIBS)
build/enkimi.o: src/enkimi.c
g++ $(FLAGS) $(LOADER_FLAGS) -o build/enkimi.o -c src/enkimi.c $(INCLUDES) -lm -Wno-unused-result
build/miniz.o: src/miniz.c
g++ $(FLAGS) $(LOADER_FLAGS) -o build/miniz.o -c src/miniz.c $(INCLUDES) -lm
build/renderer.o: src/renderer.cpp include/renderer.h include/texture.h include/shader.h include/world.h include/camera.h include/cube.h include/logger.h include/dynamicObject.h include/model.h include/WindowManager/Space.h include/components/Bootable.h include/components/Light.h include/screen.h
g++ -std=c++20 $(FLAGS) -o build/renderer.o -c src/renderer.cpp $(INCLUDES)
build/IndexPool.o: include/IndexPool.h src/IndexPool.cpp
g++ -std=c++20 $(FLAGS) -o build/IndexPool.o -c src/IndexPool.cpp $(INCLUDES)
build/main.o: src/main.cpp include/engine.h include/screen.h
g++ -std=c++20 $(FLAGS) -o build/main.o -c src/main.cpp $(INCLUDES)
build/shader.o: src/shader.cpp include/shader.h
g++ -std=c++20 $(FLAGS) -o build/shader.o -c src/shader.cpp $(INCLUDES)
build/texture.o: src/texture.cpp include/texture.h
g++ -std=c++20 $(FLAGS) -o build/texture.o -c src/texture.cpp $(INCLUDES)
build/world.o: src/world.cpp include/world.h include/app.h include/camera.h include/cube.h include/chunk.h include/loader.h include/utility.h include/dynamicObject.h include/renderer.h include/worldInterface.h include/model.h include/systems/ApplyRotation.h
g++ -std=c++20 -g $(FLAGS) -o build/world.o -c src/world.cpp $(INCLUDES)
build/camera.o: src/camera.cpp include/camera.h
g++ -std=c++20 $(FLAGS) -o build/camera.o -c src/camera.cpp $(INCLUDES)
build/api.o: src/api.cpp include/api.h include/world.h include/logger.h include/protos/api.pb.h
g++ -std=c++20 $(FLAGS) -o build/api.o -c src/api.cpp $(INCLUDES)
build/controls.o: src/controls.cpp include/controls.h include/camera.h include/WindowManager/WindowManager.h include/world.h include/ControlMappings.h
g++ -std=c++20 $(FLAGS) -o build/controls.o -c src/controls.cpp $(INCLUDES)
build/ControlMappings.o: src/ControlMappings.cpp include/ControlMappings.h include/Config.h
g++ -std=c++20 $(FLAGS) -o build/ControlMappings.o -c src/ControlMappings.cpp $(INCLUDES)
build/app.o: src/app.cpp include/app.h include/screen.h
g++ -std=c++20 $(FLAGS) -o build/app.o -c src/app.cpp $(INCLUDES) -Wno-narrowing
build/screen.o: src/screen.cpp include/screen.h
g++ -std=c++20 $(FLAGS) -o build/screen.o -c src/screen.cpp $(INCLUDES) -Wno-narrowing
build/WindowManager/WindowManager.o: src/WindowManager/WindowManager.cpp include/WindowManager/WindowManager.h include/controls.h include/logger.h include/world.h include/WindowManager/Space.h include/systems/Boot.h include/components/Bootable.h include/screen.h include/Config.h
g++ -std=c++20 $(FLAGS) -o build/WindowManager/WindowManager.o -c src/WindowManager/WindowManager.cpp $(INCLUDES)
build/WindowManager/Space.o: src/WindowManager/Space.cpp include/WindowManager/Space.h include/loader.h include/app.h include/camera.h include/renderer.h include/screen.h
g++ -std=c++20 $(FLAGS) -o build/WindowManager/Space.o -c src/WindowManager/Space.cpp $(INCLUDES)
build/logger.o: src/logger.cpp include/logger.h
g++ -std=c++20 $(FLAGS) -o build/logger.o -c src/logger.cpp $(INCLUDES)
build/engine.o: src/engine.cpp include/engine.h include/api.h include/app.h include/camera.h include/controls.h include/renderer.h include/WindowManager/WindowManager.h include/world.h include/blocks.h include/assets.h include/entity.h include/model.h include/systems/Derivative.h include/components/Light.h include/MultiPlayer/Client.h include/MultiPlayer/Server.h
g++ -std=c++20 $(FLAGS) -Wdeprecated-enum-enum-conversion -o build/engine.o -c src/engine.cpp $(INCLUDES)
build/cube.o: src/cube.cpp include/cube.h
g++ -std=c++20 $(FLAGS) -o build/cube.o -c src/cube.cpp $(INCLUDES)
build/chunk.o: src/chunk.cpp include/chunk.h include/mesher.h
g++ -std=c++20 $(FLAGS) -o build/chunk.o -c src/chunk.cpp $(INCLUDES)
build/mesher.o: src/mesher.cpp include/mesher.h
g++ -std=c++20 $(FLAGS) -o build/mesher.o -c src/mesher.cpp $(INCLUDES)
build/loader.o: src/loader.cpp include/loader.h include/utility.h
g++ -std=c++20 $(FLAGS) -o build/loader.o -c src/loader.cpp $(INCLUDES)
build/utility.o: src/utility.cpp include/utility.h
g++ -std=c++20 $(FLAGS) -o build/utility.o -c src/utility.cpp $(INCLUDES)
build/blocks.o: src/blocks.cpp include/blocks.h
g++ -std=c++20 $(FLAGS) -o build/blocks.o -c src/blocks.cpp $(INCLUDES)
build/dynamicObject.o: src/dynamicObject.cpp include/dynamicObject.h
g++ -std=c++20 $(FLAGS) -o build/dynamicObject.o -c src/dynamicObject.cpp $(INCLUDES)
build/assets.o: src/assets.cpp include/assets.h
g++ -std=c++20 $(FLAGS) -o build/assets.o -c src/assets.cpp $(INCLUDES)
build/model.o: src/model.cpp include/model.h include/mesh.h
g++ -std=c++20 $(FLAGS) -o build/model.o -c src/model.cpp $(INCLUDES)
build/mesh.o: src/mesh.cpp include/mesh.h
g++ -std=c++20 $(FLAGS) -o build/mesh.o -c src/mesh.cpp $(INCLUDES)
build/entity.o: src/entity.cpp include/entity.h include/Config.h
g++ -std=c++20 $(FLAGS) -o build/entity.o -c src/entity.cpp $(INCLUDES)
build/engineGui.o: src/engineGui.cpp include/engineGui.h include/components/RotateMovement.h include/model.h include/systems/Update.h include/components/Bootable.h include/components/Light.h include/engine.h
g++ -std=c++20 $(FLAGS) -o build/engineGui.o -c src/engineGui.cpp $(INCLUDES)
build/persister.o: src/persister.cpp include/persister.h
g++ -std=c++20 $(FLAGS) -o build/persister.o -c src/persister.cpp $(INCLUDES)
build/systems/ApplyRotation.o: src/systems/ApplyRotation.cpp include/systems/ApplyRotation.h include/components/RotateMovement.h include/model.h
g++ -std=c++20 $(FLAGS) -o build/systems/ApplyRotation.o -c src/systems/ApplyRotation.cpp $(INCLUDES)
build/systems/ApplyTranslation.o: src/systems/ApplyTranslation.cpp include/systems/ApplyTranslation.h include/components/TranslateMovement.h include/model.h
g++ -std=c++20 $(FLAGS) -o build/systems/ApplyTranslation.o -c src/systems/ApplyTranslation.cpp $(INCLUDES)
build/systems/Move.o: src/systems/Move.cpp include/systems/Move.h include/components/TranslateMovement.h
g++ -std=c++20 $(FLAGS) -o build/systems/Move.o -c src/systems/Move.cpp $(INCLUDES)
build/systems/Door.o: src/systems/Door.cpp include/systems/Door.h include/components/Door.h include/entity.h
g++ -std=c++20 $(FLAGS) -o build/systems/Door.o -c src/systems/Door.cpp $(INCLUDES)
build/systems/KeyAndLock.o: src/systems/KeyAndLock.cpp include/systems/KeyAndLock.h include/components/Key.h include/components/Lock.h
g++ -std=c++20 $(FLAGS) -o build/systems/KeyAndLock.o -c src/systems/KeyAndLock.cpp $(INCLUDES)
build/systems/Boot.o: src/systems/Boot.cpp include/systems/Boot.h include/components/Bootable.h include/entity.h
g++ -std=c++20 $(FLAGS) -o build/systems/Boot.o -c src/systems/Boot.cpp $(INCLUDES)
build/systems/Light.o: src/systems/Light.cpp include/systems/Light.h include/components/Light.h include/entity.h include/renderer.h include/model.h
g++ -std=c++20 $(FLAGS) -o build/systems/Light.o -c src/systems/Light.cpp $(INCLUDES)
build/components/Key.o: src/components/Key.cpp include/components/Key.h include/SQLPersisterImpl.h include/components/RotateMovement.h
g++ -std=c++20 $(FLAGS) -o build/components/Key.o -c src/components/Key.cpp $(INCLUDES)
build/components/Lock.o: src/components/Lock.cpp include/components/Lock.h include/SQLPersisterImpl.h
g++ -std=c++20 $(FLAGS) -o build/components/Lock.o -c src/components/Lock.cpp $(INCLUDES)
build/components/RotateMovement.o: src/components/RotateMovement.cpp include/components/RotateMovement.h
g++ -std=c++20 $(FLAGS) -o build/components/RotateMovement.o -c src/components/RotateMovement.cpp $(INCLUDES)
build/components/Parent.o: src/components/Parent.cpp include/components/Parent.h
g++ -std=c++20 $(FLAGS) -o build/components/Parent.o -c src/components/Parent.cpp $(INCLUDES)
build/components/Scriptable.o: src/components/Scriptable.cpp include/components/Scriptable.h
g++ -std=c++20 $(FLAGS) -o build/components/Scriptable.o -c src/components/Scriptable.cpp $(INCLUDES)
build/components/Bootable.o: src/components/Bootable.cpp include/components/Bootable.h include/SQLPersisterImpl.h include/screen.h
g++ -std=c++20 $(FLAGS) -o build/components/Bootable.o -c src/components/Bootable.cpp $(INCLUDES)
build/components/Light.o: src/components/Light.cpp include/components/Light.h
g++ -std=c++20 $(FLAGS) -o build/components/Light.o -c src/components/Light.cpp $(INCLUDES)
build/systems/Scripts.o: src/systems/Scripts.cpp include/systems/Scripts.h include/components/Scriptable.h include/entity.h
g++ -std=c++20 $(FLAGS) -o build/systems/Scripts.o -c src/systems/Scripts.cpp $(INCLUDES)
build/systems/Intersections.o: src/systems/Intersections.cpp include/systems/Intersections.h include/components/BoundingSphere.h include/entity.h include/model.h
g++ -std=c++20 $(FLAGS) -o build/systems/Intersections.o -c src/systems/Intersections.cpp $(INCLUDES)
build/systems/Update.o: src/systems/Update.cpp include/systems/Update.h include/entity.h
g++ -std=c++20 $(FLAGS) -o build/systems/Update.o -c src/systems/Update.cpp $(INCLUDES)
build/systems/Derivative.o: src/systems/Derivative.cpp include/systems/Intersections.h include/entity.h include/model.h include/components/Scriptable.h
g++ -std=c++20 $(FLAGS) -o build/systems/Derivative.o -c src/systems/Derivative.cpp $(INCLUDES)
build/systems/Player.o: src/systems/Player.cpp include/systems/Player.h include/entity.h include/model.h
g++ -std=c++20 $(FLAGS) -o build/systems/Player.o -c src/systems/Player.cpp $(INCLUDES)
build/MultiPlayer/Gui.o: src/MultiPlayer/Gui.cpp include/MultiPlayer/Gui.h include/engine.h
g++ -std=c++20 $(FLAGS) -o build/MultiPlayer/Gui.o -c src/MultiPlayer/Gui.cpp $(INCLUDES)
build/MultiPlayer/Client.o: src/MultiPlayer/Client.cpp include/MultiPlayer/Client.h
g++ -std=c++20 $(FLAGS) -o build/MultiPlayer/Client.o -c src/MultiPlayer/Client.cpp $(INCLUDES)
build/MultiPlayer/Server.o: src/MultiPlayer/Server.cpp include/MultiPlayer/Server.h include/systems/Player.h include/entity.h
g++ -std=c++20 $(FLAGS) -o build/MultiPlayer/Server.o -c src/MultiPlayer/Server.cpp $(INCLUDES)
build/Config.o: src/Config.cpp include/Config.h
g++ -std=c++20 $(FLAGS) -o build/Config.o -c src/Config.cpp $(INCLUDES)
# SQLite build logic
build/%.o: src/sqlite/%.cpp
g++ -std=c++20 $(FLAGS) -c $< -o $@ $(INCLUDES)
include/protos/api.pb.h src/api.pb.cc: $(PROTO_FILES)
protoc --cpp_out=./ protos/api.proto
protoc --python_out=client_libs/python/hackMatrix/ protos/api.proto
mv protos/api.pb.cc src
mv protos/api.pb.h include/protos
build/x-raise: src/x-raise.c
gcc -o build/x-raise src/x-raise.c -lX11
build/diagnosis: src/diagnosis.cpp
g++ -o build/diagnosis src/diagnosis.cpp
install:
install -d $(DESTDIR)bin
install -m 755 matrix $(DESTDIR)bin
docs: game-design.md
pandoc -s game-design.md -o index.html
python -m http.server
#######################
######## Tests ########
#######################
BUILD_OBJECTS_FOR_TEST = build/api.o build/dynamicObject.o build/logger.o src/api.pb.cc build/chunk.o build/mesher.o build/cube.o build/api.o build/WindowManager/WindowManager.o build/WindowManager/Space.o
TEST_OBJECTS = build/testChunk.o
test: FLAGS+=-O0
test: $(TEST_OBJECTS) $(ALL_OBJECTS)
g++ -std=c++20 $(FLAGS) -o test $(TEST_OBJECTS) $(ALL_OBJECTS) -fuse-ld=gold -I /usr/src/gtest $(INCLUDES) -L /usr/local/lib $(LIBS) -lgtest -lgtest_main -pthread $(EXTRA_LDFLAGS)
build/testDynamicObject.o: build/dynamicObject.o tests/dynamicObject.cpp include/dynamicObject.h
g++ -std=c++20 $(FLAGS) -o build/testDynamicObject.o -c tests/dynamicObject.cpp $(INCLUDES)
#build/testApi.o: build/api.o tests/api.cpp include/api.h
# g++ -std=c++20 $(FLAGS) -o build/testApi.o -c tests/api.cpp $(INCLUDES)
build/testChunk.o: build/chunk.o tests/chunk.cpp include/chunk.h include/mesher.h include/cube.h
g++ -std=c++20 $(FLAGS) -o build/testChunk.o -c tests/chunk.cpp $(INCLUDES)
#######################
######## Imgui ########
#######################
# Source files
IMGUI_SRC = src/imgui/imgui.cpp src/imgui/imgui_draw.cpp src/imgui/imgui_tables.cpp src/imgui/imgui_widgets.cpp src/imgui/imgui_impl_opengl3.cpp src/imgui/imgui_impl_glfw.cpp src/imgui/imgui_demo.cpp
# Object files directory
IMGUI_OBJ_DIR = build/imgui
# Object files list based on source files
IMGUI_OBJ = $(patsubst src/imgui/%.cpp,$(IMGUI_OBJ_DIR)/%.o,$(IMGUI_SRC))
$(IMGUI_OBJ_DIR)/%.o: src/imgui/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@ -I include/imgui
# Rule to compile all ImGui object files
imgui_objects: $(IMGUI_OBJ)
#######################
######## Utils ########
#######################
cloc:
cloc include/ src/ py/ client_libs/js client_libs/python/hackMatrix/api.py levels/ --exclude-dir=imgui,glad,glm,octree,protos,stb,zmq,scns,__pychache__,node_modules --not-match-f=\.json > line-count
sed -i '/github.com\/AlDanial\/cloc/d' line-count
clean:
find build -name "*.o" -type f -delete
format:
clang-format -i src/*.cpp include/*.h
clang-format -i src/systems/*.cpp include/systems/*.h
clang-format -i src/MultiPlayer/*.cpp include/MultiPlayer/*.h