source: trunk/configure.ac @ 2071

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

vimlol: some code for a Vim plugin; see http://lol.zoy.org/wiki/dev/setup/vim

File size: 12.6 KB
RevLine 
[700]1dnl configure script for Lol Engine
[92]2
[221]3AC_INIT(lolengine, 0.0)
[92]4AC_PREREQ(2.50)
5AC_CONFIG_AUX_DIR(.auto)
6AC_CANONICAL_SYSTEM
[1388]7AM_INIT_AUTOMAKE([subdir-objects no-define tar-ustar silent-rules])
[92]8dnl AM_MAINTAINER_MODE
[1939]9AM_DEFAULT_VERBOSITY=0
[92]10
[938]11dnl Versioning of the separate software we ship
12LOLUNIT_VERSION=0.1
13AC_SUBST(LOLUNIT_VERSION)
[1129]14LOLREMEZ_VERSION=0.2
[1119]15AC_SUBST(LOLREMEZ_VERSION)
[938]16
[92]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
[623]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
[1984]37dnl  Same for Lol Engine M4 files.
38m4_pattern_forbid([^LOL_])
39
40
[623]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
[92]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
[2036]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
[1036]64AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
[92]65dnl conditional builds
66AC_ARG_ENABLE(debug,
[97]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)])
[658]70AC_ARG_ENABLE(experimental,
71  [  --enable-experimental   experimental build (default no)])
[92]72
[1505]73AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
[1643]74AC_CHECK_HEADERS(fastmath.h pthread.h libutil.h util.h pty.h glob.h)
[1505]75AC_CHECK_HEADERS(sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h)
76AC_CHECK_HEADERS(sys/wait.h)
77AC_CHECK_HEADERS(linux/kdev_t.h linux/major.h)
78AC_CHECK_HEADERS(security/pam_appl.h security/pam_misc.h)
[1642]79AC_CHECK_HEADERS(pam/pam_appl.h pam/pam_misc.h)
[92]80
[421]81if test "${enable_debug}" = "yes"; then
[658]82  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
[693]83  OPT="-O"
[644]84else
[884]85  OPT="-O3 -ffast-math -fno-strength-reduce -fomit-frame-pointer"
[421]86fi
87
[644]88if test "${enable_release}" = "yes"; then
[658]89  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
[644]90  REL=""
91else
92  REL="-g"
93fi
94
[658]95if test "${enable_experimental}" = "yes"; then
96  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
97fi
98
[840]99dnl No exceptions
[935]100CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
[700]101dnl Optimizations
[693]102CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
[700]103dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
[92]104CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
105
106AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
[1093]107AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
[1505]108AC_CHECK_LIB(util, forkpty, UTIL_LIBS="${UTIL_LIBS} -lutil")
[92]109
[840]110dnl Are we on the PS3?
[1563]111ac_cv_my_have_ps3="no"
[840]112AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
[1563]113 [ac_cv_my_have_ps3="yes"
114  LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
[840]115  dnl  For PSGL
116  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
117  GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
[1959]118  dnl  This is the old way; we now use CELL_SDK instead of CELLSDK
119  if test "x${CELLSDK}" != x -a "x${CELL_SDK}" = x; then
[1533]120    CELL_SDK="${CELLSDK}"
121  fi
[840]122  if test "x${enable_debug}" = xyes; then
[1533]123    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
[840]124  elif test "x${enable_release}" = xyes; then
[1533]125    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
[840]126  else
[1533]127    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
[840]128  fi
129  dnl  For the runtime Cg compiler
130  GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
131  dnl  For the PNG decoder
132  LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
133  dnl  For the pad library
134  LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
[1288]135  dnl  Disable this warning, it's too verbose with vector.h
136  CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"
[1981]137  AC_PATH_PROG(MAKE_FSELF, make_fself, no)
138  if test "${MAKE_FSELF}" = "no"; then
139    AC_MSG_ERROR([[Building for PS3 but make_fself not found]])
140  fi],
[844]141 [MAKE_FSELF=no])
[1563]142AM_CONDITIONAL(USE_PS3, test "${ac_cv_my_have_ps3}" != "no")
[840]143
144
[1647]145dnl  Are we building using MinGW?
146LIBS_save="$LIBS"
[1653]147LIBS="$LIBS -mwindows -mwin32"
148AC_MSG_CHECKING(for -mwindows -mwin32)
[1647]149AC_TRY_LINK([], [],
150 [AC_MSG_RESULT(yes)
[1653]151  CXXFLAGS="${CXXFLAGS} -mwindows -mwin32"
152  LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16"],
[1647]153 [AC_MSG_RESULT(no)])
154LIBS="$LIBS_save"
155
156
[1563]157dnl  Are we on the Xbox 360?
158dnl  Answer: NO! we don't know how to build for it anyway
159AM_CONDITIONAL(USE_X360, false)
160
161
[1212]162dnl Are we on a Direct3D 9 platform?
[1485]163#ac_cv_my_have_d3d9="no"
164#AC_CHECK_HEADERS(d3d9.h, [ac_cv_my_have_d3d9="yes"])
165#if test "${ac_cv_my_have_d3d9}" != "no"; then
166#  D3D_LIBS="${D3D_LIBS} -ld3d9 -ld3dx9 -lxinput"
167#  AC_DEFINE(USE_D3D9, 1, Define to 1 to use DirectX 9)
168#fi
169#AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no")
[1212]170
[1984]171LOL_CHECK_OPENGL
[1212]172
[1670]173
[840]174dnl Use SDL? (always required on Linux or Win32)
[848]175ac_cv_my_have_sdl="no"
[949]176ac_cv_my_have_sdl_image="no"
177ac_cv_my_have_sdl_mixer="no"
178dnl
179dnl  First, try the proper pkg-config check
180PKG_CHECK_MODULES(SDL, sdl, [ac_cv_my_have_sdl="yes"], [:])
181PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [ac_cv_my_have_sdl_mixer="yes"], [:])
182PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [ac_cv_my_have_sdl_image="yes"], [:])
183dnl
184dnl  Then the old sdl-config method
185if test "x${cross_compiling}" != xyes -a "${ac_cv_my_have_sdl}" != yes; then
[848]186  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
[949]187  if test "${SDL_CONFIG}" != "no"; then
188    SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
189    SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
190    ac_cv_my_have_sdl="yes"
[848]191  fi
[92]192fi
[949]193dnl
194dnl  Maybe all this has failed, try direct inclusion
195save_CPPFLAGS="${CPPFLAGS}"
196save_LIBS="${LIBS}"
197CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
198LIBS="${LIBS} ${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
199AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
[1691]200AC_CHECK_HEADERS(SDL_mixer.h SDL/SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
201AC_CHECK_HEADERS(SDL_image.h SDL/SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
[949]202AC_CHECK_LIB(SDL, main,
203 [SDL_LIBS="${SDL_LIBS} -lSDL"],
204 [ac_cv_my_have_sdl="no"])
[1653]205AC_CHECK_LIB(SDLmain, main,
206 [SDL_LIBS="${SDL_LIBS} -lSDLmain -lSDL"])
[949]207AC_CHECK_LIB(SDL_mixer, main,
208 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
209 [ac_cv_my_have_sdl_mixer="no"])
210AC_CHECK_LIB(SDL_image, main,
211 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
212 [ac_cv_my_have_sdl_image="no"])
213SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
214SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
215CPPFLAGS="${save_CPPFLAGS}"
216LIBS="${save_LIBS}"
217if test "${ac_cv_my_have_sdl}" = "no"; then
218  AC_MSG_WARN([SDL not found])
219else
220  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
221fi
222if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
223  AC_MSG_WARN([SDL_mixer not found])
[950]224else
225  AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
[949]226fi
227if test "${ac_cv_my_have_sdl_image}" = "no"; then
228  AC_MSG_WARN([SDL_image not found])
[950]229else
230  AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
[949]231fi
[92]232AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
[949]233AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes")
234AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes")
[92]235
236
[1436]237dnl  Use Flex's FlexLexer.h or ours?
238ac_cv_my_have_flexlexer_h="no"
239AC_LANG_PUSH(C++)
[2036]240AC_CHECK_HEADERS(FlexLexer.h,
241 dnl  Ensure that FlexLexer::yleng is of type int, and not size_t like
242 dnl  on recent Apple systems. It would break all our existing code.
243 [AC_MSG_CHECKING(for FlexLexer.h validity)
244  AC_COMPILE_IFELSE(
245   [AC_LANG_PROGRAM([#include <FlexLexer.h>
246      class Foo : public FlexLexer
247      {
248          Foo() { int &test = yyleng; }
249      }],
250     [])],
251   [AC_MSG_RESULT(yes)
252    ac_cv_my_have_flexlexer_h="yes"],
253   [AC_MSG_RESULT(no)])])
[1436]254AC_LANG_POP(C++)
255if test "x${ac_cv_my_have_flexlexer_h}" = "xno"; then
[1995]256  LOL_CFLAGS="$LOL_CFLAGS -I\$(top_srcdir)/external/flex-2.5.35/include"
[1436]257fi
258
259
[1084]260dnl  Use NativeClient?
261ac_cv_my_have_nacl="no"
262AC_LANG_PUSH(C++)
[1438]263AC_CHECK_HEADERS(ppapi/cpp/instance.h,
264 [ac_cv_my_have_nacl="yes"
265  dnl  Disable this warning, it's too verbose with vector.h
266  CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"])
[1084]267AC_LANG_POP(C++)
268AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
269
[1438]270
[1684]271dnl  Use Android? FIXME: super hacks!
272ac_cv_my_have_android="no"
273AC_CHECK_LIB(log, __android_log_vprint,
274 [ac_cv_my_have_android="yes"
275  LOL_LIBS="${LOL_LIBS} -llog -module"])
276AM_CONDITIONAL(USE_ANDROID, test "${ac_cv_my_have_android}" != "no")
277
278
[1677]279dnl  Use EGL?
[682]280ac_cv_my_have_egl="no"
281PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
282if test "${ac_cv_my_have_egl}" != "no"; then
283  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
284  EGL_LIBS="${EGL_LIBS} -lX11"
285fi
[1677]286AC_CHECK_LIB(EGL, main,
[1670]287 [ac_cv_my_have_egl="yes"
288  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
[1677]289  EGL_LIBS="-lEGL"])
290dnl  Raspberry Pi is different, check for it with extra libs; also we
291dnl  look for a different function to bypass autoconf caching
292AC_CHECK_LIB(EGL, eglGetDisplay,
293 [ac_cv_my_have_egl="yes"
294  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
295  EGL_LIBS="-lEGL -lvcos -lvchiq_arm -lbcm_host -lGLESv2"],
296 [:],
297 [-lvcos -lvchiq_arm -lbcm_host -lGLESv2])
[682]298AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
299
300
[711]301dnl Use libpng? (replacement for SDL_image)
302ac_cv_my_have_libpng="no"
303PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
304if test "${ac_cv_my_have_libpng}" != "no"; then
305  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
306fi
307AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
308
309
[981]310dnl Use Windows GDI+?
311ac_cv_my_have_gdiplus="no"
312AC_LANG_PUSH(C++)
[1156]313AC_CHECK_HEADERS(gdiplus.h,
[981]314 [ac_cv_my_have_gdiplus="yes"
315  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
316 [ac_cv_my_have_gdiplus="no"],
317 [#include <algorithm>
318  using std::min;
319  using std::max;
320  #include <windows.h>])
321AC_LANG_POP(C++)
322if test "${ac_cv_my_have_gdiplus}" != "no"; then
323  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
324fi
325AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
326
327
[623]328dnl Use libcaca? (required for font generation)
[178]329ac_cv_my_have_caca="no"
330PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
331if test "${ac_cv_my_have_caca}" != "no"; then
332  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
[92]333fi
[178]334AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
[92]335
[178]336
[623]337dnl Use libpipi? (required for video recording)
[178]338ac_cv_my_have_pipi="no"
339PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
340if test "${ac_cv_my_have_pipi}" != "no"; then
341  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
342fi
343AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
344
345
[623]346dnl Use GTK+? (required for the deushax editor)
[628]347ac_cv_my_have_gtkgl="no"
348PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
349PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
350if test "${ac_cv_my_have_gtkgl}" != "no"; then
351  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
352fi
353AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
[623]354
[642]355
[1643]356dnl  Can we build neercs?
357AM_CONDITIONAL(BUILD_NEERCS, test "${ac_cv_my_have_caca}" != "no" -a "${ac_cv_header_glob_h}" = "yes")
358
359
[1505]360dnl Extra libraries we may need
361AC_SUBST(MATH_LIBS)
362AC_SUBST(PAM_LIBS)
363AC_SUBST(UTIL_LIBS)
364
[700]365dnl How to use the Lol Engine inside this tree
[796]366LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
[848]367LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
[1212]368LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
[220]369
370AC_SUBST(LOL_CFLAGS)
371AC_SUBST(LOL_LIBS)
[92]372
[1505]373
[793]374AC_CONFIG_FILES(
375 [Makefile
[92]376  src/Makefile
[1524]377  src/data/Makefile
378  src/data/font/Makefile
[1518]379  tutorial/Makefile
[642]380  test/Makefile
[984]381  test/math/Makefile
[1112]382  test/sandbox/Makefile
[1043]383  test/xolotl/Makefile
[1520]384  build/Makefile
385  binaries/Makefile
[1744]386  people/Makefile
[1524]387  games/Makefile
388  tools/Makefile
[2071]389  tools/vimlol/Makefile
[1938]390  tools/vslol/Makefile
[92]391])
[793]392AC_CONFIG_FILES(
[1524]393 [games/monsterz/Makefile
[785]394])
[793]395AC_CONFIG_FILES(
[1524]396 [games/deushax/Makefile
397  games/deushax/art/Makefile
398  games/deushax/art/test/Makefile
399  games/deushax/gfx/Makefile
400  games/deushax/maps/Makefile
[785]401])
[1168]402AC_CONFIG_FILES(
[1524]403 [games/mrpigeon/Makefile
[1168]404])
[1235]405AC_CONFIG_FILES(
[1524]406 [games/orbital/Makefile
[1235]407])
[1449]408AC_CONFIG_FILES(
[1744]409 [tools/neercs/Makefile
[1713]410])
411AC_CONFIG_FILES(
[1744]412 [people/jnat/Makefile
[1980]413  people/jnat/TestProject/Makefile
[1778]414  people/peeweek/Makefile
[1744]415  people/touky/Makefile
[1529]416])
[92]417
418AC_OUTPUT
419
Note: See TracBrowser for help on using the repository browser.