source: trunk/configure.ac @ 1982

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

build: put the OpenGL detection code in a separate .m4 file and assume
that the OpenGL framework on OS X provides GL version 2 at least.

File size: 11.8 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 Do not use PKG_CONFIG_LIBDIR when cross-compiling.
38if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
39  export PKG_CONFIG_LIBDIR=/dev/null
40fi
41
42dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
43dnl now otherwise it might be set in an obscure if statement. Same thing for
44dnl PKG_PROG_PKG_CONFIG which needs to be called first.
45AC_EGREP_CPP(yes, foo)
46PKG_PROG_PKG_CONFIG()
47
48AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
49dnl conditional builds
50AC_ARG_ENABLE(debug,
51  [  --enable-debug          build debug versions of the game (default no)])
52AC_ARG_ENABLE(release,
53  [  --enable-release        build final release of the game (default no)])
54AC_ARG_ENABLE(experimental,
55  [  --enable-experimental   experimental build (default no)])
56
57AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
58AC_CHECK_HEADERS(fastmath.h pthread.h libutil.h util.h pty.h glob.h)
59AC_CHECK_HEADERS(sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h)
60AC_CHECK_HEADERS(sys/wait.h)
61AC_CHECK_HEADERS(linux/kdev_t.h linux/major.h)
62AC_CHECK_HEADERS(security/pam_appl.h security/pam_misc.h)
63AC_CHECK_HEADERS(pam/pam_appl.h pam/pam_misc.h)
64
65if test "${enable_debug}" = "yes"; then
66  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
67  OPT="-O"
68else
69  OPT="-O3 -ffast-math -fno-strength-reduce -fomit-frame-pointer"
70fi
71
72if test "${enable_release}" = "yes"; then
73  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
74  REL=""
75else
76  REL="-g"
77fi
78
79if test "${enable_experimental}" = "yes"; then
80  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
81fi
82
83dnl No exceptions
84CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
85dnl Optimizations
86CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
87dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
88CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
89
90AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
91AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
92AC_CHECK_LIB(util, forkpty, UTIL_LIBS="${UTIL_LIBS} -lutil")
93
94dnl Are we on the PS3?
95ac_cv_my_have_ps3="no"
96AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
97 [ac_cv_my_have_ps3="yes"
98  LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
99  dnl  For PSGL
100  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
101  GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
102  dnl  This is the old way; we now use CELL_SDK instead of CELLSDK
103  if test "x${CELLSDK}" != x -a "x${CELL_SDK}" = x; then
104    CELL_SDK="${CELLSDK}"
105  fi
106  if test "x${enable_debug}" = xyes; then
107    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
108  elif test "x${enable_release}" = xyes; then
109    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
110  else
111    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
112  fi
113  dnl  For the runtime Cg compiler
114  GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
115  dnl  For the PNG decoder
116  LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
117  dnl  For the pad library
118  LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
119  dnl  Disable this warning, it's too verbose with vector.h
120  CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"
121  AC_PATH_PROG(MAKE_FSELF, make_fself, no)
122  if test "${MAKE_FSELF}" = "no"; then
123    AC_MSG_ERROR([[Building for PS3 but make_fself not found]])
124  fi],
125 [MAKE_FSELF=no])
126AM_CONDITIONAL(USE_PS3, test "${ac_cv_my_have_ps3}" != "no")
127
128
129dnl  Are we building using MinGW?
130LIBS_save="$LIBS"
131LIBS="$LIBS -mwindows -mwin32"
132AC_MSG_CHECKING(for -mwindows -mwin32)
133AC_TRY_LINK([], [],
134 [AC_MSG_RESULT(yes)
135  CXXFLAGS="${CXXFLAGS} -mwindows -mwin32"
136  LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16"],
137 [AC_MSG_RESULT(no)])
138LIBS="$LIBS_save"
139
140
141dnl  Are we on the Xbox 360?
142dnl  Answer: NO! we don't know how to build for it anyway
143AM_CONDITIONAL(USE_X360, false)
144
145
146dnl Are we on a Direct3D 9 platform?
147#ac_cv_my_have_d3d9="no"
148#AC_CHECK_HEADERS(d3d9.h, [ac_cv_my_have_d3d9="yes"])
149#if test "${ac_cv_my_have_d3d9}" != "no"; then
150#  D3D_LIBS="${D3D_LIBS} -ld3d9 -ld3dx9 -lxinput"
151#  AC_DEFINE(USE_D3D9, 1, Define to 1 to use DirectX 9)
152#fi
153#AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no")
154
155LOL_CHECK_OPENGL()
156
157
158dnl Use SDL? (always required on Linux or Win32)
159ac_cv_my_have_sdl="no"
160ac_cv_my_have_sdl_image="no"
161ac_cv_my_have_sdl_mixer="no"
162dnl
163dnl  First, try the proper pkg-config check
164PKG_CHECK_MODULES(SDL, sdl, [ac_cv_my_have_sdl="yes"], [:])
165PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [ac_cv_my_have_sdl_mixer="yes"], [:])
166PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [ac_cv_my_have_sdl_image="yes"], [:])
167dnl
168dnl  Then the old sdl-config method
169if test "x${cross_compiling}" != xyes -a "${ac_cv_my_have_sdl}" != yes; then
170  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
171  if test "${SDL_CONFIG}" != "no"; then
172    SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
173    SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
174    ac_cv_my_have_sdl="yes"
175  fi
176fi
177dnl
178dnl  Maybe all this has failed, try direct inclusion
179save_CPPFLAGS="${CPPFLAGS}"
180save_LIBS="${LIBS}"
181CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
182LIBS="${LIBS} ${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
183AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
184AC_CHECK_HEADERS(SDL_mixer.h SDL/SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
185AC_CHECK_HEADERS(SDL_image.h SDL/SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
186AC_CHECK_LIB(SDL, main,
187 [SDL_LIBS="${SDL_LIBS} -lSDL"],
188 [ac_cv_my_have_sdl="no"])
189AC_CHECK_LIB(SDLmain, main,
190 [SDL_LIBS="${SDL_LIBS} -lSDLmain -lSDL"])
191AC_CHECK_LIB(SDL_mixer, main,
192 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
193 [ac_cv_my_have_sdl_mixer="no"])
194AC_CHECK_LIB(SDL_image, main,
195 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
196 [ac_cv_my_have_sdl_image="no"])
197SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
198SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
199CPPFLAGS="${save_CPPFLAGS}"
200LIBS="${save_LIBS}"
201if test "${ac_cv_my_have_sdl}" = "no"; then
202  AC_MSG_WARN([SDL not found])
203else
204  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
205fi
206if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
207  AC_MSG_WARN([SDL_mixer not found])
208else
209  AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
210fi
211if test "${ac_cv_my_have_sdl_image}" = "no"; then
212  AC_MSG_WARN([SDL_image not found])
213else
214  AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
215fi
216AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
217AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes")
218AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes")
219
220
221dnl  Use Flex's FlexLexer.h or ours?
222ac_cv_my_have_flexlexer_h="no"
223AC_LANG_PUSH(C++)
224AC_CHECK_HEADERS(FlexLexer.h, [ac_cv_my_have_flexlexer_h="yes"])
225AC_LANG_POP(C++)
226if test "x${ac_cv_my_have_flexlexer_h}" = "xno"; then
227  LOL_CFLAGS="$LOL_CFLAGS -I\$(top_srcdir)/contrib/flex-2.5.35/include"
228fi
229
230
231dnl  Use NativeClient?
232ac_cv_my_have_nacl="no"
233AC_LANG_PUSH(C++)
234AC_CHECK_HEADERS(ppapi/cpp/instance.h,
235 [ac_cv_my_have_nacl="yes"
236  dnl  Disable this warning, it's too verbose with vector.h
237  CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"])
238AC_LANG_POP(C++)
239AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
240
241
242dnl  Use Android? FIXME: super hacks!
243ac_cv_my_have_android="no"
244AC_CHECK_LIB(log, __android_log_vprint,
245 [ac_cv_my_have_android="yes"
246  LOL_LIBS="${LOL_LIBS} -llog -module"])
247AM_CONDITIONAL(USE_ANDROID, test "${ac_cv_my_have_android}" != "no")
248
249
250dnl  Use EGL?
251ac_cv_my_have_egl="no"
252PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
253if test "${ac_cv_my_have_egl}" != "no"; then
254  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
255  EGL_LIBS="${EGL_LIBS} -lX11"
256fi
257AC_CHECK_LIB(EGL, main,
258 [ac_cv_my_have_egl="yes"
259  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
260  EGL_LIBS="-lEGL"])
261dnl  Raspberry Pi is different, check for it with extra libs; also we
262dnl  look for a different function to bypass autoconf caching
263AC_CHECK_LIB(EGL, eglGetDisplay,
264 [ac_cv_my_have_egl="yes"
265  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
266  EGL_LIBS="-lEGL -lvcos -lvchiq_arm -lbcm_host -lGLESv2"],
267 [:],
268 [-lvcos -lvchiq_arm -lbcm_host -lGLESv2])
269AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
270
271
272dnl Use libpng? (replacement for SDL_image)
273ac_cv_my_have_libpng="no"
274PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
275if test "${ac_cv_my_have_libpng}" != "no"; then
276  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
277fi
278AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
279
280
281dnl Use Windows GDI+?
282ac_cv_my_have_gdiplus="no"
283AC_LANG_PUSH(C++)
284AC_CHECK_HEADERS(gdiplus.h,
285 [ac_cv_my_have_gdiplus="yes"
286  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
287 [ac_cv_my_have_gdiplus="no"],
288 [#include <algorithm>
289  using std::min;
290  using std::max;
291  #include <windows.h>])
292AC_LANG_POP(C++)
293if test "${ac_cv_my_have_gdiplus}" != "no"; then
294  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
295fi
296AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
297
298
299dnl Use libcaca? (required for font generation)
300ac_cv_my_have_caca="no"
301PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
302if test "${ac_cv_my_have_caca}" != "no"; then
303  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
304fi
305AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
306
307
308dnl Use libpipi? (required for video recording)
309ac_cv_my_have_pipi="no"
310PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
311if test "${ac_cv_my_have_pipi}" != "no"; then
312  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
313fi
314AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
315
316
317dnl Use GTK+? (required for the deushax editor)
318ac_cv_my_have_gtkgl="no"
319PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
320PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
321if test "${ac_cv_my_have_gtkgl}" != "no"; then
322  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
323fi
324AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
325
326
327dnl  Can we build neercs?
328AM_CONDITIONAL(BUILD_NEERCS, test "${ac_cv_my_have_caca}" != "no" -a "${ac_cv_header_glob_h}" = "yes")
329
330
331dnl Extra libraries we may need
332AC_SUBST(MATH_LIBS)
333AC_SUBST(PAM_LIBS)
334AC_SUBST(UTIL_LIBS)
335
336dnl How to use the Lol Engine inside this tree
337LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
338LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
339LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
340
341AC_SUBST(LOL_CFLAGS)
342AC_SUBST(LOL_LIBS)
343
344
345AC_CONFIG_FILES(
346 [Makefile
347  src/Makefile
348  src/data/Makefile
349  src/data/font/Makefile
350  tutorial/Makefile
351  test/Makefile
352  test/math/Makefile
353  test/sandbox/Makefile
354  test/xolotl/Makefile
355  build/Makefile
356  binaries/Makefile
357  people/Makefile
358  games/Makefile
359  tools/Makefile
360  tools/vslol/Makefile
361])
362AC_CONFIG_FILES(
363 [games/monsterz/Makefile
364])
365AC_CONFIG_FILES(
366 [games/deushax/Makefile
367  games/deushax/art/Makefile
368  games/deushax/art/test/Makefile
369  games/deushax/gfx/Makefile
370  games/deushax/maps/Makefile
371])
372AC_CONFIG_FILES(
373 [games/mrpigeon/Makefile
374])
375AC_CONFIG_FILES(
376 [games/orbital/Makefile
377])
378AC_CONFIG_FILES(
379 [tools/neercs/Makefile
380])
381AC_CONFIG_FILES(
382 [people/jnat/Makefile
383  people/jnat/TestProject/Makefile
384  people/peeweek/Makefile
385  people/touky/Makefile
386])
387
388AC_OUTPUT
389
Note: See TracBrowser for help on using the repository browser.