source: trunk/configure.ac @ 2395

Last change on this file since 2395 was 2395, checked in by sam, 7 years ago

build: better check for compiler flags; we no longer try to use
flags that autoconf hasn’t checked first.

File size: 13.0 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
64AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
65dnl conditional builds
66AC_ARG_ENABLE(debug,
67  [  --enable-debug          build debug versions of the game (default no)])
68AC_ARG_ENABLE(release,
69  [  --enable-release        build final release of the game (default no)])
70AC_ARG_ENABLE(experimental,
71  [  --enable-experimental   experimental build (default no)])
72AC_ARG_ENABLE(doc,
73  [  --enable-doc            build documentation (needs doxygen and LaTeX)])
74
75AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
76AC_CHECK_HEADERS(fastmath.h pthread.h libutil.h util.h pty.h glob.h unistd.h)
77AC_CHECK_HEADERS(sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h)
78AC_CHECK_HEADERS(sys/wait.h)
79AC_CHECK_HEADERS(linux/kdev_t.h linux/major.h)
80AC_CHECK_HEADERS(security/pam_appl.h security/pam_misc.h)
81AC_CHECK_HEADERS(pam/pam_appl.h pam/pam_misc.h)
82
83AC_CHECK_FUNCS(getcwd _getcwd)
84
85if test "${enable_debug}" = "yes"; then
86  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
87  OPT="-O"
88else
89  OPT="-O3 -ffast-math -fno-strength-reduce -fomit-frame-pointer"
90fi
91
92if test "${enable_release}" = "yes"; then
93  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
94  REL=""
95else
96  REL="-g"
97fi
98
99if test "${enable_experimental}" = "yes"; then
100  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
101fi
102
103# Build documentation?
104DOXYGEN="no"
105LATEX="no"
106if test "${enable_doc}" != "no"; then
107  AC_PATH_PROG(DOXYGEN, doxygen, no)
108  if test "${DOXYGEN}" != "no"; then
109    # Build LaTeX documentation?
110    AC_PATH_PROG(LATEX, pdflatex, no)
111    AC_PATH_PROG(KPSEWHICH, kpsewhich, no)
112    AC_PATH_PROG(DVIPS, dvips, no)
113    if test "${DVIPS}" = "no" -o "${KPSEWHICH}" = "no"; then
114      LATEX="no"
115    fi
116    if test "${LATEX}" != "no"; then
117      AC_MSG_CHECKING(for a4.sty and a4wide.sty)
118      if "${KPSEWHICH}" a4.sty >/dev/null 2>&1; then
119        if "${KPSEWHICH}" a4wide.sty >/dev/null 2>&1; then
120          AC_MSG_RESULT(yes)
121        else
122          LATEX="no"
123          AC_MSG_RESULT(no)
124        fi
125      else
126        LATEX="no"
127        AC_MSG_RESULT(no)
128      fi
129    fi
130    AC_PATH_PROG(DOT, dot, no)
131    if test "${DOT}" != "no"; then
132      USE_DOT="YES"
133    else
134      USE_DOT="NO"
135    fi
136  fi
137fi
138AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
139AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
140AM_CONDITIONAL(USE_DOT, test "${DOT}" != "no")
141
142
143dnl  No exceptions
144LOL_TRY_CXXFLAGS(-fno-exceptions, [AM_CXXFLAGS="${AM_CXXFLAGS} -fno-exceptions"])
145LOL_TRY_CXXFLAGS(-fno-rtti, [AM_CXXFLAGS="${AM_CXXFLAGS} -fno-rtti"])
146
147dnl  Optimizations
148AM_CXXFLAGS="${AM_CXXFLAGS} ${REL} ${OPT}"
149
150dnl  Code qui fait des warnings == code de porc == deux baffes dans ta gueule
151LOL_TRY_CXXFLAGS(-Wall, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wall"])
152LOL_TRY_CXXFLAGS(-Wextra, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wextra"])
153LOL_TRY_CXXFLAGS(-Wpointer-arith, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wpointer-arith"])
154LOL_TRY_CXXFLAGS(-Wcast-align, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-align"])
155LOL_TRY_CXXFLAGS(-Wcast-qual, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-qual"])
156LOL_TRY_CXXFLAGS(-Wshadow, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wshadow"])
157LOL_TRY_CXXFLAGS(-Wsign-compare, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wsign-compare"])
158
159dnl  Add these even though they're implicitly set, so that we can safely
160dnl  remove them from within a Makefile.
161LOL_TRY_CXXFLAGS(-Wno-maybe-uninitialized, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wno-maybe-uninitialized"])
162LOL_TRY_CXXFLAGS(-Wno-narrowing, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wno-narrowing"])
163
164
165AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
166AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
167
168AC_CHECK_LIB(util, forkpty,
169 [UTIL_LIBS="${UTIL_LIBS} -lutil"
170  dnl  Override future forkpty detection
171  ac_cv_func_forkpty="yes"])
172AC_CHECK_FUNCS(forkpty)
173
174dnl Are we on the PS3?
175ac_cv_my_have_ps3="no"
176AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
177 [ac_cv_my_have_ps3="yes"
178  LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
179  dnl  For PSGL
180  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
181  GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
182  dnl  This is the old way; we now use CELL_SDK instead of CELLSDK
183  if test "x${CELLSDK}" != x -a "x${CELL_SDK}" = x; then
184    CELL_SDK="${CELLSDK}"
185  fi
186  if test "x${enable_debug}" = xyes; then
187    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
188  elif test "x${enable_release}" = xyes; then
189    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
190  else
191    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
192  fi
193  dnl  For the runtime Cg compiler
194  GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
195  dnl  For the PNG decoder
196  LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
197  dnl  For the pad library
198  LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
199  dnl  Disable this warning, it's too verbose with vector.h
200  AM_CXXFLAGS="${AM_CXXFLAGS} -Wno-sign-compare"
201  AC_PATH_PROG(MAKE_FSELF, make_fself, no)
202  if test "${MAKE_FSELF}" = "no"; then
203    AC_MSG_ERROR([[Building for PS3 but make_fself not found]])
204  fi],
205 [MAKE_FSELF=no])
206AM_CONDITIONAL(USE_PS3, test "${ac_cv_my_have_ps3}" != "no")
207
208
209dnl  Are we building using MinGW?
210LIBS_save="$LIBS"
211LIBS="$LIBS -mwindows -mwin32"
212AC_MSG_CHECKING(for -mwindows -mwin32)
213AC_TRY_LINK([], [],
214 [AC_MSG_RESULT(yes)
215  AM_CXXFLAGS="${AM_CXXFLAGS} -mwindows -mwin32"
216  LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16"],
217 [AC_MSG_RESULT(no)])
218LIBS="$LIBS_save"
219
220
221dnl  Are we on the Xbox 360?
222dnl  Answer: NO! we don't know how to build for it anyway
223AM_CONDITIONAL(USE_X360, false)
224
225
226dnl Are we on a Direct3D 9 platform?
227#ac_cv_my_have_d3d9="no"
228#AC_CHECK_HEADERS(d3d9.h, [ac_cv_my_have_d3d9="yes"])
229#if test "${ac_cv_my_have_d3d9}" != "no"; then
230#  D3D_LIBS="${D3D_LIBS} -ld3d9 -ld3dx9 -lxinput"
231#  AC_DEFINE(USE_D3D9, 1, Define to 1 to use DirectX 9)
232#fi
233#AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no")
234
235LOL_CHECK_OPENGL
236
237LOL_CHECK_SDL
238
239dnl  Use Flex's FlexLexer.h or ours?
240ac_cv_my_have_flexlexer_h="no"
241AC_LANG_PUSH(C++)
242AC_CHECK_HEADERS(FlexLexer.h,
243 dnl  Ensure that FlexLexer::yleng is of type int, and not size_t like
244 dnl  on recent Apple systems. It would break all our existing code.
245 [AC_MSG_CHECKING(for FlexLexer.h validity)
246  AC_COMPILE_IFELSE(
247   [AC_LANG_PROGRAM([#include <FlexLexer.h>
248      class Foo : public FlexLexer
249      {
250          Foo() { int &test = yyleng; }
251      }],
252     [])],
253   [AC_MSG_RESULT(yes)
254    ac_cv_my_have_flexlexer_h="yes"],
255   [AC_MSG_RESULT(no)])])
256AC_LANG_POP(C++)
257if test "x${ac_cv_my_have_flexlexer_h}" = "xno"; then
258  LOL_CFLAGS="$LOL_CFLAGS -I\$(top_srcdir)/external/flex-2.5.35/include"
259fi
260
261
262dnl  Use NativeClient?
263ac_cv_my_have_nacl="no"
264AC_LANG_PUSH(C++)
265AC_CHECK_HEADERS(ppapi/cpp/instance.h,
266 [ac_cv_my_have_nacl="yes"
267  dnl  Disable this warning, it's too verbose with vector.h
268  AM_CXXFLAGS="${AM_CXXFLAGS} -Wno-sign-compare"])
269AC_LANG_POP(C++)
270AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
271
272
273dnl  Use Android? FIXME: super hacks!
274ac_cv_my_have_android="no"
275AC_CHECK_LIB(log, __android_log_vprint,
276 [ac_cv_my_have_android="yes"
277  LOL_LIBS="${LOL_LIBS} -llog -module"])
278AM_CONDITIONAL(USE_ANDROID, test "${ac_cv_my_have_android}" != "no")
279
280
281dnl  Use EGL?
282ac_cv_my_have_egl="no"
283PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
284if test "${ac_cv_my_have_egl}" != "no"; then
285  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
286  EGL_LIBS="${EGL_LIBS} -lX11"
287fi
288AC_CHECK_LIB(EGL, main,
289 [ac_cv_my_have_egl="yes"
290  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
291  EGL_LIBS="-lEGL"])
292dnl  Raspberry Pi is different, check for it with extra libs; also we
293dnl  look for a different function to bypass autoconf caching
294AC_CHECK_LIB(EGL, eglGetDisplay,
295 [ac_cv_my_have_egl="yes"
296  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
297  EGL_LIBS="-lEGL -lvcos -lvchiq_arm -lbcm_host -lGLESv2"],
298 [:],
299 [-lvcos -lvchiq_arm -lbcm_host -lGLESv2])
300AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
301
302
303dnl Use libpng? (replacement for SDL_image)
304ac_cv_my_have_libpng="no"
305PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
306if test "${ac_cv_my_have_libpng}" != "no"; then
307  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
308fi
309AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
310
311
312dnl Use Windows GDI+?
313ac_cv_my_have_gdiplus="no"
314AC_LANG_PUSH(C++)
315AC_CHECK_HEADERS(gdiplus.h,
316 [ac_cv_my_have_gdiplus="yes"
317  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
318 [ac_cv_my_have_gdiplus="no"],
319 [#include <algorithm>
320  using std::min;
321  using std::max;
322  #include <windows.h>])
323AC_LANG_POP(C++)
324if test "${ac_cv_my_have_gdiplus}" != "no"; then
325  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
326fi
327AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
328
329
330dnl Use libcaca? (required for font generation)
331ac_cv_my_have_caca="no"
332PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
333if test "${ac_cv_my_have_caca}" != "no"; then
334  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
335fi
336AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
337
338
339dnl Use libpipi? (required for video recording)
340ac_cv_my_have_pipi="no"
341PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
342if test "${ac_cv_my_have_pipi}" != "no"; then
343  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
344  LOL_CFLAGS="${LOL_CFLAGS} ${PIPI_CFLAGS}"
345  LOL_LIBS="${LOL_LIBS} ${PIPI_LIBS}"
346fi
347AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
348
349
350dnl Use GTK+? (required for the deushax editor)
351ac_cv_my_have_gtkgl="no"
352PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
353PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
354if test "${ac_cv_my_have_gtkgl}" != "no"; then
355  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
356fi
357AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
358
359
360dnl  Can we build neercs?
361AM_CONDITIONAL(BUILD_NEERCS, test "${ac_cv_my_have_caca}" != "no")
362
363
364dnl  Extra libraries we may need
365AC_SUBST(MATH_LIBS)
366AC_SUBST(PAM_LIBS)
367AC_SUBST(UTIL_LIBS)
368
369dnl  How to use the Lol Engine outside this tree
370LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
371LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
372
373dnl  How to use the Lol Engine inside this tree
374AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(top_srcdir)/src"
375AM_CPPFLAGS="${AM_CPPFLAGS} -DLOL_SOURCE_SUBDIR=\\\"\$(subdir)\\\""
376AM_CPPFLAGS="${AM_CPPFLAGS} $LOL_CFLAGS"
377AM_LDFLAGS="${AM_LDFLAGS} \$(top_builddir)/src/liblolcore.a"
378AM_LDFLAGS="${AM_LDFLAGS} \$(top_builddir)/src/bullet/liblolbullet.a"
379AM_LDFLAGS="${AM_LDFLAGS} $LOL_LIBS"
380
381dnl  Extra flags
382AC_SUBST(LOL_CFLAGS)
383AC_SUBST(LOL_LIBS)
384
385AC_SUBST(AM_CFLAGS)
386AC_SUBST(AM_CPPFLAGS)
387AC_SUBST(AM_CXXFLAGS)
388AC_SUBST(AM_LDFLAGS)
389
390AC_SUBST(USE_DOT)
391
392AC_CONFIG_FILES(
393 [Makefile
394  src/Makefile
395  src/bullet/Makefile
396  src/data/Makefile
397  src/data/font/Makefile
398  tutorial/Makefile
399  test/Makefile
400  test/math/Makefile
401  test/sandbox/Makefile
402  test/xolotl/Makefile
403  build/Makefile
404  binaries/Makefile
405  people/Makefile
406  games/Makefile
407  tools/Makefile
408  tools/vimlol/Makefile
409  tools/vslol/Makefile
410  doc/Makefile
411  doc/doxygen.cfg
412])
413AC_CONFIG_FILES(
414 [games/monsterz/Makefile
415])
416AC_CONFIG_FILES(
417 [games/deushax/Makefile
418  games/deushax/art/Makefile
419  games/deushax/art/test/Makefile
420  games/deushax/gfx/Makefile
421  games/deushax/maps/Makefile
422])
423AC_CONFIG_FILES(
424 [games/mrpigeon/Makefile
425])
426AC_CONFIG_FILES(
427 [games/orbital/Makefile
428])
429AC_CONFIG_FILES(
430 [tools/neercs/Makefile
431])
432AC_CONFIG_FILES(
433 [people/jnat/Makefile
434  people/jnat/TestProject/Makefile
435  people/peeweek/Makefile
436  people/peeweek/private/Makefile
437  people/touky/Makefile
438  people/touky/private/Makefile
439  people/jylam/Makefile
440  people/jylam/private/Makefile
441  people/jylam/private/chat/Makefile
442])
443
444AC_OUTPUT
445
Note: See TracBrowser for help on using the repository browser.