source: trunk/configure.ac @ 848

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

build: allow to properly cross-compile for PS3 on Mingw.

File size: 8.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
10AM_CONFIG_HEADER(config.h)
11
12AM_PROG_CC_C_O
13AC_PROG_CPP
14AC_PROG_CXX
15AC_PROG_CXXCPP
16AC_PROG_RANLIB
17
18AC_LIBTOOL_WIN32_DLL
19AM_PROG_LIBTOOL
20AC_LIBTOOL_CXX
21
22AC_C_CONST
23AC_C_INLINE
24
25dnl Ensure an error is thrown if pkg-config M4 files are not found.
26m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
27m4_pattern_forbid([^PKG_CHECK_MODULES$])
28m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])
29
30dnl Do not use PKG_CONFIG_LIBDIR when cross-compiling.
31if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
32  export PKG_CONFIG_LIBDIR=/dev/null
33fi
34
35dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
36dnl now otherwise it might be set in an obscure if statement. Same thing for
37dnl PKG_PROG_PKG_CONFIG which needs to be called first.
38AC_EGREP_CPP(yes, foo)
39PKG_PROG_PKG_CONFIG()
40
41dnl conditional builds
42AC_ARG_ENABLE(debug,
43  [  --enable-debug          build debug versions of the game (default no)])
44AC_ARG_ENABLE(release,
45  [  --enable-release        build final release of the game (default no)])
46AC_ARG_ENABLE(experimental,
47  [  --enable-experimental   experimental build (default no)])
48
49AC_ARG_ENABLE(cppunit,
50  [  --enable-cppunit        use cppunit for unit tests (autodetected)])
51
52AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
53
54if test "${enable_debug}" = "yes"; then
55  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
56  OPT="-O"
57else
58  OPT="-O2 -fno-strength-reduce -fomit-frame-pointer"
59fi
60
61if test "${enable_release}" = "yes"; then
62  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
63  REL=""
64else
65  REL="-g"
66fi
67
68if test "${enable_experimental}" = "yes"; then
69  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
70fi
71
72dnl No exceptions
73CXXFLAGS="${CXXFLAGS} -fno-exceptions"
74dnl Optimizations
75CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
76dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
77CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
78
79AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
80
81
82dnl Are we on the PS3?
83AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
84 [LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
85  dnl  For PSGL
86  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
87  GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
88  if test "x${enable_debug}" = xyes; then
89    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
90  elif test "x${enable_release}" = xyes; then
91    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
92  else
93    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
94  fi
95  dnl  For the runtime Cg compiler
96  GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
97  dnl  For the PNG decoder
98  LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
99  dnl  For the pad library
100  LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
101  AC_PATH_PROG(MAKE_FSELF, make_fself, no)],
102 [MAKE_FSELF=no])
103AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no")
104
105
106dnl Which version of OpenGL to use?
107ac_cv_my_have_gl="no"
108PKG_CHECK_MODULES(GLES2, glesv2,
109 [ac_cv_my_have_gl="yes"
110  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
111  GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
112  GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
113 [:])
114AC_CHECK_LIB(GL, glLoadIdentity,
115 [ac_cv_my_have_gl="yes"
116  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
117  GL_LIBS="-lGL"])
118AC_CHECK_HEADER(GL/gl.h,
119 [LIBS_save="$LIBS"
120  LIBS="$LIBS -lopengl32"
121  AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
122  AC_TRY_LINK([#include <GL/gl.h>],
123   [glLoadIdentity();],
124   [ac_cv_my_have_gl="yes"
125    AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
126    AC_MSG_RESULT(yes)
127    GL_LIBS="-lopengl32"],
128   [AC_MSG_RESULT(no)])
129  LIBS="$LIBS_save"])
130AC_CHECK_HEADER(PSGL/psgl.h,
131 [ac_cv_my_have_gl="yes"])
132if test "${ac_cv_my_have_gl}" = "no"; then
133  AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
134fi
135
136dnl Use Glew?
137ac_cv_my_have_glew="no"
138PKG_CHECK_MODULES(GLEW, glew,
139 [ac_cv_my_have_glew="yes"
140  GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
141  GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
142 [:])
143AC_CHECK_HEADER(GL/glew.h,
144 [LIBS_save="${LIBS}"
145  LIBS="${LIBS} -lglew32 ${GL_LIBS}"
146  AC_MSG_CHECKING(for glewInit in -lglew32)
147  AC_TRY_LINK(
148   [#include <GL/glew.h>],
149   [glewInit();],
150   [ac_cv_my_have_glew="yes"
151    GL_LIBS="-lglew32 ${GL_LIBS}"
152    AC_MSG_RESULT(yes)],
153   [AC_MSG_RESULT(no)])
154  LIBS="${LIBS_save}"])
155if test "${ac_cv_my_have_glew}" != "no"; then
156  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
157  AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew)
158fi
159AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
160
161dnl Poor man's GL feature detection if all else failed.
162save_LIBS="${LIBS}"
163LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
164AC_CHECK_FUNCS(glBegin)
165LIBS="${save_LIBS}"
166
167dnl Use SDL? (always required on Linux or Win32)
168ac_cv_my_have_sdl="no"
169if test "x$cross_compiling" != xyes; then
170  ac_cv_my_have_sdl="yes"
171  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
172  if test "${SDL_CONFIG}" != "no" -a "x$cross_compiling" != xyes; then
173    SDL_CFLAGS="${SDL_CFLAGS} `sdl-config --cflags`"
174    SDL_LIBS="${SDL_LIBS} `sdl-config --libs`"
175  fi
176  PKG_CHECK_MODULES(SDL, sdl, [:],
177   [SDL_LIBS="${SDL_LIBS} -lSDL"])
178  PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [:],
179   [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"])
180  PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [:],
181   [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"])
182  SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
183  SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
184  save_CPPFLAGS="${CPPFLAGS}"
185  CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
186  AC_CHECK_HEADERS(SDL_mixer.h, [:], [ac_cv_my_have_sdl="no"])
187  AC_CHECK_HEADERS(SDL_image.h, [:], [ac_cv_my_have_sdl="no"])
188  CPPFLAGS="${save_CPPFLAGS}"
189  if test "${ac_cv_my_have_sdl}" = "no"; then
190    AC_MSG_WARN([[One of SDL, SDL_Image or SDL_Mixer not found]])
191  else
192    AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
193  fi
194fi
195AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
196
197
198dnl Use EGL?
199ac_cv_my_have_egl="no"
200PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
201if test "${ac_cv_my_have_egl}" != "no"; then
202  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
203  EGL_LIBS="${EGL_LIBS} -lX11"
204fi
205AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
206
207
208dnl Use libpng? (replacement for SDL_image)
209ac_cv_my_have_libpng="no"
210PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
211if test "${ac_cv_my_have_libpng}" != "no"; then
212  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
213fi
214AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
215
216
217dnl Use libcaca? (required for font generation)
218ac_cv_my_have_caca="no"
219PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
220if test "${ac_cv_my_have_caca}" != "no"; then
221  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
222fi
223AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
224
225
226dnl Use libpipi? (required for video recording)
227ac_cv_my_have_pipi="no"
228PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
229if test "${ac_cv_my_have_pipi}" != "no"; then
230  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
231fi
232AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
233
234
235dnl Use GTK+? (required for the deushax editor)
236ac_cv_my_have_gtkgl="no"
237PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
238PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
239if test "${ac_cv_my_have_gtkgl}" != "no"; then
240  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
241fi
242AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
243
244
245dnl Use cppunit for unit tests?
246PKG_CHECK_MODULES(CPPUNIT, cppunit, [CPPUNIT="yes"], [CPPUNIT="no"])
247AM_CONDITIONAL(USE_CPPUNIT, test "$CPPUNIT" = "yes")
248
249
250dnl How to use the Lol Engine inside this tree
251LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
252LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
253LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS"
254
255AC_SUBST(MATH_LIBS)
256AC_SUBST(LOL_CFLAGS)
257AC_SUBST(LOL_LIBS)
258
259AC_CONFIG_FILES(
260 [Makefile
261  src/Makefile
262  test/Makefile
263  gfx/Makefile
264  gfx/font/Makefile
265  tools/Makefile
266])
267AC_CONFIG_FILES(
268 [monsterz/Makefile
269])
270AC_CONFIG_FILES(
271 [deushax/Makefile
272  deushax/art/Makefile
273  deushax/art/test/Makefile
274  deushax/gfx/Makefile
275  deushax/maps/Makefile
276])
277
278AC_OUTPUT
279
Note: See TracBrowser for help on using the repository browser.