source: trunk/configure.ac @ 1438

Last change on this file since 1438 was 1438, checked in by sam, 8 years ago

build: disable violent vector.h warnings when building for NaCl.

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