-
Notifications
You must be signed in to change notification settings - Fork 5
/
configure.in
422 lines (354 loc) · 11.1 KB
/
configure.in
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
dnl **************************************************************
dnl Process this file with autoconf to produce a configure script.
dnl **************************************************************
AC_PREREQ(2.59)
AC_INIT
AC_CONFIG_SRCDIR([README])
AC_CONFIG_AUX_DIR(.)
dnl Keep the correct libtool macros in-tree
AC_CONFIG_MACRO_DIR([m4])
dnl Detect the canonical host and target build environment
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(adonthell, 0.4.0-alpha-3)
AM_CONFIG_HEADER([config.h])
dnl ********************
dnl Checks for programs.
dnl ********************
AC_PROG_LN_S
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_MAKE_SET
dnl *********
dnl Endianess
dnl *********
AC_C_BIGENDIAN(CXXFLAGS="$CXXFLAGS -D__BIG_ENDIAN__", :, :)
dnl ************************************
dnl set up Objective C compiler for OS X
dnl ************************************
_AM_DEPENDENCIES([OBJC])
OBJC="gcc"
AC_SUBST(OBJC)
if test x$ac_cv_cxx_compiler_gnu = xyes; then
CXXFLAGS="$CXXFLAGS -std=c++0x -fno-exceptions -fno-strict-aliasing"
fi
case "$target" in
*-apple-darwin*)
osx="yes"
LDFLAGS="$LDFLAGS -headerpad_max_install_names"
;;
*-*-cygwin* | *-*-mingw32*)
LDFLAGS="$LDFLAGS -no-undefined"
;;
esac
AM_CONDITIONAL(OSX_COMPILE, test x$osx = xyes)
dnl *******
dnl libtool
dnl *******
AC_LIBTOOL_WIN32_DLL
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
AC_CHECK_LIB(ltdl, lt_dlinit,,echo "Adonthell requires libltdl. Exitting...";exit 1)
dnl ********************
dnl Additional arguments
dnl ********************
AC_ARG_ENABLE(unix-install,
[ --disable-unix-install Disable a Unix-like install (enabled by default)],
unixinst=$enableval, unixinst=yes)
AC_ARG_WITH(data-dir,
[ --with-data-dir=DIR Directory where game data will be installed],
gamedatadir="$withval", gamedatadir=none)
AC_ARG_WITH(py-libs,
[ --with-py-libs=LIBS Override Python libraries auto-detection],
pylibs="$withval", pylibs=none)
AC_ARG_WITH(py-cflags,
[ --with-py-cflags=FLAGS Override Python cflags auto-detection],
pycflags="$withval", pycflags=none)
AC_ARG_ENABLE(dev-build,
[ --enable-dev-build Enable developer build with unit tests and debug symbols (disabled by default)],
devbuild=$enableval, devbuild=no)
AC_ARG_VAR(GTEST_DIR, [path to Google Test sources (default /usr/src/gtest)])
AC_ARG_VAR(GMOCK_DIR, [path to Google Mock sources (default /usr/src/gmock)])
AC_CHECK_LIB(z, main,,echo "Adonthell requires Zlib. Exitting...";exit 1)
dnl ******************************
dnl Tell that we are using libtool
dnl ******************************
CXXFLAGS="$CXXFLAGS -DUSE_LIBTOOL"
dnl **********************
dnl Set the data directory
dnl **********************
if test x$gamedatadir = xnone; then
if test x$unixinst = xno; then
CXXFLAGS="$CXXFLAGS -DSINGLE_DIR_INST"
case "$target" in
*-*-darwin*)
makebundle="yes"
backenddir="../PlugIns"
gamedatadir="../Resources"
;;
*)
gamedatadir="."
backenddir="./lib/adonthell"
;;
esac
else
case "$target" in
*-*-cygwin* | *-*-mingw32*)
gamedatadir="."
backenddir="./lib/adonthell"
LDFLAGS="$LDFLAGS -Wl,--export-all-symbols"
;;
*-*-beos*)
gamedatadir="/boot/home/config/share/adonthell"
;;
*)
backenddir="${libdir}/adonthell"
gamedatadir="${datadir}/adonthell"
;;
esac
fi
fi
CXXFLAGS="$CXXFLAGS -DDATA_DIR=\"\\\"$gamedatadir\\\"\""
AC_SUBST(backenddir)
dnl ***************
dnl Find pkg-config
dnl ***************
AC_PATH_PROG(PKG_CONFIG, [pkg-config], [no])
if test x$PKG_CONFIG = xno ; then
AC_MSG_ERROR([*** pkg-config not found. See http://www.freedesktop.org/software/pkgconfig/])
fi
if $PKG_CONFIG --atleast-pkgconfig-version 0.14 ; then
:
else
AC_MSG_ERROR([*** pkg-config too old; version 0.14 or better required.])
fi
dnl *****************
dnl Check for libxml2
dnl *****************
XML_VERSION=2.5.0
AM_PATH_XML2($XML_VERSION,
:,
AC_MSG_ERROR([*** libxml version >= $XML_VERSION not found!])
)
dnl *************
dnl Check for SDL
dnl *************
dnl try sdl >= 2.0.0 first
AM_PATH_SDL2([2.0.0],
[
sdlbackenddir=sdl2
sdlmixer_prefix=SDL2
],
[
unset ac_cv_path_SDL_CONFIG
sdlmixer_prefix=SDL
SDL_VERSION=1.2.0
AM_PATH_SDL([$SDL_VERSION],
[sdlbackenddir=sdl],
[AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])]
)]
)
dnl *******************
dnl Check for SDL-mixer
dnl *******************
AC_CHECK_HEADER([${sdlmixer_prefix}/SDL_mixer.h],,
[AC_MSG_ERROR([*** Cannot find the ${sdlmixer_prefix}/SDL_mixer.h header
goto http://www.libsdl.org to download or
check with your distibution.]
); exit])
AC_CHECK_LIB([${sdlmixer_prefix}_mixer],
[Mix_OpenAudio],
[:],
[AC_MSG_ERROR([*** Cannot find the ${sdlmixer_prefix}_mixer library
goto http://www.libsdl.org to download or
check with your distibution.]
); exit])
SDL_MIXER_LIBS=-l${sdlmixer_prefix}_mixer
AC_SUBST(SDL_MIXER_LIBS)
dnl *******************
dnl Check for libpng
dnl *******************
dnl TODO Need to check for library also
AC_CHECK_HEADER([png.h],,
[AC_MSG_ERROR([*** Cannot find the png.h header
goto http://www.libpng.org/ to download or
check with your distibution.]
); exit])
dnl ****************
dnl Check for Python
dnl ****************
AM_PATH_PYTHON([2.0])
dnl convert windows paths to cygwin paths
dnl required when building the python wrappers
case "$target" in
*-*-cygwin* | *-*-mingw32*)
pyexecdir=`cd $pyexecdir && pwd`
pythondir=`cd $pythondir && pwd`
;;
esac
dnl Find the Python.h header file
if test "x$pycflags" = xnone; then
AC_MSG_CHECKING(for Python header files)
changequote(<<, >>)
PYINCLUDE=`$PYTHON -c 'import sys ; print "%s/include/python%s" % (sys.prefix, sys.version[:3])'`
changequote([, ])
dnl convert windows paths to cygwin paths
case "$target" in
*-*-cygwin* | *-*-mingw32*)
PYINCLUDE=`cd $PYINCLUDE && pwd`
;;
esac
if test -r "$PYINCLUDE/Python.h"; then
PY_CFLAGS="-I$PYINCLUDE"
AC_SUBST(PY_CFLAGS)
else
AC_MSG_ERROR([Could not find Python.h in $PYINCLUDE])
fi
AC_MSG_RESULT(found)
else
PY_CFLAGS=${pycflags}
AC_MSG_CHECKING(for Python cflags)
AC_MSG_RESULT($PY_CFLAGS)
AC_SUBST(PY_CFLAGS)
fi
dnl Find the Python library
if test "x$pylibs" = xnone; then
AC_MSG_CHECKING(for Python library)
PYLIB=""
changequote(<<, >>)
PYPREFIX=`$PYTHON -c 'import sys; print sys.prefix'`
PYLIBVER=`$PYTHON -c 'import sys; print sys.version[:3]'`
changequote([, ])
dnl look for a framework build of python first
fw=`echo "$PYPREFIX" | sed 's/.*\(Python\.framework\).*/\1/;'`
if test "x$fw" != x && test "x$osx" = "xyes"; then
PY_LIBS="-framework Python"
PY_FWDIR=`$PYTHON -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()'`
PY_SPDIR="$pyexecdir"
AC_SUBST(PY_FWDIR)
AC_SUBST(PY_SPDIR)
AC_MSG_RESULT(found)
else
py_paths="$PYPREFIX/lib64/python$PYLIBVER/config $PYPREFIX/lib64 \
$PYPREFIX/lib/python$PYLIBVER/config $PYPREFIX/lib"
dnl Try for specific version first, then the generic version, then panic
for ppath in $py_paths ; do
if test -r "$ppath/libpython$PYLIBVER.so" -o \
-r "$ppath/libpython$PYLIBVER.a"; then
PYLIB="-L$ppath -lpython$PYLIBVER"
break
fi
if test -r "$ppath/libpython.so" -o \
-r "$ppath/libpython.a"; then
PYLIB="-L$ppath -lpython"
break
fi
done
if test "x$PYLIB" != x ; then
PY_LIBS="$PYLIB $PY_LIBS"
AC_MSG_RESULT(found)
else
AC_MSG_ERROR([*** Python library not found])
fi
fi
dnl Get the libraries that a static python library depends on
AC_MSG_CHECKING(for Python's dependencies)
py_extradeps=`$PYTHON -c 'import distutils.sysconfig; print distutils.sysconfig.get_config_var("LIBS")'`
py_sysextradeps=`$PYTHON -c 'import distutils.sysconfig; print distutils.sysconfig.get_config_var("SYSLIBS")'`
PY_DEPS="$py_extradeps $py_sysextradeps"
AC_MSG_RESULT($PY_DEPS)
dnl only GNU ld seems to know -E flag
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
PY_LIBS="-Wl,-E $PY_LIBS $PY_DEPS"
else
PY_LIBS="$PY_LIBS $PY_DEPS"
fi
AC_SUBST(PY_LIBS)
else
PY_LIBS=${pylibs}
AC_MSG_CHECKING(for Python ld flags)
AC_MSG_RESULT($PY_LIBS)
AC_SUBST(PY_LIBS)
fi
AM_CONDITIONAL(PY_FRAMEWORK, test x$PY_SPDIR != x$PY_FWDIR)
dnl **************
dnl Check for SWIG
dnl **************
SWIG_VERSION=1.3.24
SWIG_PROG($SWIG_VERSION)
SWIG_ENABLE_CXX()
dnl *********************************************************************************
dnl If this is a developer build, turn on debug symbols and check for gtest and gmock
dnl *********************************************************************************
if test x$devbuild = xyes; then
CXXFLAGS="$CXXFLAGS -g -Wall -pedantic"
test "x$GTEST_DIR" = "x" && GTEST_DIR="/usr/src/gtest"
test "x$GMOCK_DIR" = "x" && GMOCK_DIR="/usr/src/gmock"
AC_CHECK_LIB(gtest_main, main,
[AC_SUBST(libgtest_CFLAGS, "")
AC_SUBST(libgtest_LIBS, "-lgtest")
AM_CONDITIONAL(BUILD_GTEST, false)],
[AC_CHECK_FILE($GTEST_DIR/src/gtest-all.cc,
[AC_SUBST(GTEST_DIR)
AC_SUBST(libgtest_CFLAGS, "-I$GTEST_DIR/include")
AC_SUBST(libgtest_LIBS, '-L$(top_builddir)/src/ -lgtest')
AM_CONDITIONAL(BUILD_GTEST, true)],
[AC_MSG_FAILURE([Missing gtest library])])
])
AC_CHECK_LIB(gmock_main, main,
[AC_SUBST(libgmock_CFLAGS, "")
AC_SUBST(libgmock_LIBS, "-lgmock")
AM_CONDITIONAL(BUILD_GMOCK, false)],
[AC_CHECK_FILE($GMOCK_DIR/src/gmock-all.cc,
[AC_SUBST(GMOCK_DIR)
AC_SUBST(libgmock_CFLAGS, "-I$GMOCK_DIR/include")
AC_SUBST(libgmock_LIBS, '-L$(top_builddir)/src/ -lgmock')
AM_CONDITIONAL(BUILD_GMOCK, true)],
[AC_MSG_FAILURE([Missing gmock library])])
])
else
AM_CONDITIONAL(BUILD_GTEST, false)
AM_CONDITIONAL(BUILD_GMOCK, false)
fi
dnl *********************
dnl Check for google-glog
dnl *********************
PKG_CHECK_MODULES([libglog], [libglog >= 0.3.0], [
AC_DEFINE([HAVE_GLOG_H], [1], [Define to 1 if you have google-glog])], [:])
AC_SUBST(libglog_LIBS)
AC_SUBST(libglog_CFLAGS)
dnl ************
dnl other checks
dnl ************
AC_CHECK_FUNCS(nanosleep,,)
AC_SUBST(CXXFLAGS)
AC_CHECK_FT2(6.0.0,
:,
AC_MSG_ERROR([*** Freetype version >= 6.0.0 not found!])
)
AC_SUBST(FT2_LIBS)
AC_SUBST(FT2_CFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(sdlbackenddir)
AC_CONFIG_FILES([
adonthell.pc
Makefile
src/Makefile
src/main/Makefile
src/base/Makefile
src/event/Makefile
src/gfx/Makefile
src/input/Makefile
src/audio/Makefile
src/gui/Makefile
src/python/Makefile
src/rpg/Makefile
src/world/Makefile
src/py-runtime/Makefile
src/py-wrappers/Makefile
src/py-wrappers/adonthell/Makefile
doc/Makefile
test/Makefile
test/data/Makefile
])
AC_OUTPUT