source: trunk/configure.ac @ 1563

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

build: do like BulletPhysics and make the PS3 code always visible.

File size: 12.9 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
9
10dnl Versioning of the separate software we ship
11LOLUNIT_VERSION=0.1
12AC_SUBST(LOLUNIT_VERSION)
13LOLREMEZ_VERSION=0.2
14AC_SUBST(LOLREMEZ_VERSION)
15
16AM_CONFIG_HEADER(config.h)
17
18AM_PROG_CC_C_O
19AC_PROG_CPP
20AC_PROG_CXX
21AC_PROG_CXXCPP
22AC_PROG_RANLIB
23
24AC_LIBTOOL_WIN32_DLL
25AM_PROG_LIBTOOL
26AC_LIBTOOL_CXX
27
28AC_C_CONST
29AC_C_INLINE
30
31dnl Ensure an error is thrown if pkg-config M4 files are not found.
32m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
33m4_pattern_forbid([^PKG_CHECK_MODULES$])
34m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])
35
36dnl Do not use PKG_CONFIG_LIBDIR when cross-compiling.
37if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
38  export PKG_CONFIG_LIBDIR=/dev/null
39fi
40
41dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
42dnl now otherwise it might be set in an obscure if statement. Same thing for
43dnl PKG_PROG_PKG_CONFIG which needs to be called first.
44AC_EGREP_CPP(yes, foo)
45PKG_PROG_PKG_CONFIG()
46
47AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
48dnl conditional builds
49AC_ARG_ENABLE(debug,
50  [  --enable-debug          build debug versions of the game (default no)])
51AC_ARG_ENABLE(release,
52  [  --enable-release        build final release of the game (default no)])
53AC_ARG_ENABLE(experimental,
54  [  --enable-experimental   experimental build (default no)])
55
56AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
57AC_CHECK_HEADERS(fastmath.h pthread.h libutil.h util.h pty.h)
58AC_CHECK_HEADERS(sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h)
59AC_CHECK_HEADERS(sys/wait.h)
60AC_CHECK_HEADERS(linux/kdev_t.h linux/major.h)
61AC_CHECK_HEADERS(security/pam_appl.h security/pam_misc.h)
62
63if test "${enable_debug}" = "yes"; then
64  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
65  OPT="-O"
66else
67  OPT="-O3 -ffast-math -fno-strength-reduce -fomit-frame-pointer"
68fi
69
70if test "${enable_release}" = "yes"; then
71  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
72  REL=""
73else
74  REL="-g"
75fi
76
77if test "${enable_experimental}" = "yes"; then
78  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
79fi
80
81dnl No exceptions
82CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
83dnl Optimizations
84CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
85dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
86CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
87
88AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
89AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
90AC_CHECK_LIB(util, forkpty, UTIL_LIBS="${UTIL_LIBS} -lutil")
91
92dnl Are we on the PS3?
93ac_cv_my_have_ps3="no"
94AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
95 [ac_cv_my_have_ps3="yes"
96  LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
97  dnl  For PSGL
98  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
99  GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
100  dnl  This is the old way
101  if test "x${CELLSDK}" != x -a "x${CELLSDK}" = x; then
102    CELL_SDK="${CELLSDK}"
103  fi
104  if test "x${enable_debug}" = xyes; then
105    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
106  elif test "x${enable_release}" = xyes; then
107    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
108  else
109    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
110  fi
111  dnl  For the runtime Cg compiler
112  GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
113  dnl  For the PNG decoder
114  LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
115  dnl  For the pad library
116  LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
117  dnl  Disable this warning, it's too verbose with vector.h
118  CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"
119  AC_PATH_PROG(MAKE_FSELF, make_fself, no)],
120 [MAKE_FSELF=no])
121AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no")
122AM_CONDITIONAL(USE_PS3, test "${ac_cv_my_have_ps3}" != "no")
123
124
125dnl  Are we on the Xbox 360?
126dnl  Answer: NO! we don't know how to build for it anyway
127AM_CONDITIONAL(USE_X360, false)
128
129
130dnl Are we on a Direct3D 9 platform?
131#ac_cv_my_have_d3d9="no"
132#AC_CHECK_HEADERS(d3d9.h, [ac_cv_my_have_d3d9="yes"])
133#if test "${ac_cv_my_have_d3d9}" != "no"; then
134#  D3D_LIBS="${D3D_LIBS} -ld3d9 -ld3dx9 -lxinput"
135#  AC_DEFINE(USE_D3D9, 1, Define to 1 to use DirectX 9)
136#fi
137#AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no")
138
139
140LIBS_save="$LIBS"
141LIBS="$LIBS -Wl,-framework -Wl,OpenGL"
142AC_MSG_CHECKING(for -framework OpenGL)
143AC_TRY_LINK([], [],
144 [ac_cv_my_have_cocoa="yes"
145  AC_MSG_RESULT(yes)
146  GL_LIBS="${GL_LIBS} -framework OpenGL"
147  CXXFLAGS="${CXXFLAGS} -ObjC++"],
148 [AC_MSG_RESULT(no)])
149LIBS="$LIBS_save"
150
151
152dnl Which version of OpenGL to use?
153ac_cv_my_have_gl="no"
154PKG_CHECK_MODULES(GLES2, glesv2,
155 [ac_cv_my_have_gl="yes"
156  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
157  GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
158  GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
159 [:])
160AC_CHECK_HEADER(GLES2/gl2.h,
161 [AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
162  ac_cv_my_have_gl="yes"])
163
164PKG_CHECK_MODULES(GL, gl,
165 [ac_cv_my_have_gl="yes"
166  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
167 [:])
168
169AC_CHECK_LIB(GL, glLoadIdentity,
170 [ac_cv_my_have_gl="yes"
171  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
172  GL_LIBS="-lGL"])
173AC_CHECK_HEADER(GL/gl.h,
174 [LIBS_save="$LIBS"
175  LIBS="$LIBS -lopengl32"
176  AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
177  AC_TRY_LINK([#include <GL/gl.h>],
178   [glLoadIdentity();],
179   [ac_cv_my_have_gl="yes"
180    AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
181    AC_MSG_RESULT(yes)
182    GL_LIBS="-lopengl32"],
183   [AC_MSG_RESULT(no)])
184  LIBS="$LIBS_save"])
185AC_CHECK_HEADER(PSGL/psgl.h,
186 [ac_cv_my_have_gl="yes"])
187
188if test "${ac_cv_my_have_gl}" = "no"; then
189  AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
190fi
191
192dnl Use Glew?
193ac_cv_my_have_glew="no"
194PKG_CHECK_MODULES(GLEW, glew,
195 [ac_cv_my_have_glew="yes"
196  GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
197  GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
198 [:])
199AC_CHECK_HEADER(glew.h,
200 [LIBS_save="${LIBS}"
201  LIBS="${LIBS} -lglew32 ${GL_LIBS}"
202  AC_MSG_CHECKING(for glewInit in -lglew32)
203  AC_TRY_LINK(
204   [#include <glew.h>],
205   [glewInit();],
206   [ac_cv_my_have_glew="yes"
207    GL_LIBS="-lglew32 ${GL_LIBS}"
208    AC_MSG_RESULT(yes)],
209   [AC_MSG_RESULT(no)])
210  LIBS="${LIBS_save}"])
211if test "${ac_cv_my_have_glew}" != "no"; then
212  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
213  AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew)
214fi
215AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
216
217dnl Poor man's GL feature detection if all else failed.
218save_LIBS="${LIBS}"
219LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
220AC_CHECK_FUNCS(glBegin)
221LIBS="${save_LIBS}"
222
223
224dnl Use SDL? (always required on Linux or Win32)
225ac_cv_my_have_sdl="no"
226ac_cv_my_have_sdl_image="no"
227ac_cv_my_have_sdl_mixer="no"
228dnl
229dnl  First, try the proper pkg-config check
230PKG_CHECK_MODULES(SDL, sdl, [ac_cv_my_have_sdl="yes"], [:])
231PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [ac_cv_my_have_sdl_mixer="yes"], [:])
232PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [ac_cv_my_have_sdl_image="yes"], [:])
233dnl
234dnl  Then the old sdl-config method
235if test "x${cross_compiling}" != xyes -a "${ac_cv_my_have_sdl}" != yes; then
236  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
237  if test "${SDL_CONFIG}" != "no"; then
238    SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
239    SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
240    ac_cv_my_have_sdl="yes"
241  fi
242fi
243dnl
244dnl  Maybe all this has failed, try direct inclusion
245save_CPPFLAGS="${CPPFLAGS}"
246save_LIBS="${LIBS}"
247CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
248LIBS="${LIBS} ${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
249AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
250AC_CHECK_HEADERS(SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
251AC_CHECK_HEADERS(SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
252AC_CHECK_LIB(SDL, main,
253 [SDL_LIBS="${SDL_LIBS} -lSDL"],
254 [ac_cv_my_have_sdl="no"])
255AC_CHECK_LIB(SDL_mixer, main,
256 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
257 [ac_cv_my_have_sdl_mixer="no"])
258AC_CHECK_LIB(SDL_image, main,
259 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
260 [ac_cv_my_have_sdl_image="no"])
261SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
262SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
263CPPFLAGS="${save_CPPFLAGS}"
264LIBS="${save_LIBS}"
265if test "${ac_cv_my_have_sdl}" = "no"; then
266  AC_MSG_WARN([SDL not found])
267else
268  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
269fi
270if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
271  AC_MSG_WARN([SDL_mixer not found])
272else
273  AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
274fi
275if test "${ac_cv_my_have_sdl_image}" = "no"; then
276  AC_MSG_WARN([SDL_image not found])
277else
278  AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
279fi
280AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
281AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes")
282AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes")
283
284
285dnl  Use Flex's FlexLexer.h or ours?
286ac_cv_my_have_flexlexer_h="no"
287AC_LANG_PUSH(C++)
288AC_CHECK_HEADERS(FlexLexer.h, [ac_cv_my_have_flexlexer_h="yes"])
289AC_LANG_POP(C++)
290if test "x${ac_cv_my_have_flexlexer_h}" = "xno"; then
291  LOL_CFLAGS="$LOL_CFLAGS -I\$(top_srcdir)/contrib/flex-2.5.35/include"
292fi
293
294
295dnl  Use NativeClient?
296ac_cv_my_have_nacl="no"
297AC_LANG_PUSH(C++)
298AC_CHECK_HEADERS(ppapi/cpp/instance.h,
299 [ac_cv_my_have_nacl="yes"
300  dnl  Disable this warning, it's too verbose with vector.h
301  CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"])
302AC_LANG_POP(C++)
303AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
304
305
306dnl Use EGL?
307ac_cv_my_have_egl="no"
308PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
309if test "${ac_cv_my_have_egl}" != "no"; then
310  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
311  EGL_LIBS="${EGL_LIBS} -lX11"
312fi
313AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
314
315
316dnl Use libpng? (replacement for SDL_image)
317ac_cv_my_have_libpng="no"
318PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
319if test "${ac_cv_my_have_libpng}" != "no"; then
320  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
321fi
322AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
323
324
325dnl Use Windows GDI+?
326ac_cv_my_have_gdiplus="no"
327AC_LANG_PUSH(C++)
328AC_CHECK_HEADERS(gdiplus.h,
329 [ac_cv_my_have_gdiplus="yes"
330  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
331 [ac_cv_my_have_gdiplus="no"],
332 [#include <algorithm>
333  using std::min;
334  using std::max;
335  #include <windows.h>])
336AC_LANG_POP(C++)
337if test "${ac_cv_my_have_gdiplus}" != "no"; then
338  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
339fi
340AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
341
342
343dnl Use libcaca? (required for font generation)
344ac_cv_my_have_caca="no"
345PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
346if test "${ac_cv_my_have_caca}" != "no"; then
347  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
348fi
349AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
350
351
352dnl Use libpipi? (required for video recording)
353ac_cv_my_have_pipi="no"
354PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
355if test "${ac_cv_my_have_pipi}" != "no"; then
356  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
357fi
358AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
359
360
361dnl Use GTK+? (required for the deushax editor)
362ac_cv_my_have_gtkgl="no"
363PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
364PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
365if test "${ac_cv_my_have_gtkgl}" != "no"; then
366  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
367fi
368AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
369
370
371dnl  LolFx compilation rule
372LOLFX_BUILD='(echo "char const *"; echo "lolfx_$(notdir $(basename $(filter %.lolfx, $^))) ="; $(SED) '"'"'s/"/\\"/g'"'"' $(filter %.lolfx, $^) | $(SED) '"'"'s/\([[^\r]]*\).*/"\1\\n"/'"'"'; echo ";") | $(CXXCOMPILE) -xc++ -c - -o $@'
373AC_SUBST(LOLFX_BUILD)
374
375
376dnl Extra libraries we may need
377AC_SUBST(MATH_LIBS)
378AC_SUBST(PAM_LIBS)
379AC_SUBST(UTIL_LIBS)
380
381dnl How to use the Lol Engine inside this tree
382LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
383LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
384LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
385
386AC_SUBST(LOL_CFLAGS)
387AC_SUBST(LOL_LIBS)
388
389
390AC_CONFIG_FILES(
391 [Makefile
392  src/Makefile
393  src/data/Makefile
394  src/data/font/Makefile
395  tutorial/Makefile
396  test/Makefile
397  test/math/Makefile
398  test/sandbox/Makefile
399  test/xolotl/Makefile
400  build/Makefile
401  binaries/Makefile
402  games/Makefile
403  tools/Makefile
404])
405AC_CONFIG_FILES(
406 [games/monsterz/Makefile
407])
408AC_CONFIG_FILES(
409 [games/deushax/Makefile
410  games/deushax/art/Makefile
411  games/deushax/art/test/Makefile
412  games/deushax/gfx/Makefile
413  games/deushax/maps/Makefile
414])
415AC_CONFIG_FILES(
416 [games/mrpigeon/Makefile
417])
418AC_CONFIG_FILES(
419 [games/orbital/Makefile
420])
421AC_CONFIG_FILES(
422 [games/ToukyDemo/Makefile
423])
424AC_CONFIG_FILES(
425 [tools/neercs/Makefile
426])
427
428AC_OUTPUT
429
Note: See TracBrowser for help on using the repository browser.