source: trunk/configure.ac @ 2542

Last change on this file since 2542 was 2542, checked in by sam, 10 years ago

lua: compilation fixes for non-quite-POSIX platforms.

File size: 14.3 KB
Line 
1dnl configure script for Lol Engine
2
3AC_INIT(lolengine, 0.0)
4AC_PREREQ(2.50)
5AC_CONFIG_AUX_DIR(.auto)
6AC_CANONICAL_SYSTEM
7AM_INIT_AUTOMAKE([subdir-objects no-define tar-ustar silent-rules])
8dnl AM_MAINTAINER_MODE
9AM_DEFAULT_VERBOSITY=0
10
11dnl Versioning of the separate software we ship
12LOLUNIT_VERSION=0.1
13AC_SUBST(LOLUNIT_VERSION)
14LOLREMEZ_VERSION=0.2
15AC_SUBST(LOLREMEZ_VERSION)
16
17AC_CONFIG_HEADER(config.h)
18
19AM_PROG_CC_C_O
20AC_PROG_CPP
21AC_PROG_CXX
22AC_PROG_CXXCPP
23AC_PROG_RANLIB
24
25AC_LIBTOOL_WIN32_DLL
26AM_PROG_LIBTOOL
27AC_LIBTOOL_CXX
28
29AC_C_CONST
30AC_C_INLINE
31
32dnl Ensure an error is thrown if pkg-config M4 files are not found.
33m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
34m4_pattern_forbid([^PKG_CHECK_MODULES$])
35m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])
36
37dnl  Same for Lol Engine M4 files.
38m4_pattern_forbid([^LOL_])
39
40
41dnl Do not use PKG_CONFIG_LIBDIR when cross-compiling.
42if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
43  export PKG_CONFIG_LIBDIR=/dev/null
44fi
45
46dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
47dnl now otherwise it might be set in an obscure if statement. Same thing for
48dnl PKG_PROG_PKG_CONFIG which needs to be called first.
49AC_EGREP_CPP(yes, foo)
50PKG_PROG_PKG_CONFIG()
51
52
53dnl  Check for a working implementation of sed
54AC_PROG_SED
55AC_MSG_CHECKING(for a sed that understands \t)
56if test "$(echo 'x\x' | "${SED}" 's/.*@<:@^x\t@:>@//')" != x; then
57  AC_MSG_RESULT(no)
58  AC_MSG_ERROR([[consider installing GNU sed]])
59else
60  AC_MSG_RESULT(yes)
61fi
62
63
64dnl conditional builds
65AC_ARG_ENABLE(debug,
66  [  --enable-debug          build debug versions of the game (default no)])
67AC_ARG_ENABLE(release,
68  [  --enable-release        build final release of the game (default no)])
69AC_ARG_ENABLE(experimental,
70  [  --enable-experimental   experimental build (default no)])
71AC_ARG_ENABLE(doc,
72  [  --enable-doc            build documentation (needs doxygen and LaTeX)])
73
74
75dnl  Common C headers
76AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
77AC_CHECK_HEADERS(fastmath.h pthread.h libutil.h util.h pty.h glob.h unistd.h)
78AC_CHECK_HEADERS(execinfo.h)
79AC_CHECK_HEADERS(sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h)
80AC_CHECK_HEADERS(sys/wait.h)
81AC_CHECK_HEADERS(linux/kdev_t.h linux/major.h)
82AC_CHECK_HEADERS(security/pam_appl.h security/pam_misc.h)
83AC_CHECK_HEADERS(pam/pam_appl.h pam/pam_misc.h)
84
85dnl  Common C++ headers
86AC_LANG_PUSH(C++)
87AC_CHECK_HEADERS(cxxabi.h)
88AC_LANG_POP(C++)
89
90dnl  Common C functions
91AC_CHECK_FUNCS(getenv getcwd _getcwd backtrace_symbols)
92
93
94if test "${enable_debug}" = "yes"; then
95  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
96  OPT_CXXFLAGS="-O"
97else
98  OPT_CXXFLAGS="-O3 -ffast-math -fomit-frame-pointer"
99  OPT_LDFLAGS="-fno-strength-reduce"
100fi
101
102if test "${enable_release}" = "yes"; then
103  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
104  REL_CXXFLAGS=""
105else
106  REL_CXXFLAGS="-g"
107fi
108
109if test "${enable_experimental}" = "yes"; then
110  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
111fi
112
113# Build documentation?
114DOXYGEN="no"
115LATEX="no"
116if test "${enable_doc}" != "no"; then
117  AC_PATH_PROG(DOXYGEN, doxygen, no)
118  if test "${DOXYGEN}" != "no"; then
119    # Build LaTeX documentation?
120    AC_PATH_PROG(LATEX, pdflatex, no)
121    AC_PATH_PROG(KPSEWHICH, kpsewhich, no)
122    AC_PATH_PROG(DVIPS, dvips, no)
123    if test "${DVIPS}" = "no" -o "${KPSEWHICH}" = "no"; then
124      LATEX="no"
125    fi
126    if test "${LATEX}" != "no"; then
127      AC_MSG_CHECKING(for a4.sty and a4wide.sty)
128      if "${KPSEWHICH}" a4.sty >/dev/null 2>&1; then
129        if "${KPSEWHICH}" a4wide.sty >/dev/null 2>&1; then
130          AC_MSG_RESULT(yes)
131        else
132          LATEX="no"
133          AC_MSG_RESULT(no)
134        fi
135      else
136        LATEX="no"
137        AC_MSG_RESULT(no)
138      fi
139    fi
140    AC_PATH_PROG(DOT, dot, no)
141    if test "${DOT}" != "no"; then
142      USE_DOT="YES"
143    else
144      USE_DOT="NO"
145    fi
146  fi
147fi
148AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
149AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
150AM_CONDITIONAL(USE_DOT, test "${DOT}" != "no")
151
152
153dnl  No exceptions
154LOL_TRY_CXXFLAGS(-fno-exceptions, [AM_CXXFLAGS="${AM_CXXFLAGS} -fno-exceptions"])
155LOL_TRY_CXXFLAGS(-fno-rtti, [AM_CXXFLAGS="${AM_CXXFLAGS} -fno-rtti"])
156
157dnl  Optimizations
158AM_CXXFLAGS="${AM_CXXFLAGS} ${REL_CXXFLAGS} ${OPT_CXXFLAGS}"
159AM_LDFLAGS="${AM_LDFLAGS} ${REL_LDFLAGS} ${OPT_LDFLAGS}"
160
161dnl  Debug symbols
162LOL_TRY_LDFLAGS(-rdynamic, [AM_LDFLAGS="${AM_LDFLAGS} -rdynamic"])
163
164dnl  Code qui fait des warnings == code de porc == deux baffes dans ta gueule
165LOL_TRY_CXXFLAGS(-Wall, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wall"])
166LOL_TRY_CXXFLAGS(-Wextra, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wextra"])
167LOL_TRY_CXXFLAGS(-Wpointer-arith, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wpointer-arith"])
168LOL_TRY_CXXFLAGS(-Wcast-align, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-align"])
169LOL_TRY_CXXFLAGS(-Wcast-qual, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-qual"])
170LOL_TRY_CXXFLAGS(-Wshadow, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wshadow"])
171LOL_TRY_CXXFLAGS(-Wsign-compare, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wsign-compare"])
172
173dnl  Add these even though they're implicitly set, so that we can safely
174dnl  remove them from within a Makefile.
175LOL_TRY_CXXFLAGS(-Wmaybe-uninitialized, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wmaybe-uninitialized"])
176LOL_TRY_CXXFLAGS(-Wnarrowing, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wnarrowing"])
177LOL_TRY_CXXFLAGS(-Wunused, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wunused"])
178LOL_TRY_CXXFLAGS(-Wstrict-aliasing, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wstrict-aliasing"])
179LOL_TRY_CXXFLAGS(-Wparentheses, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wparentheses"])
180LOL_TRY_CXXFLAGS(-Wreorder, [AM_CXXFLAGS="${AM_CXXFLAGS} -Wreorder"])
181
182
183AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
184AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
185
186
187dnl  Unix-specific libutil
188AC_CHECK_LIB(util, forkpty,
189 [UTIL_LIBS="${UTIL_LIBS} -lutil"
190  dnl  Override future forkpty detection
191  ac_cv_func_forkpty="yes"])
192AC_CHECK_FUNCS(forkpty)
193
194
195dnl  GCC-specific symbol demangling
196AC_LANG_PUSH(C++)
197AC_TRY_LINK(
198 [#include <cxxabi.h>],
199 [abi::__cxa_demangle(NULL, 0, 0, NULL);],
200 [AC_DEFINE(HAVE_CXA_DEMANGLE, 1, Define to 1 if abi::__cxa_demangle is available)])
201AC_LANG_POP(C++)
202
203
204dnl  Are we on the PS3?
205ac_cv_my_have_ps3="no"
206AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
207 [ac_cv_my_have_ps3="yes"
208  LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
209  dnl  For PSGL
210  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
211  GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
212  dnl  This is the old way; we now use CELL_SDK instead of CELLSDK
213  if test "x${CELLSDK}" != x -a "x${CELL_SDK}" = x; then
214    CELL_SDK="${CELLSDK}"
215  fi
216  if test "x${enable_debug}" = xyes; then
217    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
218  elif test "x${enable_release}" = xyes; then
219    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
220  else
221    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
222  fi
223  dnl  For the runtime Cg compiler
224  GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
225  dnl  For the PNG decoder
226  LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
227  dnl  For the pad library
228  LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
229  dnl  Disable this warning, it's too verbose with vector.h
230  AM_CXXFLAGS="${AM_CXXFLAGS} -Wno-sign-compare"
231  AC_PATH_PROG(MAKE_FSELF, make_fself, no)
232  if test "${MAKE_FSELF}" = "no"; then
233    AC_MSG_ERROR([[Building for PS3 but make_fself not found]])
234  fi],
235 [MAKE_FSELF=no])
236AM_CONDITIONAL(USE_PS3, test "${ac_cv_my_have_ps3}" != "no")
237
238
239dnl  Are we building using MinGW?
240LOL_TRY_CXXFLAGS(-mwindows -mwin32,
241 [AM_CXXFLAGS="${AM_CXXFLAGS} -mwindows -mwin32"
242  LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16"])
243
244
245dnl  Are we on the Xbox 360?
246dnl  Answer: NO! we don't know how to build for it anyway
247AM_CONDITIONAL(USE_X360, false)
248
249
250dnl  Are we on an OS X or iOS platform?
251LOL_TRY_LDFLAGS(-framework Foundation,
252 [LOL_LIBS="${LOL_LIBS} -framework Foundation"])
253LOL_TRY_LDFLAGS(-framework CoreGraphics,
254 [LOL_LIBS="${LOL_LIBS} -framework CoreGraphics"])
255LOL_TRY_LDFLAGS(-framework CoreData,
256 [LOL_LIBS="${LOL_LIBS} -framework CoreData"])
257LOL_TRY_LDFLAGS(-framework UIKit,
258 [LOL_LIBS="${LOL_LIBS} -framework UIKit"])
259
260
261dnl Are we on a Direct3D 9 platform?
262#ac_cv_my_have_d3d9="no"
263#AC_CHECK_HEADERS(d3d9.h, [ac_cv_my_have_d3d9="yes"])
264#if test "${ac_cv_my_have_d3d9}" != "no"; then
265#  D3D_LIBS="${D3D_LIBS} -ld3d9 -ld3dx9 -lxinput"
266#  AC_DEFINE(USE_D3D9, 1, Define to 1 to use DirectX 9)
267#fi
268#AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no")
269
270LOL_CHECK_OPENGL
271
272LOL_CHECK_SDL
273
274dnl  Use Flex's FlexLexer.h or ours?
275ac_cv_my_have_flexlexer_h="no"
276AC_LANG_PUSH(C++)
277AC_CHECK_HEADERS(FlexLexer.h,
278 dnl  Ensure that FlexLexer::yleng is of type int, and not size_t like
279 dnl  on recent Apple systems. It would break all our existing code.
280 [AC_MSG_CHECKING(for FlexLexer.h validity)
281  AC_COMPILE_IFELSE(
282   [AC_LANG_PROGRAM([#include <FlexLexer.h>
283      class Foo : public FlexLexer
284      {
285          Foo() { int &test = yyleng; }
286      }],
287     [])],
288   [AC_MSG_RESULT(yes)
289    ac_cv_my_have_flexlexer_h="yes"],
290   [AC_MSG_RESULT(no)])])
291AC_LANG_POP(C++)
292if test "x${ac_cv_my_have_flexlexer_h}" = "xno"; then
293  LOL_CFLAGS="$LOL_CFLAGS -I\$(top_srcdir)/external/flex-2.5.35/include"
294fi
295
296
297dnl  Use NativeClient?
298ac_cv_my_have_nacl="no"
299AC_LANG_PUSH(C++)
300AC_CHECK_HEADERS(ppapi/cpp/instance.h,
301 [ac_cv_my_have_nacl="yes"
302  dnl  Disable this warning, it's too verbose with vector.h
303  AM_CXXFLAGS="${AM_CXXFLAGS} -Wno-sign-compare"])
304AC_LANG_POP(C++)
305AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
306
307
308dnl  Use Android? FIXME: super hacks!
309ac_cv_my_have_android="no"
310AC_CHECK_LIB(log, __android_log_vprint,
311 [ac_cv_my_have_android="yes"
312  LOL_LIBS="${LOL_LIBS} -llog -module"])
313AM_CONDITIONAL(USE_ANDROID, test "${ac_cv_my_have_android}" != "no")
314
315
316dnl  Use EGL?
317ac_cv_my_have_egl="no"
318PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
319if test "${ac_cv_my_have_egl}" != "no"; then
320  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
321  EGL_LIBS="${EGL_LIBS} -lX11"
322fi
323AC_CHECK_LIB(EGL, main,
324 [ac_cv_my_have_egl="yes"
325  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
326  EGL_LIBS="-lEGL"])
327dnl  Raspberry Pi is different, check for it with extra libs; also we
328dnl  look for a different function to bypass autoconf caching
329AC_CHECK_LIB(EGL, eglGetDisplay,
330 [ac_cv_my_have_egl="yes"
331  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
332  EGL_LIBS="-lEGL -lvcos -lvchiq_arm -lbcm_host -lGLESv2"],
333 [:],
334 [-lvcos -lvchiq_arm -lbcm_host -lGLESv2])
335AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
336
337
338dnl Use libpng? (replacement for SDL_image)
339ac_cv_my_have_libpng="no"
340PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
341if test "${ac_cv_my_have_libpng}" != "no"; then
342  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
343fi
344AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
345
346
347dnl Use Windows GDI+?
348ac_cv_my_have_gdiplus="no"
349AC_LANG_PUSH(C++)
350AC_CHECK_HEADERS(gdiplus.h,
351 [ac_cv_my_have_gdiplus="yes"
352  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
353 [ac_cv_my_have_gdiplus="no"],
354 [#include <algorithm>
355  using std::min;
356  using std::max;
357  #include <windows.h>])
358AC_LANG_POP(C++)
359if test "${ac_cv_my_have_gdiplus}" != "no"; then
360  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
361fi
362AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
363
364
365dnl Use libcaca? (required for font generation)
366ac_cv_my_have_caca="no"
367PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
368if test "${ac_cv_my_have_caca}" != "no"; then
369  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
370fi
371AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
372
373
374dnl Use libpipi? (required for video recording)
375ac_cv_my_have_pipi="no"
376PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
377if test "${ac_cv_my_have_pipi}" != "no"; then
378  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
379  LOL_CFLAGS="${LOL_CFLAGS} ${PIPI_CFLAGS}"
380  LOL_LIBS="${LOL_LIBS} ${PIPI_LIBS}"
381fi
382AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
383
384
385dnl Use GTK+? (required for the deushax editor)
386ac_cv_my_have_gtkgl="no"
387PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
388PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
389if test "${ac_cv_my_have_gtkgl}" != "no"; then
390  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
391fi
392AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
393
394
395dnl  Can we build neercs?
396AM_CONDITIONAL(BUILD_NEERCS, test "${ac_cv_my_have_caca}" != "no")
397
398
399dnl  Extra libraries we may need
400AC_SUBST(MATH_LIBS)
401AC_SUBST(PAM_LIBS)
402AC_SUBST(UTIL_LIBS)
403
404dnl  How to use the Lol Engine outside this tree
405LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
406LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
407LOL_DEPS="${LOL_DEPS} \$(top_builddir)/src/liblolcore.a"
408LOL_DEPS="${LOL_DEPS} \$(top_builddir)/src/bullet/liblolbullet.a"
409LOL_DEPS="${LOL_DEPS} \$(top_builddir)/src/lua/liblollua.a"
410
411dnl  How to use the Lol Engine inside this tree
412AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(top_srcdir)/src"
413AM_CPPFLAGS="${AM_CPPFLAGS} -DLOL_CONFIG_SOURCESUBDIR=\\\"\$(subdir)\\\""
414AM_CPPFLAGS="${AM_CPPFLAGS} ${LOL_CFLAGS}"
415AM_LDFLAGS="${AM_LDFLAGS} ${LOL_DEPS}"
416AM_LDFLAGS="${AM_LDFLAGS} ${LOL_LIBS}"
417
418dnl  Extra flags
419AC_SUBST(LOL_CFLAGS)
420AC_SUBST(LOL_LIBS)
421AC_SUBST(LOL_DEPS)
422
423AC_SUBST(AM_CFLAGS)
424AC_SUBST(AM_CPPFLAGS)
425AC_SUBST(AM_CXXFLAGS)
426AC_SUBST(AM_LDFLAGS)
427
428AC_SUBST(USE_DOT)
429
430AC_CONFIG_FILES(
431 [Makefile
432  src/Makefile
433  src/bullet/Makefile
434  src/lua/Makefile
435  src/data/Makefile
436  src/data/font/Makefile
437  tutorial/Makefile
438  test/Makefile
439  test/math/Makefile
440  test/sandbox/Makefile
441  test/xolotl/Makefile
442  build/Makefile
443  binaries/Makefile
444  people/Makefile
445  games/Makefile
446  tools/Makefile
447  tools/vimlol/Makefile
448  tools/vslol/Makefile
449  doc/Makefile
450  doc/doxygen.cfg
451])
452AC_CONFIG_FILES(
453 [games/monsterz/Makefile
454])
455AC_CONFIG_FILES(
456 [games/deushax/Makefile
457  games/deushax/art/Makefile
458  games/deushax/art/test/Makefile
459  games/deushax/gfx/Makefile
460  games/deushax/maps/Makefile
461])
462AC_CONFIG_FILES(
463 [games/mrpigeon/Makefile
464])
465AC_CONFIG_FILES(
466 [games/orbital/Makefile
467])
468AC_CONFIG_FILES(
469 [tools/neercs/Makefile
470])
471AC_CONFIG_FILES(
472 [people/jnat/Makefile
473  people/jnat/TestProject/Makefile
474  people/peeweek/Makefile
475  people/peeweek/private/Makefile
476  people/touky/Makefile
477  people/touky/private/Makefile
478  people/touky/private/tactics/Makefile
479  people/jylam/Makefile
480  people/jylam/private/Makefile
481  people/jylam/private/chat/Makefile
482])
483
484AC_OUTPUT
485
Note: See TracBrowser for help on using the repository browser.