source: trunk/configure.ac @ 981

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

image: add a GDI+ loader.

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