-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Makefile
538 lines (440 loc) · 12.4 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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
#------------------------------------------------------------------------------
# Build: devel, release
BUILD := $(shell cat neverball-build.txt 2> /dev/null || echo release)
VERSION := $(shell sh scripts/version.sh)
$(info Will make a "$(BUILD)" build of Neverball $(VERSION).)
#------------------------------------------------------------------------------
# Provide a target system hint for the Makefile.
# Recognized PLATFORM values: darwin, mingw, haiku.
ifeq ($(shell uname), Darwin)
PLATFORM := darwin
endif
ifeq ($(shell uname -o 2> /dev/null),Msys)
PLATFORM := mingw
endif
ifeq ($(shell uname), Haiku)
PLATFORM := haiku
endif
#------------------------------------------------------------------------------
# Paths (packagers might want to set DATADIR and LOCALEDIR)
USERDIR := .neverball
DATADIR := ./data
LOCALEDIR := ./locale
ifeq ($(PLATFORM),mingw)
USERDIR := Neverball
endif
ifeq ($(PLATFORM),haiku)
USERDIR := /config/settings/neverball
endif
ifneq ($(BUILD),release)
USERDIR := $(USERDIR)-dev
endif
#------------------------------------------------------------------------------
# Optional flags (CFLAGS, CPPFLAGS, ...)
ifeq ($(DEBUG),1)
CFLAGS := -g
CXXFLAGS := -g
CPPFLAGS :=
else
CFLAGS := -O2
CXXFLAGS := -O2
CPPFLAGS := -DNDEBUG
endif
#------------------------------------------------------------------------------
# Mandatory flags
# Compiler...
ifeq ($(ENABLE_TILT),wii)
# -std=c99 because we need isnormal and -fms-extensions because
# libwiimote headers make heavy use of the "unnamed fields" GCC
# extension.
ALL_CFLAGS := -Wall -Wshadow -std=c99 -pedantic -fms-extensions $(CFLAGS)
else
ALL_CFLAGS := -Wall -Wshadow -std=c99 -pedantic $(CFLAGS)
endif
ALL_CXXFLAGS := -fno-rtti -fno-exceptions $(CXXFLAGS)
# Preprocessor...
SDL_CPPFLAGS := $(shell sdl2-config --cflags)
PNG_CPPFLAGS := $(shell libpng-config --cflags)
ALL_CPPFLAGS := $(SDL_CPPFLAGS) $(PNG_CPPFLAGS) -Ishare
ALL_CPPFLAGS += \
-DCONFIG_USER=\"$(USERDIR)\" \
-DCONFIG_DATA=\"$(DATADIR)\" \
-DCONFIG_LOCALE=\"$(LOCALEDIR)\"
ifeq ($(ENABLE_OPENGLES),1)
ALL_CPPFLAGS += -DENABLE_OPENGLES=1
endif
ifeq ($(ENABLE_NLS),0)
ALL_CPPFLAGS += -DENABLE_NLS=0
else
ALL_CPPFLAGS += -DENABLE_NLS=1
endif
ifeq ($(ENABLE_HMD),openhmd)
ALL_CPPFLAGS += -DENABLE_HMD=1
endif
ifeq ($(ENABLE_HMD),libovr)
ALL_CPPFLAGS += -DENABLE_HMD=1
endif
ifeq ($(ENABLE_RADIANT_CONSOLE),1)
ALL_CPPFLAGS += -DENABLE_RADIANT_CONSOLE=1
endif
ifneq ($(BUILD),release)
ALL_CPPFLAGS += -DENABLE_VERSION=1
endif
# Enable libcurl by default, disable w/ ENABLE_FETCH=0.
ENABLE_FETCH := curl
ifeq ($(ENABLE_FETCH),curl)
ALL_CPPFLAGS += $(shell curl-config --cflags) -DENABLE_FETCH=1
else
ALL_CPPFLAGS += -DENABLE_FETCH=0
endif
ifeq ($(PLATFORM),darwin)
ALL_CFLAGS += -Wno-newline-eof
ALL_CPPFLAGS += \
-DGL_SILENCE_DEPRECATION=1 \
$(patsubst %, -I%, $(wildcard /opt/local/include \
/usr/local/include \
/opt/homebrew/include))
endif
ALL_CPPFLAGS += $(CPPFLAGS)
#------------------------------------------------------------------------------
# HMD handling is a complicated with 6 platform-backend combinations.
ifeq ($(ENABLE_HMD),openhmd)
HMD_LIBS := -lopenhmd
endif
ifeq ($(ENABLE_HMD),libovr)
HMD_LIBS := -L/usr/local/OculusSDK/LibOVR/Lib/Linux/Release/x86_64 -lovr -ludev -lX11 -lXinerama
HMD_CPPFLAGS := -I/usr/local/OculusSDK/LibOVR/Include
ifeq ($(PLATFORM),mingw)
HMD_LIBS := -L/usr/local/OculusSDK/LibOVR/Lib/MinGW/Release/w32 -lovr -lsetupapi -lwinmm
HMD_CPPFLAGS := -I/usr/local/OculusSDK/LibOVR/Include
endif
ifeq ($(PLATFORM),darwin)
HMD_LIBS := -L/usr/local/OculusSDK/LibOVR/Lib/MacOS/Release -lovr -framework IOKit -framework CoreFoundation -framework ApplicationServices
HMD_CPPFLAGS := -I/usr/local/OculusSDK/LibOVR/Include
endif
endif
ALL_CPPFLAGS += $(HMD_CPPFLAGS)
#------------------------------------------------------------------------------
# Libraries
SDL_LIBS := $(shell sdl2-config --libs)
PNG_LIBS := $(shell libpng-config --libs)
ENABLE_FS := stdio
ifeq ($(ENABLE_FS),stdio)
FS_LIBS :=
endif
# The non-conditionalised values below are specific to the native
# system. The native system of this Makefile is Linux (or GNU+Linux if
# you prefer). Please be sure to override ALL of them for each target
# system in the conditional parts below.
INTL_LIBS :=
ifeq ($(ENABLE_TILT),wii)
TILT_LIBS := -lcwiimote -lbluetooth
else
ifeq ($(ENABLE_TILT),wiiuse)
TILT_LIBS := -lwiiuse -lbluetooth
else
ifeq ($(ENABLE_TILT),loop)
TILT_LIBS := -lusb-1.0 -lfreespace
else
ifeq ($(ENABLE_TILT),leapmotion)
TILT_LIBS := /usr/lib/Leap/libLeap.so -Wl,-rpath,/usr/lib/Leap
endif
endif
endif
endif
ifeq ($(ENABLE_OPENGLES),1)
OGL_LIBS := -lGLESv1_CM
else
OGL_LIBS := -lGL
endif
ifeq ($(PLATFORM),mingw)
ifneq ($(ENABLE_NLS),0)
INTL_LIBS := -lintl
endif
OGL_LIBS := -lopengl32
endif
ifeq ($(PLATFORM),darwin)
ifneq ($(ENABLE_NLS),0)
INTL_LIBS := -lintl
endif
OGL_LIBS := -framework OpenGL
endif
ifeq ($(PLATFORM),haiku)
ifneq ($(ENABLE_NLS),0)
INTL_LIBS := -lintl
endif
endif
BASE_LIBS := -ljpeg $(PNG_LIBS) $(FS_LIBS) -lm
ifeq ($(PLATFORM),darwin)
BASE_LIBS += $(patsubst %, -L%, $(wildcard /opt/local/lib \
/usr/local/lib \
/opt/homebrew/lib))
endif
OGG_LIBS := -lvorbisfile
TTF_LIBS := -lSDL2_ttf
ifeq ($(PLATFORM),haiku)
TTF_LIBS := -lSDL2_ttf -lfreetype
endif
ifeq ($(ENABLE_FETCH),curl)
CURL_LIBS := $(shell curl-config --libs)
endif
ALL_LIBS := $(HMD_LIBS) $(TILT_LIBS) $(INTL_LIBS) $(TTF_LIBS) \
$(CURL_LIBS) $(OGG_LIBS) $(SDL_LIBS) $(OGL_LIBS) $(BASE_LIBS)
MAPC_LIBS := $(BASE_LIBS)
ifeq ($(ENABLE_RADIANT_CONSOLE),1)
MAPC_LIBS += -lSDL2_net
endif
#------------------------------------------------------------------------------
ifeq ($(PLATFORM),mingw)
X := .exe
endif
MAPC_TARG := mapc$(X)
BALL_TARG := neverball$(X)
PUTT_TARG := neverputt$(X)
ifeq ($(PLATFORM),mingw)
MAPC := $(WINE) ./$(MAPC_TARG)
else
MAPC := ./$(MAPC_TARG)
endif
#------------------------------------------------------------------------------
MAPC_OBJS := \
share/vec3.o \
share/base_image.o \
share/solid_base.o \
share/binary.o \
share/log.o \
share/base_config.o \
share/common.o \
share/fs_common.o \
share/fs_png.o \
share/fs_jpg.o \
share/dir.o \
share/array.o \
share/list.o \
share/mapc.o
BALL_OBJS := \
share/lang.o \
share/st_common.o \
share/vec3.o \
share/base_image.o \
share/image.o \
share/solid_base.o \
share/solid_vary.o \
share/solid_draw.o \
share/solid_all.o \
share/mtrl.o \
share/part.o \
share/geom.o \
share/ball.o \
share/ease.o \
share/transition.o \
share/gui.o \
share/font.o \
share/theme.o \
share/base_config.o \
share/config.o \
share/video.o \
share/glext.o \
share/binary.o \
share/state.o \
share/audio.o \
share/text.o \
share/common.o \
share/list.o \
share/queue.o \
share/cmd.o \
share/array.o \
share/dir.o \
share/fbo.o \
share/glsl.o \
share/fs_common.o \
share/fs_png.o \
share/fs_jpg.o \
share/fs_ov.o \
share/log.o \
share/joy.o \
share/package.o \
share/st_package.o \
ball/hud.o \
ball/game_common.o \
ball/game_client.o \
ball/game_server.o \
ball/game_proxy.o \
ball/game_draw.o \
ball/score.o \
ball/level.o \
ball/progress.o \
ball/set.o \
ball/demo.o \
ball/demo_dir.o \
ball/util.o \
ball/st_conf.o \
ball/st_demo.o \
ball/st_save.o \
ball/st_goal.o \
ball/st_fail.o \
ball/st_done.o \
ball/st_level.o \
ball/st_over.o \
ball/st_play.o \
ball/st_set.o \
ball/st_start.o \
ball/st_title.o \
ball/st_help.o \
ball/st_name.o \
ball/st_shared.o \
ball/st_pause.o \
ball/st_ball.o \
ball/main.o
PUTT_OBJS := \
share/lang.o \
share/st_common.o \
share/vec3.o \
share/base_image.o \
share/image.o \
share/solid_base.o \
share/solid_vary.o \
share/solid_draw.o \
share/solid_all.o \
share/mtrl.o \
share/part.o \
share/geom.o \
share/ball.o \
share/base_config.o \
share/config.o \
share/video.o \
share/glext.o \
share/binary.o \
share/audio.o \
share/state.o \
share/ease.o \
share/transition.o \
share/gui.o \
share/font.o \
share/theme.o \
share/text.o \
share/common.o \
share/list.o \
share/fs_common.o \
share/fs_png.o \
share/fs_jpg.o \
share/fs_ov.o \
share/dir.o \
share/fbo.o \
share/glsl.o \
share/array.o \
share/log.o \
share/joy.o \
putt/hud.o \
putt/game.o \
putt/hole.o \
putt/course.o \
putt/st_all.o \
putt/st_conf.o \
putt/main.o
BALL_OBJS += share/solid_sim_sol.o
PUTT_OBJS += share/solid_sim_sol.o
ifeq ($(ENABLE_FS),stdio)
BALL_OBJS += share/fs_stdio.o share/zip.o
PUTT_OBJS += share/fs_stdio.o share/zip.o
MAPC_OBJS += share/fs_stdio.o share/zip.o
endif
ifeq ($(ENABLE_TILT),wii)
BALL_OBJS += share/tilt_wii.o
else
ifeq ($(ENABLE_TILT),wiiuse)
BALL_OBJS += share/tilt_wiiuse.o
else
ifeq ($(ENABLE_TILT),loop)
BALL_OBJS += share/tilt_loop.o
else
ifeq ($(ENABLE_TILT),leapmotion)
BALL_OBJS += share/tilt_leapmotion.o
else
BALL_OBJS += share/tilt_null.o
endif
endif
endif
endif
ifeq ($(ENABLE_HMD),openhmd)
BALL_OBJS += share/hmd_openhmd.o share/hmd_common.o
PUTT_OBJS += share/hmd_openhmd.o share/hmd_common.o
else
ifeq ($(ENABLE_HMD),libovr)
BALL_OBJS += share/hmd_libovr.o share/hmd_common.o
PUTT_OBJS += share/hmd_libovr.o share/hmd_common.o
else
BALL_OBJS += share/hmd_null.o
PUTT_OBJS += share/hmd_null.o
endif
endif
ifeq ($(PLATFORM),mingw)
BALL_OBJS += neverball.ico.o
PUTT_OBJS += neverputt.ico.o
endif
FETCH_OBJS := share/fetch_null.o
ifeq ($(ENABLE_FETCH),curl)
FETCH_OBJS := share/fetch_curl.o
endif
BALL_OBJS += $(FETCH_OBJS)
BALL_DEPS := $(BALL_OBJS:.o=.d)
PUTT_DEPS := $(PUTT_OBJS:.o=.d)
MAPC_DEPS := $(MAPC_OBJS:.o=.d)
MAPS := $(shell find data -name "*.map" \! -name "*.autosave.map")
SOLS := $(MAPS:%.map=%.sol)
DESKTOPS := $(basename $(wildcard dist/*.desktop.in))
# The build environment defines this (or should).
# This is a fallback that likely only works on a Windows host.
WINDRES ?= windres
#------------------------------------------------------------------------------
%.o : %.c
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -MM -MP -MF $*.d -MT "$@" $<
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -o $@ -c $<
%.o : %.cpp
$(CXX) $(ALL_CXXFLAGS) $(ALL_CPPFLAGS) -MM -MP -MF $*.d -MT "$@" $<
$(CXX) $(ALL_CXXFLAGS) $(ALL_CPPFLAGS) -o $@ -c $<
%.sol : %.map $(MAPC_TARG)
$(MAPC) $< data
%.desktop : %.desktop.in
sh scripts/translate-desktop.sh < $< > $@
%.ico.o: dist/ico/%.ico
echo "1 ICON \"$<\"" | $(WINDRES) -o $@
#------------------------------------------------------------------------------
all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales desktops
ifeq ($(ENABLE_HMD),libovr)
LINK := $(CXX) $(ALL_CXXFLAGS)
else
ifeq ($(ENABLE_TILT),leapmotion)
LINK := $(CXX) $(ALL_CXXFLAGS)
else
LINK := $(CC) $(ALL_CFLAGS)
endif
endif
$(BALL_TARG) : $(BALL_OBJS)
$(LINK) -o $(BALL_TARG) $(BALL_OBJS) $(LDFLAGS) $(ALL_LIBS)
$(PUTT_TARG) : $(PUTT_OBJS)
$(LINK) -o $(PUTT_TARG) $(PUTT_OBJS) $(LDFLAGS) $(ALL_LIBS)
$(MAPC_TARG) : $(MAPC_OBJS)
$(CC) $(ALL_CFLAGS) -o $(MAPC_TARG) $(MAPC_OBJS) $(LDFLAGS) $(MAPC_LIBS)
# Work around some extremely helpful sdl-config scripts.
ifeq ($(PLATFORM),mingw)
$(MAPC_TARG) : ALL_CPPFLAGS := $(ALL_CPPFLAGS) -Umain
endif
sols : $(SOLS)
locales :
ifneq ($(ENABLE_NLS),0)
$(MAKE) -C po
endif
desktops : $(DESKTOPS)
clean-src :
$(RM) $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG)
find ball share putt \( -name '*.o' -o -name '*.d' \) -delete
$(RM) neverball.ico.o neverputt.ico.o
clean : clean-src
$(RM) $(SOLS)
$(RM) $(DESKTOPS)
$(MAKE) -C po clean
#------------------------------------------------------------------------------
.PHONY : all sols locales desktops clean-src clean
-include $(BALL_DEPS) $(PUTT_DEPS) $(MAPC_DEPS)
#------------------------------------------------------------------------------