source: trunk/configure.ac @ 1112

Last change on this file since 1112 was 1112, checked in by gary, 8 years ago

build: minor reorganisation of the sandbox code.

File size: 10.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([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)
13
14AM_CONFIG_HEADER(config.h)
15
16AM_PROG_CC_C_O
17AC_PROG_CPP
18AC_PROG_CXX
19AC_PROG_CXXCPP
20AC_PROG_RANLIB
21
22AC_LIBTOOL_WIN32_DLL
23AM_PROG_LIBTOOL
24AC_LIBTOOL_CXX
25
26AC_C_CONST
27AC_C_INLINE
28
29dnl Ensure an error is thrown if pkg-config M4 files are not found.
30m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
31m4_pattern_forbid([^PKG_CHECK_MODULES$])
32m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])
33
34dnl Do not use PKG_CONFIG_LIBDIR when cross-compiling.
35if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
36  export PKG_CONFIG_LIBDIR=/dev/null
37fi
38
39dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
40dnl now otherwise it might be set in an obscure if statement. Same thing for
41dnl PKG_PROG_PKG_CONFIG which needs to be called first.
42AC_EGREP_CPP(yes, foo)
43PKG_PROG_PKG_CONFIG()
44
45dnl  Available platforms: some of these are not public
46AM_CONDITIONAL(HAVE_PS3, test -f src/platform/ps3/ps3app.cpp)
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 fastmath.h pthread.h)
58
59if test "${enable_debug}" = "yes"; then
60  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
61  OPT="-O"
62else
63  OPT="-O3 -ffast-math -fno-strength-reduce -fomit-frame-pointer"
64fi
65
66if test "${enable_release}" = "yes"; then
67  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
68  REL=""
69else
70  REL="-g"
71fi
72
73if test "${enable_experimental}" = "yes"; then
74  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
75fi
76
77dnl No exceptions
78CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
79dnl Optimizations
80CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
81dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
82CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
83
84AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
85AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
86
87dnl Are we on the PS3?
88AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
89 [LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
90  dnl  For PSGL
91  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
92  GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
93  if test "x${enable_debug}" = xyes; then
94    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
95  elif test "x${enable_release}" = xyes; then
96    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
97  else
98    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
99  fi
100  dnl  For the runtime Cg compiler
101  GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
102  dnl  For the PNG decoder
103  LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
104  dnl  For the pad library
105  LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
106  AC_PATH_PROG(MAKE_FSELF, make_fself, no)],
107 [MAKE_FSELF=no])
108AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no")
109
110
111LIBS_save="$LIBS"
112LIBS="$LIBS -Wl,-framework -Wl,OpenGL"
113AC_MSG_CHECKING(for -framework OpenGL)
114AC_TRY_LINK([], [],
115 [ac_cv_my_have_cocoa="yes"
116  AC_MSG_RESULT(yes)
117  GL_LIBS="${GL_LIBS} -framework OpenGL"
118  CXXFLAGS="${CXXFLAGS} -ObjC++"],
119 [AC_MSG_RESULT(no)])
120LIBS="$LIBS_save"
121
122
123dnl Which version of OpenGL to use?
124ac_cv_my_have_gl="no"
125PKG_CHECK_MODULES(GLES2, glesv2,
126 [ac_cv_my_have_gl="yes"
127  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
128  GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
129  GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
130 [:])
131AC_CHECK_HEADER(GLES2/gl2.h,
132 [AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
133  ac_cv_my_have_gl="yes"])
134
135PKG_CHECK_MODULES(GL, gl,
136 [ac_cv_my_have_gl="yes"
137  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
138 [:])
139
140AC_CHECK_LIB(GL, glLoadIdentity,
141 [ac_cv_my_have_gl="yes"
142  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
143  GL_LIBS="-lGL"])
144AC_CHECK_HEADER(GL/gl.h,
145 [LIBS_save="$LIBS"
146  LIBS="$LIBS -lopengl32"
147  AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
148  AC_TRY_LINK([#include <GL/gl.h>],
149   [glLoadIdentity();],
150   [ac_cv_my_have_gl="yes"
151    AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
152    AC_MSG_RESULT(yes)
153    GL_LIBS="-lopengl32"],
154   [AC_MSG_RESULT(no)])
155  LIBS="$LIBS_save"])
156AC_CHECK_HEADER(PSGL/psgl.h,
157 [ac_cv_my_have_gl="yes"])
158
159if test "${ac_cv_my_have_gl}" = "no"; then
160  AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
161fi
162
163dnl Use Glew?
164ac_cv_my_have_glew="no"
165PKG_CHECK_MODULES(GLEW, glew,
166 [ac_cv_my_have_glew="yes"
167  GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
168  GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
169 [:])
170AC_CHECK_HEADER(glew.h,
171 [LIBS_save="${LIBS}"
172  LIBS="${LIBS} -lglew32 ${GL_LIBS}"
173  AC_MSG_CHECKING(for glewInit in -lglew32)
174  AC_TRY_LINK(
175   [#include <glew.h>],
176   [glewInit();],
177   [ac_cv_my_have_glew="yes"
178    GL_LIBS="-lglew32 ${GL_LIBS}"
179    AC_MSG_RESULT(yes)],
180   [AC_MSG_RESULT(no)])
181  LIBS="${LIBS_save}"])
182if test "${ac_cv_my_have_glew}" != "no"; then
183  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
184  AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew)
185fi
186AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
187
188dnl Poor man's GL feature detection if all else failed.
189save_LIBS="${LIBS}"
190LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
191AC_CHECK_FUNCS(glBegin)
192LIBS="${save_LIBS}"
193
194
195dnl Use SDL? (always required on Linux or Win32)
196ac_cv_my_have_sdl="no"
197ac_cv_my_have_sdl_image="no"
198ac_cv_my_have_sdl_mixer="no"
199dnl
200dnl  First, try the proper pkg-config check
201PKG_CHECK_MODULES(SDL, sdl, [ac_cv_my_have_sdl="yes"], [:])
202PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [ac_cv_my_have_sdl_mixer="yes"], [:])
203PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [ac_cv_my_have_sdl_image="yes"], [:])
204dnl
205dnl  Then the old sdl-config method
206if test "x${cross_compiling}" != xyes -a "${ac_cv_my_have_sdl}" != yes; then
207  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
208  if test "${SDL_CONFIG}" != "no"; then
209    SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
210    SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
211    ac_cv_my_have_sdl="yes"
212  fi
213fi
214dnl
215dnl  Maybe all this has failed, try direct inclusion
216save_CPPFLAGS="${CPPFLAGS}"
217save_LIBS="${LIBS}"
218CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
219LIBS="${LIBS} ${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
220AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
221AC_CHECK_HEADERS(SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
222AC_CHECK_HEADERS(SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
223AC_CHECK_LIB(SDL, main,
224 [SDL_LIBS="${SDL_LIBS} -lSDL"],
225 [ac_cv_my_have_sdl="no"])
226AC_CHECK_LIB(SDL_mixer, main,
227 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
228 [ac_cv_my_have_sdl_mixer="no"])
229AC_CHECK_LIB(SDL_image, main,
230 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
231 [ac_cv_my_have_sdl_image="no"])
232SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
233SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
234CPPFLAGS="${save_CPPFLAGS}"
235LIBS="${save_LIBS}"
236if test "${ac_cv_my_have_sdl}" = "no"; then
237  AC_MSG_WARN([SDL not found])
238else
239  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
240fi
241if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
242  AC_MSG_WARN([SDL_mixer not found])
243else
244  AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
245fi
246if test "${ac_cv_my_have_sdl_image}" = "no"; then
247  AC_MSG_WARN([SDL_image not found])
248else
249  AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
250fi
251AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
252AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes")
253AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes")
254
255
256dnl  Use NativeClient?
257ac_cv_my_have_nacl="no"
258AC_LANG_PUSH(C++)
259AC_CHECK_HEADERS(ppapi/cpp/instance.h, [ac_cv_my_have_nacl="yes"])
260AC_LANG_POP(C++)
261AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
262
263dnl Use EGL?
264ac_cv_my_have_egl="no"
265PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
266if test "${ac_cv_my_have_egl}" != "no"; then
267  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
268  EGL_LIBS="${EGL_LIBS} -lX11"
269fi
270AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
271
272
273dnl Use libpng? (replacement for SDL_image)
274ac_cv_my_have_libpng="no"
275PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
276if test "${ac_cv_my_have_libpng}" != "no"; then
277  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
278fi
279AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
280
281
282dnl Use Windows GDI+?
283ac_cv_my_have_gdiplus="no"
284AC_LANG_PUSH(C++)
285AC_CHECK_HEADERS(Gdiplus.h,
286 [ac_cv_my_have_gdiplus="yes"
287  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
288 [ac_cv_my_have_gdiplus="no"],
289 [#include <algorithm>
290  using std::min;
291  using std::max;
292  #include <windows.h>])
293AC_LANG_POP(C++)
294if test "${ac_cv_my_have_gdiplus}" != "no"; then
295  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
296fi
297AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
298
299
300dnl Use libcaca? (required for font generation)
301ac_cv_my_have_caca="no"
302PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
303if test "${ac_cv_my_have_caca}" != "no"; then
304  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
305fi
306AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
307
308
309dnl Use libpipi? (required for video recording)
310ac_cv_my_have_pipi="no"
311PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
312if test "${ac_cv_my_have_pipi}" != "no"; then
313  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
314fi
315AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
316
317
318dnl Use GTK+? (required for the deushax editor)
319ac_cv_my_have_gtkgl="no"
320PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
321PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
322if test "${ac_cv_my_have_gtkgl}" != "no"; then
323  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
324fi
325AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
326
327
328dnl How to use the Lol Engine inside this tree
329LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
330LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
331LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS"
332
333AC_SUBST(MATH_LIBS)
334AC_SUBST(LOL_CFLAGS)
335AC_SUBST(LOL_LIBS)
336
337AC_CONFIG_FILES(
338 [Makefile
339  src/Makefile
340  test/Makefile
341  test/math/Makefile
342  test/sandbox/Makefile
343  test/tutorial/Makefile
344  test/xolotl/Makefile
345  gfx/Makefile
346  gfx/font/Makefile
347  tools/Makefile
348])
349AC_CONFIG_FILES(
350 [monsterz/Makefile
351])
352AC_CONFIG_FILES(
353 [deushax/Makefile
354  deushax/art/Makefile
355  deushax/art/test/Makefile
356  deushax/gfx/Makefile
357  deushax/maps/Makefile
358])
359
360AC_OUTPUT
361
Note: See TracBrowser for help on using the repository browser.