Repository navigation
Expand file tree
/
Copy pathconfigure.ac
More file actions
456 lines (367 loc) · 11.7 KB
/
Copy pathconfigure.ac
File metadata and controls
456 lines (367 loc) · 11.7 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
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
AC_PREREQ([2.69])
AC_INIT([quetoo], [-1], [jay@jaydolan.com])
AC_USE_SYSTEM_EXTENSIONS
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_MACRO_DIR(m4)
AC_CONFIG_SRCDIR(src/quetoo.h)
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([foreign subdir-objects])
AM_SILENT_RULES([yes])
dnl ---------------
dnl Check for tools
dnl ---------------
AC_PROG_CC
AC_PROG_CXX
AC_PROG_OBJC
# libtool 2.5+ dropped the ObjC tag; set OBJC=$CC so libtool infers the CC
# tag for Objective-C files (.m), which clang/gcc handles via file extension.
OBJC="$CC"
LT_INIT
dnl --------------------
dnl Check for pkg-config
dnl --------------------
PKG_PROG_PKG_CONFIG
dnl ---------------
dnl Check host type
dnl ---------------
HOST_NAME=""
HOST_CFLAGS=""
HOST_LDFLAGS=""
HOST_LIBS=""
HOST_PROFILE_CFLAGS=""
HOST_PROFILE_LIBS=""
HOST_SO_CFLAGS=""
DEFAULT_PREFIX="/usr/local"
AC_MSG_CHECKING([host type])
case "$host" in
*-apple-*)
AC_MSG_RESULT(apple)
HOST_NAME="APPLE"
host_cpu="arm64"
host_os="darwin"
dnl openal-soft is keg-only in Homebrew (to avoid clobbering macOS's
dnl built-in OpenAL framework), so its .pc file lives under
dnl opt/openal-soft rather than anywhere pkg-config searches by
dnl default. Everything else we depend on (sdl3, physfs, ncurses,
dnl etc.) is discoverable via pkg-config's own default search path.
dnl Homebrew's prefix differs between Apple Silicon (/opt/homebrew)
dnl and Intel (/usr/local), so check both.
if test -d "/opt/homebrew/opt/openal-soft/lib/pkgconfig"; then
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/opt/homebrew/opt/openal-soft/lib/pkgconfig"
elif test -d "/usr/local/opt/openal-soft/lib/pkgconfig"; then
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/opt/openal-soft/lib/pkgconfig"
fi
dnl Some dependencies (e.g. a manually built SDL3 family, as
dnl opposed to a Homebrew bottle) install their shared libraries
dnl with an @rpath-relative install name and no absolute-path
dnl fixup. Without an LC_RPATH entry in the consuming binary,
dnl dyld cannot resolve those libraries at runtime, even though
dnl they're perfectly discoverable at link time via pkg-config.
dnl Embed rpaths for both common prefixes so this works
dnl regardless of which SDL3 (or other) build pkg-config finds.
HOST_LDFLAGS="-headerpad_max_install_names -Wl,-rpath,/usr/local/lib -Wl,-rpath,/opt/homebrew/lib"
HOST_LIBS="-ldl -rdynamic"
HOST_SO_CFLAGS="-fPIC -DPIC"
;;
*bsd*)
AC_MSG_RESULT(bsd)
HOST_NAME="BSD"
HOST_SO_CFLAGS="-fPIC -DPIC"
;;
*)
AC_MSG_RESULT(linux)
HOST_NAME="LINUX"
HOST_LIBS="-ldl -lm -rdynamic"
HOST_SO_CFLAGS="-fPIC -DPIC"
;;
esac
BUILD="${host_cpu}-${host_vendor}-${host_os}"
AC_DEFINE_UNQUOTED(BUILD, "${BUILD}", [The canonical name of the build])
AC_ARG_WITH([build-number],
[AS_HELP_STRING([--with-build-number=N], [monotonic build number; -1 disables the installer (default: -1)])],
[BUILD_NUMBER=$withval],
[BUILD_NUMBER=$PACKAGE_VERSION])
AC_DEFINE_UNQUOTED(BUILD_NUMBER, "${BUILD_NUMBER}", [The monotonic build number, used by the installer])
AC_ARG_WITH([version],
[AS_HELP_STRING([--with-version=X.Y.Z], [semantic version, e.g. the git tag (default: `git describe`)])],
[VERSION=$withval],
[VERSION=`git describe --tags --always 2>/dev/null || echo $PACKAGE_VERSION`])
AC_DEFINE_UNQUOTED(VERSION, "${VERSION}", [The semantic version])
AC_SUBST(ARCH)
AC_SUBST(HOST)
AC_SUBST(HOST_NAME)
AC_SUBST(HOST_CFLAGS)
AC_SUBST(HOST_LIBS)
AC_SUBST(HOST_PROFILE_CFLAGS)
AC_SUBST(HOST_PROFILE_LIBS)
CFLAGS="-pipe $CFLAGS $HOST_CFLAGS"
AC_SUBST(CFLAGS)
SO_CFLAGS="$SO_CFLAGS $HOST_SO_CFLAGS"
AC_SUBST(SO_CFLAGS)
LDFLAGS="$LDFLAGS $HOST_LDFLAGS"
AC_SUBST(LDFLAGS)
CPPFLAGS="$CFLAGS $CPPFLAGS"
AC_SUBST(CPPFLAGS)
AM_CONDITIONAL([APPLE], [test "x$HOST_NAME" = "xAPPLE"])
AM_CONDITIONAL([BSD], [test "x$HOST_NAME" = "xBSD"])
AM_CONDITIONAL([LINUX], [test "x$HOST_NAME" = "xLINUX"])
dnl -----------------
dnl Check for curses
dnl -----------------
PKG_CHECK_MODULES([CURSES], [ncurses >= 5.0],, [
AC_CHECK_HEADER(curses.h,
CURSES_LIBS="-lpdcurses",
[AC_MSG_ERROR([Could not find curses.h, please install curses])]
)
])
dnl --------------------------
dnl Check for SDL3, SDL3_image
dnl --------------------------
PKG_CHECK_MODULES([SDL3], [sdl3 >= 3.4.12 sdl3-image sdl3-ttf])
dnl Homebrew's sdl3.pc carries its own -Wl,-rpath for the Homebrew prefix,
dnl which HOST_LDFLAGS already embeds on macOS; drop it to keep ld quiet.
case "$host" in
*darwin*)
SDL3_LIBS=`echo "$SDL3_LIBS" | sed 's|-Wl,-rpath,/opt/homebrew/lib||;s|-Wl,-rpath,/usr/local/lib||'`
;;
esac
dnl --------------------
dnl Check for libsndfile
dnl --------------------
PKG_CHECK_MODULES([SNDFILE], [sndfile])
dnl ------------------------
dnl Check for Objectively
dnl ------------------------
PKG_CHECK_MODULES([OBJECTIVELY], [Objectively >= 2.4.0])
dnl ------------------------
dnl Check for ObjectivelyGPU
dnl ------------------------
PKG_CHECK_MODULES([OBJECTIVELYGPU], [ObjectivelyGPU >= 2.2.0])
dnl ------------------------
dnl Check for ObjectivelyMVC
dnl ------------------------
PKG_CHECK_MODULES([OBJECTIVELYMVC], [ObjectivelyMVC >= 2.5.3])
dnl ------------------------------------------------
dnl Check for offline shader cross-compilation tools
dnl ------------------------------------------------
dnl glslc (shaderc) compiles GLSL to SPIR-V; shadercross (SDL_shadercross)
dnl cross-compiles SPIR-V to MSL/DXIL. Only needed to regenerate the versioned
dnl shader blobs via 'make shaders'; normal builds use the committed blobs.
AC_CHECK_PROG([GLSLC], [glslc], [glslc])
AC_CHECK_PROG([SHADERCROSS], [shadercross], [shadercross])
dnl ----------------
dnl Check for OpenAL
dnl ----------------
PKG_CHECK_MODULES([OPENAL], [openal >= 1.20])
dnl --------------
dnl Check for Opus
dnl --------------
PKG_CHECK_MODULES([OPUS], [opus >= 1.3])
dnl -------------------
dnl Check for PhysicsFS
dnl -------------------
PKG_CHECK_MODULES([PHYSFS], [physfs])
dnl PhysicsFS itself links zlib but its .pc doesn't declare the dependency.
PHYSFS_LIBS="$PHYSFS_LIBS -lz"
dnl -------------------------------
dnl Check for execinfo.h (optional)
dnl -------------------------------
AC_CHECK_HEADER(execinfo.h,
AC_DEFINE(HAVE_EXECINFO, 1,
[Define to 1 if you have the <execinfo.h> header file.]
),
)
dnl ---------------------------------
dnl Check which game modules to build
dnl ---------------------------------
AC_MSG_CHECKING(which game modules to build)
GAME_MODULES="ctf default lithium race"
AC_ARG_WITH(games,
AS_HELP_STRING([--with-games='default ...'],
[build specified game modules]
)
)
if test "x${with_games}" != x; then
GAME_MODULES="${with_games}"
fi
AC_SUBST(GAME_MODULES)
AC_MSG_RESULT($GAME_MODULES)
dnl ---------------------------------
dnl Check whether to build unit tests
dnl ---------------------------------
BUILD_TESTS=no
AC_ARG_WITH(tests,
AS_HELP_STRING([--with-tests],
[build unit tests]
)
)
AC_MSG_CHECKING(whether to build unit tests)
if test "x${with_tests}" = xyes; then
BUILD_TESTS=yes
PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
fi
AC_MSG_RESULT($BUILD_TESTS)
AM_CONDITIONAL(BUILD_TESTS, test "x$BUILD_TESTS" = xyes)
dnl -----------------
dnl Compiler warnings
dnl -----------------
AC_MSG_CHECKING(whether to abort on compiler warnings)
WARN_CFLAGS="-Wall -Wextra -Wno-unused-parameter -Wno-unknown-pragmas -Wno-format-truncation"
AC_ARG_ENABLE(warn,
AS_HELP_STRING(
[--enable-warn], [abort on compiler warnings]
),
AC_MSG_RESULT(yes)
WARN_CFLAGS="-Werror $WARN_CFLAGS",
AC_MSG_RESULT(no)
)
AC_SUBST(WARN_CFLAGS)
dnl ----------------------
dnl Compiler optimizations
dnl ----------------------
AC_MSG_CHECKING(whether to enable compiler optimizations)
OPT_CFLAGS=""
AC_ARG_ENABLE(optimizations,
AS_HELP_STRING(
[--enable-optimizations=none|default|expensive], [enable compiler optimizations]
),
AC_MSG_RESULT($enable_optimizations)
if test "x${enable_optimizations}" = xnone; then
OPT_CFLAGS="-O0 $OPT_CFLAGS"
elif test "x${enable_optimizations}" = xexpensive; then
OPT_CFLAGS="-O3 $OPT_CFLAGS"
else
OPT_CFLAGS="-O2 $OPT_CFLAGS"
fi,
AC_MSG_RESULT(no)
)
AC_SUBST(OPT_CFLAGS)
dnl ---------------------
dnl Debugging information
dnl ---------------------
AC_MSG_CHECKING(whether to include debugging information)
DEBUG_CFLAGS="-g"
AC_ARG_ENABLE(debug,
AS_HELP_STRING(
[--disable-debug], [omit debugging information]
),
AC_MSG_RESULT(no)
DEBUG_CFLAGS="",
AC_MSG_RESULT(yes)
)
AC_SUBST(DEBUG_CFLAGS)
dnl ---------------------
dnl Profiling information
dnl ---------------------
AC_MSG_CHECKING(whether to include profiling information)
PROFILE_CFLAGS=""
PROFILE_LIBS=""
AC_ARG_ENABLE(profile,
AS_HELP_STRING(
[--enable-profile], [include profiling information]
),
AC_MSG_RESULT(yes)
PROFILE_CFLAGS="-pg $HOST_PROFILE_CFLAGS"
PROFILE_LIBS="$HOST_PROFILE_LIBS",
AC_MSG_RESULT(no)
)
AC_SUBST(PROFILE_CFLAGS)
AC_SUBST(PROFILE_LIBS)
dnl ----------------------------------------
dnl Consolidate our core flags and libraries
dnl ----------------------------------------
BASE_CFLAGS=$(echo $CFLAGS $OPT_CFLAGS $DEBUG_CFLAGS $PROFILE_CFLAGS $WARN_CFLAGS)
BASE_LIBS=$(echo $HOST_LIBS $PROFILE_LIBS $WARN_LIBS)
BASE_LDFLAGS=$(echo $LDFLAGS)
AC_SUBST(BASE_CFLAGS)
AC_SUBST(BASE_LIBS)
AC_SUBST(BASE_LDFLAGS)
dnl ----------------------
dnl Fill in path variables
dnl ----------------------
test "$prefix" = "NONE" && prefix=$DEFAULT_PREFIX
test "$exec_prefix" = "NONE" && exec_prefix=$prefix
if test "x${prefix}" = "x/"; then
eval BINDIR="/bin"
eval PKGLIBDIR="/lib/$PACKAGE"
eval PKGDATADIR="/share/$PACKAGE"
else
eval BINDIR="$prefix/bin"
eval PKGLIBDIR="$prefix/lib/$PACKAGE"
eval PKGDATADIR="$prefix/share/$PACKAGE"
fi
AC_DEFINE_UNQUOTED(BINDIR, "$BINDIR",
[Define to path containing game binaries.]
)
AC_SUBST(BINDIR)
AC_DEFINE_UNQUOTED(PKGLIBDIR, "$PKGLIBDIR",
[Define to path containing the shared modules.]
)
AC_SUBST(PKGLIBDIR)
AC_DEFINE_UNQUOTED(PKGDATADIR, "$PKGDATADIR",
[Define to path containing the game data.]
)
AC_SUBST(PKGDATADIR)
AM_CONDITIONAL(BUILD_CLIENT, test "x$BUILD_CLIENT" = xyes)
AM_CONDITIONAL(BUILD_MASTER, test "x$BUILD_MASTER" = xyes)
dnl -----------------------------------------------------------
dnl Configuraton tests complete -- provide a summary of results
dnl -----------------------------------------------------------
AC_CONFIG_FILES([
Makefile
deps/Makefile
deps/discord-rpc/Makefile
deps/discord-rpc/include/Makefile
deps/discord-rpc/src/Makefile
deps/minizip/Makefile
deps/rapidjson/Makefile
deps/rapidjson/rapidjson/Makefile
deps/rapidjson/rapidjson/error/Makefile
deps/rapidjson/rapidjson/internal/Makefile
deps/rapidjson/rapidjson/msinttypes/Makefile
src/Makefile
src/collision/Makefile
src/cgame/Makefile
src/cgame/default/Makefile
src/cgame/ctf/Makefile
src/cgame/lithium/Makefile
src/cgame/race/Makefile
src/client/Makefile
src/client/renderer/Makefile
src/client/renderer/shaders/Makefile
src/client/sound/Makefile
src/client/ui/Makefile
src/common/Makefile
src/game/Makefile
src/game/default/Makefile
src/game/ctf/Makefile
src/game/lithium/Makefile
src/game/race/Makefile
src/main/Makefile
src/master/Makefile
src/net/Makefile
src/quemap/Makefile
src/server/Makefile
src/shared/Makefile
src/tests/Makefile
src/tools/Makefile
])
AC_OUTPUT
AC_MSG_RESULT([
Automatic configuration OK.
Configuration summary:
Version: ........... $VERSION
Build number: ...... $BUILD_NUMBER
Build: ............. $BUILD
Compiler: .......... $CC
C flags: ........... $BASE_CFLAGS
Libraries: ......... $BASE_LIBS
Linking: ........... $BASE_LDFLAGS
Game modules: ...... $GAME_MODULES
Unit tests: ........ $BUILD_TESTS
Installation directories:
Program: ........... $BINDIR
Libraries: ......... $PKGLIBDIR
Data: .............. $PKGDATADIR
Type 'make' to build Quetoo. Type 'make install' to install it.
])