source: trunk/configure.ac @ 1173

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

xbox: start working on an Xbox/Direct3D port.

File size: 11.0 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([no-define tar-ustar])
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  AC_PATH_PROG(MAKE_FSELF, make_fself, no)],
110 [MAKE_FSELF=no])
111AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no")
112
113
114LIBS_save="$LIBS"
115LIBS="$LIBS -Wl,-framework -Wl,OpenGL"
116AC_MSG_CHECKING(for -framework OpenGL)
117AC_TRY_LINK([], [],
118 [ac_cv_my_have_cocoa="yes"
119  AC_MSG_RESULT(yes)
120  GL_LIBS="${GL_LIBS} -framework OpenGL"
121  CXXFLAGS="${CXXFLAGS} -ObjC++"],
122 [AC_MSG_RESULT(no)])
123LIBS="$LIBS_save"
124
125
126dnl Which version of OpenGL to use?
127ac_cv_my_have_gl="no"
128PKG_CHECK_MODULES(GLES2, glesv2,
129 [ac_cv_my_have_gl="yes"
130  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
131  GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
132  GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
133 [:])
134AC_CHECK_HEADER(GLES2/gl2.h,
135 [AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
136  ac_cv_my_have_gl="yes"])
137
138PKG_CHECK_MODULES(GL, gl,
139 [ac_cv_my_have_gl="yes"
140  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
141 [:])
142
143AC_CHECK_LIB(GL, glLoadIdentity,
144 [ac_cv_my_have_gl="yes"
145  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
146  GL_LIBS="-lGL"])
147AC_CHECK_HEADER(GL/gl.h,
148 [LIBS_save="$LIBS"
149  LIBS="$LIBS -lopengl32"
150  AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
151  AC_TRY_LINK([#include <GL/gl.h>],
152   [glLoadIdentity();],
153   [ac_cv_my_have_gl="yes"
154    AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
155    AC_MSG_RESULT(yes)
156    GL_LIBS="-lopengl32"],
157   [AC_MSG_RESULT(no)])
158  LIBS="$LIBS_save"])
159AC_CHECK_HEADER(PSGL/psgl.h,
160 [ac_cv_my_have_gl="yes"])
161
162if test "${ac_cv_my_have_gl}" = "no"; then
163  AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
164fi
165
166dnl Use Glew?
167ac_cv_my_have_glew="no"
168PKG_CHECK_MODULES(GLEW, glew,
169 [ac_cv_my_have_glew="yes"
170  GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
171  GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
172 [:])
173AC_CHECK_HEADER(glew.h,
174 [LIBS_save="${LIBS}"
175  LIBS="${LIBS} -lglew32 ${GL_LIBS}"
176  AC_MSG_CHECKING(for glewInit in -lglew32)
177  AC_TRY_LINK(
178   [#include <glew.h>],
179   [glewInit();],
180   [ac_cv_my_have_glew="yes"
181    GL_LIBS="-lglew32 ${GL_LIBS}"
182    AC_MSG_RESULT(yes)],
183   [AC_MSG_RESULT(no)])
184  LIBS="${LIBS_save}"])
185if test "${ac_cv_my_have_glew}" != "no"; then
186  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
187  AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew)
188fi
189AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
190
191dnl Poor man's GL feature detection if all else failed.
192save_LIBS="${LIBS}"
193LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
194AC_CHECK_FUNCS(glBegin)
195LIBS="${save_LIBS}"
196
197
198dnl Use SDL? (always required on Linux or Win32)
199ac_cv_my_have_sdl="no"
200ac_cv_my_have_sdl_image="no"
201ac_cv_my_have_sdl_mixer="no"
202dnl
203dnl  First, try the proper pkg-config check
204PKG_CHECK_MODULES(SDL, sdl, [ac_cv_my_have_sdl="yes"], [:])
205PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [ac_cv_my_have_sdl_mixer="yes"], [:])
206PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [ac_cv_my_have_sdl_image="yes"], [:])
207dnl
208dnl  Then the old sdl-config method
209if test "x${cross_compiling}" != xyes -a "${ac_cv_my_have_sdl}" != yes; then
210  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
211  if test "${SDL_CONFIG}" != "no"; then
212    SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
213    SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
214    ac_cv_my_have_sdl="yes"
215  fi
216fi
217dnl
218dnl  Maybe all this has failed, try direct inclusion
219save_CPPFLAGS="${CPPFLAGS}"
220save_LIBS="${LIBS}"
221CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
222LIBS="${LIBS} ${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
223AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
224AC_CHECK_HEADERS(SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
225AC_CHECK_HEADERS(SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
226AC_CHECK_LIB(SDL, main,
227 [SDL_LIBS="${SDL_LIBS} -lSDL"],
228 [ac_cv_my_have_sdl="no"])
229AC_CHECK_LIB(SDL_mixer, main,
230 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
231 [ac_cv_my_have_sdl_mixer="no"])
232AC_CHECK_LIB(SDL_image, main,
233 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
234 [ac_cv_my_have_sdl_image="no"])
235SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
236SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
237CPPFLAGS="${save_CPPFLAGS}"
238LIBS="${save_LIBS}"
239if test "${ac_cv_my_have_sdl}" = "no"; then
240  AC_MSG_WARN([SDL not found])
241else
242  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
243fi
244if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
245  AC_MSG_WARN([SDL_mixer not found])
246else
247  AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
248fi
249if test "${ac_cv_my_have_sdl_image}" = "no"; then
250  AC_MSG_WARN([SDL_image not found])
251else
252  AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
253fi
254AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
255AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes")
256AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes")
257
258
259dnl  Use NativeClient?
260ac_cv_my_have_nacl="no"
261AC_LANG_PUSH(C++)
262AC_CHECK_HEADERS(ppapi/cpp/instance.h, [ac_cv_my_have_nacl="yes"])
263AC_LANG_POP(C++)
264AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
265
266dnl Use EGL?
267ac_cv_my_have_egl="no"
268PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
269if test "${ac_cv_my_have_egl}" != "no"; then
270  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
271  EGL_LIBS="${EGL_LIBS} -lX11"
272fi
273AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
274
275
276dnl Use libpng? (replacement for SDL_image)
277ac_cv_my_have_libpng="no"
278PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
279if test "${ac_cv_my_have_libpng}" != "no"; then
280  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
281fi
282AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
283
284
285dnl Use Windows GDI+?
286ac_cv_my_have_gdiplus="no"
287AC_LANG_PUSH(C++)
288AC_CHECK_HEADERS(gdiplus.h,
289 [ac_cv_my_have_gdiplus="yes"
290  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
291 [ac_cv_my_have_gdiplus="no"],
292 [#include <algorithm>
293  using std::min;
294  using std::max;
295  #include <windows.h>])
296AC_LANG_POP(C++)
297if test "${ac_cv_my_have_gdiplus}" != "no"; then
298  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
299fi
300AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
301
302
303dnl Use libcaca? (required for font generation)
304ac_cv_my_have_caca="no"
305PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
306if test "${ac_cv_my_have_caca}" != "no"; then
307  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
308fi
309AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
310
311
312dnl Use libpipi? (required for video recording)
313ac_cv_my_have_pipi="no"
314PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
315if test "${ac_cv_my_have_pipi}" != "no"; then
316  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
317fi
318AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
319
320
321dnl Use GTK+? (required for the deushax editor)
322ac_cv_my_have_gtkgl="no"
323PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
324PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
325if test "${ac_cv_my_have_gtkgl}" != "no"; then
326  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
327fi
328AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
329
330
331dnl How to use the Lol Engine inside this tree
332LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
333LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
334LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS"
335
336AC_SUBST(MATH_LIBS)
337AC_SUBST(LOL_CFLAGS)
338AC_SUBST(LOL_LIBS)
339
340AC_CONFIG_FILES(
341 [Makefile
342  src/Makefile
343  test/Makefile
344  test/math/Makefile
345  test/sandbox/Makefile
346  test/tutorial/Makefile
347  test/xolotl/Makefile
348  gfx/Makefile
349  gfx/font/Makefile
350  tools/Makefile
351])
352AC_CONFIG_FILES(
353 [monsterz/Makefile
354])
355AC_CONFIG_FILES(
356 [deushax/Makefile
357  deushax/art/Makefile
358  deushax/art/test/Makefile
359  deushax/gfx/Makefile
360  deushax/maps/Makefile
361])
362AC_CONFIG_FILES(
363 [mrpigeon/Makefile
364])
365
366AC_OUTPUT
367
Note: See TracBrowser for help on using the repository browser.