source: trunk/configure.ac @ 1529

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

build: create and activate Makefile for ToukyDemo.

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