source: trunk/configure.ac @ 1168

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

mrpigeon: create source tree for MrPigeon.

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