source: trunk/configure.ac @ 949

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

build: move SDL_image and SDL_mixer binaries to an i686-only directory.

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