source: trunk/configure.ac @ 2435

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

sys: add the base source directory to the list of search directories
on automake platforms, too.

File size: 13.4 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(-Wmaybe-uninitialized, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wmaybe-uninitialized"])
162LOL_TRY_CXXFLAGS(-Wnarrowing, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wnarrowing"])
163LOL_TRY_CXXFLAGS(-Wunused, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wunused"])
164LOL_TRY_CXXFLAGS(-Wstrict-aliasing, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wstrict-aliasing"])
165LOL_TRY_CXXFLAGS(-Wreorder, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wreorder"])
166LOL_TRY_CXXFLAGS(-Wparentheses, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wparentheses"])
167
168
169AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
170AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
171
172AC_CHECK_LIB(util, forkpty,
173 [UTIL_LIBS="${UTIL_LIBS} -lutil"
174  dnl  Override future forkpty detection
175  ac_cv_func_forkpty="yes"])
176AC_CHECK_FUNCS(forkpty)
177
178dnl Are we on the PS3?
179ac_cv_my_have_ps3="no"
180AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
181 [ac_cv_my_have_ps3="yes"
182  LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
183  dnl  For PSGL
184  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
185  GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
186  dnl  This is the old way; we now use CELL_SDK instead of CELLSDK
187  if test "x${CELLSDK}" != x -a "x${CELL_SDK}" = x; then
188    CELL_SDK="${CELLSDK}"
189  fi
190  if test "x${enable_debug}" = xyes; then
191    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
192  elif test "x${enable_release}" = xyes; then
193    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
194  else
195    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
196  fi
197  dnl  For the runtime Cg compiler
198  GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
199  dnl  For the PNG decoder
200  LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
201  dnl  For the pad library
202  LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
203  dnl  Disable this warning, it's too verbose with vector.h
204  AM_CXXFLAGS="${AM_CXXFLAGS} -Wno-sign-compare"
205  AC_PATH_PROG(MAKE_FSELF, make_fself, no)
206  if test "${MAKE_FSELF}" = "no"; then
207    AC_MSG_ERROR([[Building for PS3 but make_fself not found]])
208  fi],
209 [MAKE_FSELF=no])
210AM_CONDITIONAL(USE_PS3, test "${ac_cv_my_have_ps3}" != "no")
211
212
213dnl  Are we building using MinGW?
214LIBS_save="$LIBS"
215LIBS="$LIBS -mwindows -mwin32"
216AC_MSG_CHECKING(for -mwindows -mwin32)
217AC_TRY_LINK([], [],
218 [AC_MSG_RESULT(yes)
219  AM_CXXFLAGS="${AM_CXXFLAGS} -mwindows -mwin32"
220  LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16"],
221 [AC_MSG_RESULT(no)])
222LIBS="$LIBS_save"
223
224
225dnl  Are we on the Xbox 360?
226dnl  Answer: NO! we don't know how to build for it anyway
227AM_CONDITIONAL(USE_X360, false)
228
229
230dnl Are we on a Direct3D 9 platform?
231#ac_cv_my_have_d3d9="no"
232#AC_CHECK_HEADERS(d3d9.h, [ac_cv_my_have_d3d9="yes"])
233#if test "${ac_cv_my_have_d3d9}" != "no"; then
234#  D3D_LIBS="${D3D_LIBS} -ld3d9 -ld3dx9 -lxinput"
235#  AC_DEFINE(USE_D3D9, 1, Define to 1 to use DirectX 9)
236#fi
237#AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no")
238
239LOL_CHECK_OPENGL
240
241LOL_CHECK_SDL
242
243dnl  Use Flex's FlexLexer.h or ours?
244ac_cv_my_have_flexlexer_h="no"
245AC_LANG_PUSH(C++)
246AC_CHECK_HEADERS(FlexLexer.h,
247 dnl  Ensure that FlexLexer::yleng is of type int, and not size_t like
248 dnl  on recent Apple systems. It would break all our existing code.
249 [AC_MSG_CHECKING(for FlexLexer.h validity)
250  AC_COMPILE_IFELSE(
251   [AC_LANG_PROGRAM([#include <FlexLexer.h>
252      class Foo : public FlexLexer
253      {
254          Foo() { int &test = yyleng; }
255      }],
256     [])],
257   [AC_MSG_RESULT(yes)
258    ac_cv_my_have_flexlexer_h="yes"],
259   [AC_MSG_RESULT(no)])])
260AC_LANG_POP(C++)
261if test "x${ac_cv_my_have_flexlexer_h}" = "xno"; then
262  LOL_CFLAGS="$LOL_CFLAGS -I\$(top_srcdir)/external/flex-2.5.35/include"
263fi
264
265
266dnl  Use NativeClient?
267ac_cv_my_have_nacl="no"
268AC_LANG_PUSH(C++)
269AC_CHECK_HEADERS(ppapi/cpp/instance.h,
270 [ac_cv_my_have_nacl="yes"
271  dnl  Disable this warning, it's too verbose with vector.h
272  AM_CXXFLAGS="${AM_CXXFLAGS} -Wno-sign-compare"])
273AC_LANG_POP(C++)
274AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
275
276
277dnl  Use Android? FIXME: super hacks!
278ac_cv_my_have_android="no"
279AC_CHECK_LIB(log, __android_log_vprint,
280 [ac_cv_my_have_android="yes"
281  LOL_LIBS="${LOL_LIBS} -llog -module"])
282AM_CONDITIONAL(USE_ANDROID, test "${ac_cv_my_have_android}" != "no")
283
284
285dnl  Use EGL?
286ac_cv_my_have_egl="no"
287PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
288if test "${ac_cv_my_have_egl}" != "no"; then
289  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
290  EGL_LIBS="${EGL_LIBS} -lX11"
291fi
292AC_CHECK_LIB(EGL, main,
293 [ac_cv_my_have_egl="yes"
294  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
295  EGL_LIBS="-lEGL"])
296dnl  Raspberry Pi is different, check for it with extra libs; also we
297dnl  look for a different function to bypass autoconf caching
298AC_CHECK_LIB(EGL, eglGetDisplay,
299 [ac_cv_my_have_egl="yes"
300  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
301  EGL_LIBS="-lEGL -lvcos -lvchiq_arm -lbcm_host -lGLESv2"],
302 [:],
303 [-lvcos -lvchiq_arm -lbcm_host -lGLESv2])
304AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
305
306
307dnl Use libpng? (replacement for SDL_image)
308ac_cv_my_have_libpng="no"
309PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
310if test "${ac_cv_my_have_libpng}" != "no"; then
311  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
312fi
313AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
314
315
316dnl Use Windows GDI+?
317ac_cv_my_have_gdiplus="no"
318AC_LANG_PUSH(C++)
319AC_CHECK_HEADERS(gdiplus.h,
320 [ac_cv_my_have_gdiplus="yes"
321  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
322 [ac_cv_my_have_gdiplus="no"],
323 [#include <algorithm>
324  using std::min;
325  using std::max;
326  #include <windows.h>])
327AC_LANG_POP(C++)
328if test "${ac_cv_my_have_gdiplus}" != "no"; then
329  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
330fi
331AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
332
333
334dnl Use libcaca? (required for font generation)
335ac_cv_my_have_caca="no"
336PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
337if test "${ac_cv_my_have_caca}" != "no"; then
338  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
339fi
340AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
341
342
343dnl Use libpipi? (required for video recording)
344ac_cv_my_have_pipi="no"
345PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
346if test "${ac_cv_my_have_pipi}" != "no"; then
347  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
348  LOL_CFLAGS="${LOL_CFLAGS} ${PIPI_CFLAGS}"
349  LOL_LIBS="${LOL_LIBS} ${PIPI_LIBS}"
350fi
351AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
352
353
354dnl Use GTK+? (required for the deushax editor)
355ac_cv_my_have_gtkgl="no"
356PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
357PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
358if test "${ac_cv_my_have_gtkgl}" != "no"; then
359  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
360fi
361AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
362
363
364dnl  Can we build neercs?
365AM_CONDITIONAL(BUILD_NEERCS, test "${ac_cv_my_have_caca}" != "no")
366
367
368dnl  Extra libraries we may need
369AC_SUBST(MATH_LIBS)
370AC_SUBST(PAM_LIBS)
371AC_SUBST(UTIL_LIBS)
372
373dnl  How to use the Lol Engine outside this tree
374LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
375LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
376LOL_DEPENDENCIES="${LOL_DEPENDENCIES} \$(top_builddir)/src/liblolcore.a"
377LOL_DEPENDENCIES="${LOL_DEPENDENCIES} \$(top_builddir)/src/bullet/liblolbullet.a"
378
379dnl  How to use the Lol Engine inside this tree
380AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(top_srcdir)/src"
381AM_CPPFLAGS="${AM_CPPFLAGS} -DLOL_CONFIG_SOURCESUBDIR=\\\"\$(subdir)\\\""
382AM_CPPFLAGS="${AM_CPPFLAGS} ${LOL_CFLAGS}"
383AM_LDFLAGS="${AM_LDFLAGS} ${LOL_DEPENDENCIES}"
384AM_LDFLAGS="${AM_LDFLAGS} ${LOL_LIBS}"
385
386dnl  Extra flags
387AC_SUBST(LOL_CFLAGS)
388AC_SUBST(LOL_LIBS)
389AC_SUBST(LOL_DEPENDENCIES)
390
391AC_SUBST(AM_CFLAGS)
392AC_SUBST(AM_CPPFLAGS)
393AC_SUBST(AM_CXXFLAGS)
394AC_SUBST(AM_LDFLAGS)
395
396AC_SUBST(USE_DOT)
397
398AC_CONFIG_FILES(
399 [Makefile
400  src/Makefile
401  src/bullet/Makefile
402  src/data/Makefile
403  src/data/font/Makefile
404  tutorial/Makefile
405  test/Makefile
406  test/math/Makefile
407  test/sandbox/Makefile
408  test/xolotl/Makefile
409  build/Makefile
410  binaries/Makefile
411  people/Makefile
412  games/Makefile
413  tools/Makefile
414  tools/vimlol/Makefile
415  tools/vslol/Makefile
416  doc/Makefile
417  doc/doxygen.cfg
418])
419AC_CONFIG_FILES(
420 [games/monsterz/Makefile
421])
422AC_CONFIG_FILES(
423 [games/deushax/Makefile
424  games/deushax/art/Makefile
425  games/deushax/art/test/Makefile
426  games/deushax/gfx/Makefile
427  games/deushax/maps/Makefile
428])
429AC_CONFIG_FILES(
430 [games/mrpigeon/Makefile
431])
432AC_CONFIG_FILES(
433 [games/orbital/Makefile
434])
435AC_CONFIG_FILES(
436 [tools/neercs/Makefile
437])
438AC_CONFIG_FILES(
439 [people/jnat/Makefile
440  people/jnat/TestProject/Makefile
441  people/peeweek/Makefile
442  people/peeweek/private/Makefile
443  people/touky/Makefile
444  people/touky/private/Makefile
445  people/jylam/Makefile
446  people/jylam/private/Makefile
447  people/jylam/private/chat/Makefile
448])
449
450AC_OUTPUT
451
Note: See TracBrowser for help on using the repository browser.