source: trunk/configure.ac @ 2273

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

build: use our own main() wrapper in addition to SDL's, and only
in that case. Currently only works with GCC.

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