source: trunk/configure.ac @ 1082

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

core: port all code to NativeClient. Nothing runs for now, but it builds.

File size: 10.6 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 [:])
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
194dnl Use SDL? (always required on Linux or Win32)
195ac_cv_my_have_sdl="no"
196ac_cv_my_have_sdl_image="no"
197ac_cv_my_have_sdl_mixer="no"
198dnl
199dnl  First, try the proper pkg-config check
200PKG_CHECK_MODULES(SDL, sdl, [ac_cv_my_have_sdl="yes"], [:])
201PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [ac_cv_my_have_sdl_mixer="yes"], [:])
202PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [ac_cv_my_have_sdl_image="yes"], [:])
203dnl
204dnl  Then the old sdl-config method
205if test "x${cross_compiling}" != xyes -a "${ac_cv_my_have_sdl}" != yes; then
206  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
207  if test "${SDL_CONFIG}" != "no"; then
208    SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
209    SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
210    ac_cv_my_have_sdl="yes"
211  fi
212fi
213dnl
214dnl  Maybe all this has failed, try direct inclusion
215save_CPPFLAGS="${CPPFLAGS}"
216save_LIBS="${LIBS}"
217CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
218LIBS="${LIBS} ${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
219AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
220AC_CHECK_HEADERS(SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
221AC_CHECK_HEADERS(SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
222AC_CHECK_LIB(SDL, main,
223 [SDL_LIBS="${SDL_LIBS} -lSDL"],
224 [ac_cv_my_have_sdl="no"])
225AC_CHECK_LIB(SDL_mixer, main,
226 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
227 [ac_cv_my_have_sdl_mixer="no"])
228AC_CHECK_LIB(SDL_image, main,
229 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
230 [ac_cv_my_have_sdl_image="no"])
231SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
232SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
233CPPFLAGS="${save_CPPFLAGS}"
234LIBS="${save_LIBS}"
235if test "${ac_cv_my_have_sdl}" = "no"; then
236  AC_MSG_WARN([SDL not found])
237else
238  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
239fi
240if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
241  AC_MSG_WARN([SDL_mixer not found])
242else
243  AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
244fi
245if test "${ac_cv_my_have_sdl_image}" = "no"; then
246  AC_MSG_WARN([SDL_image not found])
247else
248  AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
249fi
250AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
251AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes")
252AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes")
253
254
255dnl Use EGL?
256ac_cv_my_have_egl="no"
257PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
258if test "${ac_cv_my_have_egl}" != "no"; then
259  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
260  EGL_LIBS="${EGL_LIBS} -lX11"
261fi
262AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
263
264
265dnl Use libpng? (replacement for SDL_image)
266ac_cv_my_have_libpng="no"
267PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
268if test "${ac_cv_my_have_libpng}" != "no"; then
269  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
270fi
271AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
272
273
274dnl Use Windows GDI+?
275ac_cv_my_have_gdiplus="no"
276AC_LANG_PUSH(C++)
277AC_CHECK_HEADERS(Gdiplus.h,
278 [ac_cv_my_have_gdiplus="yes"
279  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
280 [ac_cv_my_have_gdiplus="no"],
281 [#include <algorithm>
282  using std::min;
283  using std::max;
284  #include <windows.h>])
285AC_LANG_POP(C++)
286if test "${ac_cv_my_have_gdiplus}" != "no"; then
287  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
288fi
289AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
290
291
292dnl Use libcaca? (required for font generation)
293ac_cv_my_have_caca="no"
294PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
295if test "${ac_cv_my_have_caca}" != "no"; then
296  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
297fi
298AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
299
300
301dnl Use libpipi? (required for video recording)
302ac_cv_my_have_pipi="no"
303PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
304if test "${ac_cv_my_have_pipi}" != "no"; then
305  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
306fi
307AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
308
309
310dnl Use GTK+? (required for the deushax editor)
311ac_cv_my_have_gtkgl="no"
312PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
313PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
314if test "${ac_cv_my_have_gtkgl}" != "no"; then
315  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
316fi
317AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
318
319
320dnl How to use the Lol Engine inside this tree
321LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
322LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
323LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS"
324
325AC_SUBST(MATH_LIBS)
326AC_SUBST(LOL_CFLAGS)
327AC_SUBST(LOL_LIBS)
328
329AC_CONFIG_FILES(
330 [Makefile
331  src/Makefile
332  test/Makefile
333  test/math/Makefile
334  test/tutorial/Makefile
335  test/xolotl/Makefile
336  gfx/Makefile
337  gfx/font/Makefile
338  tools/Makefile
339])
340AC_CONFIG_FILES(
341 [monsterz/Makefile
342])
343AC_CONFIG_FILES(
344 [deushax/Makefile
345  deushax/art/Makefile
346  deushax/art/test/Makefile
347  deushax/gfx/Makefile
348  deushax/maps/Makefile
349])
350
351AC_OUTPUT
352
Note: See TracBrowser for help on using the repository browser.