source: trunk/configure.ac @ 1043

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

test: start writing tutorials and other shit.

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