forked from pioneerspacesim/pioneer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
411 lines (348 loc) · 14 KB
/
configure.ac
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
dnl Copyright © 2008-2014 Pioneer Developers. See AUTHORS.txt for details
dnl Licensed under the terms of the GPL v3. See COPYING.txt for details
dnl Process this file with autoconf to create configure.
dnl ###########################################################################
dnl Setup
dnl ###########################################################################
AC_PREREQ(2.59)
AC_INIT([pioneer], [0.00], [[email protected]])
dnl AC_CONFIG_HEADERS([config.h])
AC_DEFUN([MXE_SETUP], [
AC_ARG_WITH([mxe], AS_HELP_STRING([--with-mxe], [Path to MXE MinGW environment for cross-building]), [MXE_BASE=$withval], [MXE_BASE=])
MXE_CROSS=
MXE_CMAKE_TOOLCHAIN_FILE=""
if test "x$MXE_BASE" != "x" ; then
if test "x$host" != "x" ; then
AC_MSG_ERROR([Cannot specify --host with --with-mxe])
fi
AC_MSG_CHECKING([for MXE])
MXE_CMAKE_TOOLCHAIN_FILE="$MXE_BASE/usr/i686-pc-mingw32/share/cmake/mxe-conf.cmake"
if ! test -f "$MXE_CMAKE_TOOLCHAIN_FILE" ; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([MXE not found in $MXE_BASE])
fi
AC_MSG_RESULT([$MXE_BASE])
MXE_CROSS=yes
MXE_PATH="$MXE_BASE/usr/bin"
PATH="$MXE_PATH:$PATH"
host_alias=i686-pc-mingw32
ac_tool_prefix=$host_alias-
cross_compiling=yes
HAVE_WINDRES=yes
MXE_WINDRES="$MXE_BASE/usr/bin/${ac_tool_prefix}windres"
fi
AM_CONDITIONAL([HAVE_WINDRES], [test "$HAVE_WINDRES" = yes])
AC_SUBST(MXE_BASE)
AC_SUBST(MXE_CROSS)
AC_SUBST(MXE_PATH)
AC_SUBST(MXE_CMAKE_TOOLCHAIN_FILE)
AC_SUBST(MXE_WINDRES)
])
MXE_SETUP
AM_INIT_AUTOMAKE([1.9 foreign dist-bzip2 dist-xz dist-zip subdir-objects])
AC_CANONICAL_HOST
AC_PROG_CC
AC_PROG_CXX
AC_C_CONST
AC_PROG_RANLIB
AC_DEFUN([AC_PROG_STRIP], [AC_CHECK_TOOL(STRIP, strip, :)])
AC_PROG_STRIP
#AC_PROG_LIBTOOL
dnl Silent compilation by default
AM_SILENT_RULES([yes])
dnl ###########################################################################
dnl Flags and options
dnl ###########################################################################
STD_CXXFLAGS=
EXTRA_CFLAGS=
EXTRA_CXXFLAGS=
EXTRA_CPPFLAGS=
EXTRA_LIBS=
WARN_CFLAGS=
WARN_CXXFLAGS=
WARN_CPPFLAGS=
dnl Check for ccache if they want it
AC_ARG_WITH([ccache], AS_HELP_STRING([--with-ccache], [Compile using ccache]), [AC_PATH_PROG([CCACHE], [ccache])])
if test "x$with_ccache" = xyes; then
if test "x$CCACHE" = x; then
AC_MSG_WARN([ccache was requested but was not found. Build will proceed as normal])
fi
fi
dnl Add a flag, if supported by the compiler or preprocessor
dnl Assumes that -Werror works
AC_DEFUN([_PIONEER_COMPILER_FLAG], dnl Language, prefix (EXTRA), flags variable 'foo' (EXTRA_fooFLAGS), flag, $CC/$CXX/$CPP/similar, if yes, if no
[AC_LANG_PUSH([$1])
saved_flags="$][$3][FLAGS"
][$3][FLAGS="$saved_flags -Werror $4"
AC_MSG_CHECKING([to see if $5 supports $4])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])], [][$2][_][$3][FLAGS="$][$2][_][$3][FLAGS $4"; AC_MSG_RESULT([yes])]m4_default([; $6], []), [AC_MSG_RESULT([no])]m4_default([; $7], []))
][$3][FLAGS="$saved_flags"
AC_LANG_POP([$1])
])
AC_DEFUN([PIONEER_CFLAG], [_PIONEER_COMPILER_FLAG([C], [EXTRA], [C], [$1], [$CC], [$2], [$3])])
AC_DEFUN([PIONEER_CXXFLAG], [_PIONEER_COMPILER_FLAG([C++], [EXTRA], [CXX], [$1], [$CXX], [$2], [$3])])
AC_DEFUN([PIONEER_CPPFLAG], [_PIONEER_COMPILER_FLAG([CPP], [EXTRA], [CPP], [$1], [$CPP], [$2], [$3])])
AC_DEFUN([PIONEER_C_CXX_FLAG],
[_PIONEER_COMPILER_FLAG([C], [EXTRA], [C], [$1], [$CC/$CXX], [EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $1"])])
AC_DEFUN([PIONEER_WARN_CFLAG], [_PIONEER_COMPILER_FLAG([C], [WARN], [C], [$1], [$CC], [$2], [$3])])
AC_DEFUN([PIONEER_WARN_CXXFLAG], [_PIONEER_COMPILER_FLAG([C++], [WARN], [CXX], [$1], [$CXX], [$2], [$3])])
AC_DEFUN([PIONEER_WARN_CPPFLAG], [_PIONEER_COMPILER_FLAG([CPP], [WARN], [CPP], [$1], [$CPP], [$2], [$3])])
AC_DEFUN([PIONEER_WARN_C_CXX_FLAG],
[_PIONEER_COMPILER_FLAG([C], [WARN], [C], [$1], [$CC/$CXX], [WARN_CXXFLAGS="$WARN_CXXFLAGS $1"])])
dnl Early check for C++11
dnl -std=c++11 defines __STRICT_ANSI__, which causes MinGW some problems so use gnu++11 on it instead
case "$host" in
i686-pc-mingw32|x86_64-pc-mingw64)
_PIONEER_COMPILER_FLAG([C++], [STD], [CXX], [-std=gnu++11], [$CXX], [], [AC_MSG_ERROR([No compiler support for C++11. Unable to build])])
;;
*)
_PIONEER_COMPILER_FLAG([C++], [STD], [CXX], [-std=c++11], [$CXX], [], [AC_MSG_ERROR([No compiler support for C++11. Unable to build])])
esac
dnl Always add -Wall, where supported
PIONEER_WARN_C_CXX_FLAG([-Wall])
dnl Add -O0 if requested
OPTIMISE=-O3
AC_ARG_WITH([no-optimise], AS_HELP_STRING([--with-no-optimise], [Compile without optimisation]), [test "$withval" != no && OPTIMISE=-O0], [])
AC_SUBST([OPTIMISE])
dnl Debug stuff
AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable debugging code (stack checks, debug tools features, etc)]), [EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -DDEBUG"])
AC_ARG_ENABLE([ldb], AS_HELP_STRING([--enable-ldb], [Enable ldb support.]), [EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -DENABLE_LDB" ; EXTRA_LIBS="$EXTRA_LIBS -lldbcore"])
AC_ARG_ENABLE([profiler], AS_HELP_STRING([--enable-profiler], [Enable internal profiler]), [EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -DPIONEER_PROFILER"])
AC_ARG_WITH([fno-inline], AS_HELP_STRING([--with-fno-inline], [Compile without inlining. Helps debugging segaults that occur in STL code]), [PIONEER_C_CXX_FLAG([-fno-inline])])
AC_ARG_WITH([gprof], AS_HELP_STRING([--with-gprof], [Compile with gprof profiler]), [PIONEER_C_CXX_FLAG([-pg])])
dnl Strip binary after build
DO_STRIP=no
AC_ARG_WITH([strip], AS_HELP_STRING([--with-strip], [Strip binary after build]), [test "$withval" != no && DO_STRIP=yes], [])
AM_CONDITIONAL([DO_STRIP], [test "$DO_STRIP" = yes])
dnl Versioning. If this is a git checkout, try to get details from it
PIONEER_VERSION=
PIONEER_EXTRAVERSION=
if test -d .git ; then
AC_MSG_NOTICE([This is a git checkout])
PIONEER_VERSION=git
gitbin=`which git`
if test "x$gitbin" != x; then
PIONEER_EXTRAVERSION=`$gitbin log -n1 --format=%h`
AC_MSG_NOTICE([git ref: $PIONEER_EXTRAVERSION])
fi
fi
dnl And override with anything on the command line
AC_ARG_WITH([version], AS_HELP_STRING([--with-version], [Game version]), [PIONEER_VERSION=$withval])
AC_ARG_WITH([extra-version], AS_HELP_STRING([--with-extra-version], [Additional version info]), [PIONEER_EXTRAVERSION=$withval])
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -DPIONEER_VERSION=\\\"$PIONEER_VERSION\\\" -DPIONEER_EXTRAVERSION=\\\"$PIONEER_EXTRAVERSION\\\""
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -DGLEW_STATIC"
dnl Compiler warning options
AC_ARG_WITH([extra-warnings], AS_HELP_STRING([--without-extra-warnings], [Disable lots of extra compiler warnings]), [], [with_extra_warnings=yes])
if test "x$with_extra_warnings" != xno; then
for warn_opt in \
-Wformat \
-Wstrict-aliasing=2 \
-Wmissing-format-attribute \
-Wmissing-noreturn \
-Wdisabled-optimization \
-Wfloat-equal \
-Wshadow \
-Wcast-qual \
-Wcast-align \
; do
PIONEER_WARN_C_CXX_FLAG([$warn_opt])
done
dnl -Wformat-security requires -Wformat first, so it needs a slightly customised test
dnl we assume that if this test passes then the test (above) for -Wformat passed
dnl and therefore -Wformat should already be in WARN_CXXFLAGS
_PIONEER_COMPILER_FLAG([C], [WARN], [C], [-Wformat -Wformat-security], [$CC/$CXX], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat-security"])
for warn_opt in \
-Wno-format-zero-length \
-Werror-implicit-function-declaration \
; do
PIONEER_WARN_CFLAG([$warn_opt])
done
for warn_opt in \
-Wstrict-null-sentinel \
-Wold-style-cast \
-Wsign-promo \
; do
PIONEER_WARN_CXXFLAG([$warn_opt])
done
fi
dnl Add some useful args for clang under ccache
dnl http://petereisentraut.blogspot.com.au/2011/05/ccache-and-clang.html
if test "x$CCACHE" != x; then
PIONEER_C_CXX_FLAG([-Qunused-arguments])
PIONEER_C_CXX_FLAG([-fcolor-diagnostics])
fi
dnl Data files directory
if test "$PIONEER_DATA_DIR" = ''; then
AC_MSG_WARN([Using the default value for PIONEER_DATA_DIR.])
AC_MSG_WARN([Installing is NOT recommended.])
AC_MSG_WARN([IF YOU ARE PACKAGING PIONEER, SET THIS VARIABLE!])
AC_MSG_WARN([To install: make install DESTDIR=/path/to/install/dir/])
AC_MSG_WARN([The trailing path separator is required.])
AC_MSG_WARN([The installed Pioneer is only runnable from that directory.])
fi
PIONEER_DATA_DIR=${PIONEER_DATA_DIR:-data}
AC_ARG_VAR([PIONEER_DATA_DIR], [where Pioneer expects its data files to be [data]. Packagers MUST set this!])
dnl ###########################################################################
dnl Library checks
dnl ###########################################################################
dnl FIXME: should really check for headers (if no pkgconfig)
AC_DEFUN([PIONEER_CHECK_LIB],
[PKG_CHECK_MODULES([$1], [$2], [],
[AC_CHECK_LIB([$3], [$4], [], [AC_MSG_ERROR([$1 is required])])
][$1][_CFLAGS=
][$1][_LIBS="-l$3"
AC_SUBST([$1][_CFLAGS])
AC_SUBST([$1][_LIBS])
])
])
AC_ARG_WITH([thirdparty], AS_HELP_STRING([--with-thirdparty], [Location of pioneer-thirdparty repository]), [
AC_MSG_NOTICE([using pioneer-thirdparty repository in $withval])
if test "x$MXE_CROSS" = "xyes" ; then
PKG_CONFIG_PATH_i686_pc_mingw32="$withval/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH_i686_pc_mingw32
else
PKG_CONFIG_PATH="$withval/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH
fi
CFLAGS="-isystem $withval/usr/include"
LIBS="-L$withval/usr/lib -Wl,-rpath,$withval/usr/lib"
])
dnl Check for sigc++
PKG_CHECK_MODULES([SIGC], [sigc++-2.0])
dnl Check for SDL
PKG_CHECK_MODULES([SDL2], [sdl2 SDL2_image])
dnl Check for Freetype
PKG_CHECK_MODULES([FREETYPE], [freetype2])
dnl Check for libvorbis
PKG_CHECK_MODULES([VORBIS], [vorbisfile])
dnl Check for libpng
PKG_CHECK_MODULES([PNG], [libpng])
dnl Check for assimp
PKG_CHECK_MODULES([ASSIMP], [assimp])
dnl assimp's pkg-config file has a broken include path. Until upstream fixes
dnl it we work around it here
ASSIMP_CFLAGS=`echo $ASSIMP_CFLAGS | sed -e 's/\/assimp$//'`
if test "x$cross_compiling" = "xno" ; then
dnl Extra version checks for assimp. Last release was 2.0, we need 3.0+ (git
dnl version). Unfortunately the pkg-config version has not yet been updated
dnl upstream, so we have to test the library directly
AC_MSG_CHECKING(for ASSIMP version >= 3.0)
dnl Convert -Lfoo to -rpath=, as the wanted dir might not be visible to the dynamic linker
assimp_rpath=`echo $ASSIMP_LIBS | sed -e 's/-[^L] *[^ ]\+ *//g' | sed -e 's/-L */-Wl,-rpath,/g'`
old_cxxflags="$CXXFLAGS"
old_libs="$LIBS"
CXXFLAGS="$ASSIMP_CFLAGS"
LIBS="$ASSIMP_LIBS $assimp_rpath"
AC_LANG_PUSH([C++])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <assimp/defs.h>
#include <assimp/version.h>]],
[[do {
if (aiGetVersionMajor() >= 3 && aiGetVersionMinor() >= 0)
return 0;
return 1;
} while(0)]])],
[AC_MSG_RESULT(yes)
have_assimp_version=yes],
[AC_MSG_RESULT(no)])
AC_LANG_POP
if test "x$have_assimp_version" != "xyes" ; then
AC_MSG_ERROR("assimp version >= 3.0 not found. Get it from https://assimp.sourceforge.net/")
fi
CXXFLAGS="$old_cxxflags"
LIBS="$old_libs"
fi
dnl Optionally use external liblua
AC_ARG_WITH([external-liblua], AS_HELP_STRING([--with-external-liblua], [Use external liblua in place of our internal copy]), [], [with_external_liblua=no; HAVE_LUA=no])
if test "$with_external_liblua" = yes; then
PKG_CHECK_MODULES([LUA], [lua >= 5.2], [HAVE_LUA=yes], [foundlua=no])
if test "$foundlua" = no; then
PKG_CHECK_MODULES([LUA], [lua5.2 >= 5.2], [HAVE_LUA=yes], [AC_MSG_ERROR([External liblua was requested but is not available])])
fi
fi
AM_CONDITIONAL([HAVE_LUA], [test "$HAVE_LUA" = yes])
case "$host" in
i686-pc-mingw32|x86_64-pc-mingw64)
;;
*)
LUA_CFLAGS="$LUA_CFLAGS -DLUA_USE_POSIX"
esac
dnl Check for OpenGL libs
if test "x$MXE_CROSS" = "xyes" ; then
AC_SUBST([GL_CFLAGS], [])
AC_SUBST([GL_LIBS], [-lopengl32])
else
PIONEER_CHECK_LIB([GL], [gl], [GL], [glBegin])
fi
dnl ###########################################################################
dnl Platform selection
dnl ###########################################################################
AC_MSG_CHECKING([platform type])
case "$host" in
i686-pc-mingw32|x86_64-pc-mingw64)
PLATFORM=win32
;;
*)
PLATFORM=posix
;;
esac
AC_SUBST([PLATFORM])
AC_MSG_RESULT($PLATFORM)
AM_CONDITIONAL([BUILD_WIN32], [test "x-$PLATFORM" = "x-win32"])
AM_CONDITIONAL([BUILD_POSIX], [test "x-$PLATFORM" = "x-posix"])
dnl ###########################################################################
dnl System-specific stuff not covered above
dnl ###########################################################################
case "$host" in
i686-pc-mingw32|x86_64-pc-mingw64)
MINGW_LIBS="-lshlwapi"
SDL_LIBS="$SDL_LIBS -ltiff -lpng -ljpeg -lz"
;;
*)
MINGW_LIBS=
;;
esac
AC_SUBST([MINGW_LIBS])
dnl ###########################################################################
dnl Finished :-)
dnl ###########################################################################
dnl if ccache was wanted, update the compiler vars to match
dnl this is done late so that configure tests aren't run under ccache
if test "x$CCACHE" != x; then
CC="$CCACHE $CC"
CXX="$CCACHE $CXX"
fi
AC_SUBST([STD_CXXFLAGS])
AC_SUBST([EXTRA_CFLAGS])
AC_SUBST([EXTRA_CXXFLAGS])
AC_SUBST([EXTRA_CPPFLAGS])
AC_SUBST([EXTRA_LIBS])
AC_SUBST([WARN_CFLAGS])
AC_SUBST([WARN_CXXFLAGS])
AC_SUBST([WARN_CPPFLAGS])
AC_CONFIG_FILES([
Makefile
data/Makefile
src/Makefile
src/collider/Makefile
src/gameui/Makefile
src/gui/Makefile
src/graphics/Makefile
src/scenegraph/Makefile
src/galaxy/Makefile
src/terrain/Makefile
src/text/Makefile
src/ui/Makefile
src/win32/Makefile
src/posix/Makefile
contrib/Makefile
contrib/lua/Makefile
contrib/miniz/Makefile
contrib/jenkins/Makefile
contrib/json/Makefile
contrib/PicoDDS/Makefile
contrib/vcacheopt/Makefile
contrib/glew/Makefile
contrib/profiler/Makefile
osx/Makefile
win32/Makefile])
AC_OUTPUT