source: trunk/configure.ac @ 2174

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