source: trunk/configure.ac @ 1156

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

win32: no longer ship GDI+ because MinGW ships a working version, including
for Win64.

File size: 10.9 KB
RevLine 
[700]1dnl configure script for Lol Engine
[92]2
[221]3AC_INIT(lolengine, 0.0)
[92]4AC_PREREQ(2.50)
5AC_CONFIG_AUX_DIR(.auto)
6AC_CANONICAL_SYSTEM
7AM_INIT_AUTOMAKE([no-define tar-ustar])
8dnl AM_MAINTAINER_MODE
9
[938]10dnl Versioning of the separate software we ship
11LOLUNIT_VERSION=0.1
12AC_SUBST(LOLUNIT_VERSION)
[1129]13LOLREMEZ_VERSION=0.2
[1119]14AC_SUBST(LOLREMEZ_VERSION)
[938]15
[92]16AM_CONFIG_HEADER(config.h)
17
18AM_PROG_CC_C_O
19AC_PROG_CPP
20AC_PROG_CXX
21AC_PROG_CXXCPP
22AC_PROG_RANLIB
23
24AC_LIBTOOL_WIN32_DLL
25AM_PROG_LIBTOOL
26AC_LIBTOOL_CXX
27
28AC_C_CONST
29AC_C_INLINE
30
[623]31dnl Ensure an error is thrown if pkg-config M4 files are not found.
32m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
33m4_pattern_forbid([^PKG_CHECK_MODULES$])
34m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])
35
36dnl Do not use PKG_CONFIG_LIBDIR when cross-compiling.
37if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
38  export PKG_CONFIG_LIBDIR=/dev/null
39fi
40
[92]41dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
42dnl now otherwise it might be set in an obscure if statement. Same thing for
43dnl PKG_PROG_PKG_CONFIG which needs to be called first.
44AC_EGREP_CPP(yes, foo)
45PKG_PROG_PKG_CONFIG()
46
[1036]47dnl  Available platforms: some of these are not public
48AM_CONDITIONAL(HAVE_PS3, test -f src/platform/ps3/ps3app.cpp)
49
50AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
[92]51dnl conditional builds
52AC_ARG_ENABLE(debug,
[97]53  [  --enable-debug          build debug versions of the game (default no)])
54AC_ARG_ENABLE(release,
55  [  --enable-release        build final release of the game (default no)])
[658]56AC_ARG_ENABLE(experimental,
57  [  --enable-experimental   experimental build (default no)])
[92]58
[1109]59AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h fastmath.h pthread.h)
[92]60
[421]61if test "${enable_debug}" = "yes"; then
[658]62  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
[693]63  OPT="-O"
[644]64else
[884]65  OPT="-O3 -ffast-math -fno-strength-reduce -fomit-frame-pointer"
[421]66fi
67
[644]68if test "${enable_release}" = "yes"; then
[658]69  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
[644]70  REL=""
71else
72  REL="-g"
73fi
74
[658]75if test "${enable_experimental}" = "yes"; then
76  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
77fi
78
[840]79dnl No exceptions
[935]80CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
[700]81dnl Optimizations
[693]82CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
[700]83dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
[92]84CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
85
86AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
[1093]87AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
[92]88
[840]89dnl Are we on the PS3?
90AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
91 [LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
92  dnl  For PSGL
93  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
94  GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
95  if test "x${enable_debug}" = xyes; then
96    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
97  elif test "x${enable_release}" = xyes; then
98    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
99  else
100    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
101  fi
102  dnl  For the runtime Cg compiler
103  GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
104  dnl  For the PNG decoder
105  LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
106  dnl  For the pad library
107  LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
[844]108  AC_PATH_PROG(MAKE_FSELF, make_fself, no)],
109 [MAKE_FSELF=no])
110AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no")
[840]111
112
[960]113LIBS_save="$LIBS"
114LIBS="$LIBS -Wl,-framework -Wl,OpenGL"
115AC_MSG_CHECKING(for -framework OpenGL)
116AC_TRY_LINK([], [],
117 [ac_cv_my_have_cocoa="yes"
118  AC_MSG_RESULT(yes)
119  GL_LIBS="${GL_LIBS} -framework OpenGL"
120  CXXFLAGS="${CXXFLAGS} -ObjC++"],
121 [AC_MSG_RESULT(no)])
122LIBS="$LIBS_save"
123
124
[700]125dnl Which version of OpenGL to use?
[673]126ac_cv_my_have_gl="no"
127PKG_CHECK_MODULES(GLES2, glesv2,
128 [ac_cv_my_have_gl="yes"
129  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
[801]130  GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
131  GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
[673]132 [:])
[1082]133AC_CHECK_HEADER(GLES2/gl2.h,
134 [AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
135  ac_cv_my_have_gl="yes"])
[943]136
137PKG_CHECK_MODULES(GL, gl,
138 [ac_cv_my_have_gl="yes"
139  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
140 [:])
141
[673]142AC_CHECK_LIB(GL, glLoadIdentity,
143 [ac_cv_my_have_gl="yes"
[795]144  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
145  GL_LIBS="-lGL"])
[793]146AC_CHECK_HEADER(GL/gl.h,
[795]147 [LIBS_save="$LIBS"
148  LIBS="$LIBS -lopengl32"
149  AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
150  AC_TRY_LINK([#include <GL/gl.h>],
[793]151   [glLoadIdentity();],
152   [ac_cv_my_have_gl="yes"
[840]153    AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
[797]154    AC_MSG_RESULT(yes)
[795]155    GL_LIBS="-lopengl32"],
[797]156   [AC_MSG_RESULT(no)])
[795]157  LIBS="$LIBS_save"])
[840]158AC_CHECK_HEADER(PSGL/psgl.h,
159 [ac_cv_my_have_gl="yes"])
[1082]160
[673]161if test "${ac_cv_my_have_gl}" = "no"; then
162  AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
163fi
164
[796]165dnl Use Glew?
166ac_cv_my_have_glew="no"
[801]167PKG_CHECK_MODULES(GLEW, glew,
168 [ac_cv_my_have_glew="yes"
169  GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
170  GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
171 [:])
[954]172AC_CHECK_HEADER(glew.h,
[801]173 [LIBS_save="${LIBS}"
174  LIBS="${LIBS} -lglew32 ${GL_LIBS}"
[797]175  AC_MSG_CHECKING(for glewInit in -lglew32)
[801]176  AC_TRY_LINK(
[954]177   [#include <glew.h>],
[797]178   [glewInit();],
179   [ac_cv_my_have_glew="yes"
[802]180    GL_LIBS="-lglew32 ${GL_LIBS}"
[797]181    AC_MSG_RESULT(yes)],
182   [AC_MSG_RESULT(no)])
[801]183  LIBS="${LIBS_save}"])
[796]184if test "${ac_cv_my_have_glew}" != "no"; then
185  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
186  AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew)
187fi
188AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
189
[801]190dnl Poor man's GL feature detection if all else failed.
[782]191save_LIBS="${LIBS}"
192LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
193AC_CHECK_FUNCS(glBegin)
194LIBS="${save_LIBS}"
195
[1084]196
[840]197dnl Use SDL? (always required on Linux or Win32)
[848]198ac_cv_my_have_sdl="no"
[949]199ac_cv_my_have_sdl_image="no"
200ac_cv_my_have_sdl_mixer="no"
201dnl
202dnl  First, try the proper pkg-config check
203PKG_CHECK_MODULES(SDL, sdl, [ac_cv_my_have_sdl="yes"], [:])
204PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [ac_cv_my_have_sdl_mixer="yes"], [:])
205PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [ac_cv_my_have_sdl_image="yes"], [:])
206dnl
207dnl  Then the old sdl-config method
208if test "x${cross_compiling}" != xyes -a "${ac_cv_my_have_sdl}" != yes; then
[848]209  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
[949]210  if test "${SDL_CONFIG}" != "no"; then
211    SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
212    SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
213    ac_cv_my_have_sdl="yes"
[848]214  fi
[92]215fi
[949]216dnl
217dnl  Maybe all this has failed, try direct inclusion
218save_CPPFLAGS="${CPPFLAGS}"
219save_LIBS="${LIBS}"
220CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
221LIBS="${LIBS} ${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
222AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
223AC_CHECK_HEADERS(SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
224AC_CHECK_HEADERS(SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
225AC_CHECK_LIB(SDL, main,
226 [SDL_LIBS="${SDL_LIBS} -lSDL"],
227 [ac_cv_my_have_sdl="no"])
228AC_CHECK_LIB(SDL_mixer, main,
229 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
230 [ac_cv_my_have_sdl_mixer="no"])
231AC_CHECK_LIB(SDL_image, main,
232 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
233 [ac_cv_my_have_sdl_image="no"])
234SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
235SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
236CPPFLAGS="${save_CPPFLAGS}"
237LIBS="${save_LIBS}"
238if test "${ac_cv_my_have_sdl}" = "no"; then
239  AC_MSG_WARN([SDL not found])
240else
241  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
242fi
243if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
244  AC_MSG_WARN([SDL_mixer not found])
[950]245else
246  AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
[949]247fi
248if test "${ac_cv_my_have_sdl_image}" = "no"; then
249  AC_MSG_WARN([SDL_image not found])
[950]250else
251  AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
[949]252fi
[92]253AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
[949]254AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes")
255AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes")
[92]256
257
[1084]258dnl  Use NativeClient?
259ac_cv_my_have_nacl="no"
260AC_LANG_PUSH(C++)
261AC_CHECK_HEADERS(ppapi/cpp/instance.h, [ac_cv_my_have_nacl="yes"])
262AC_LANG_POP(C++)
263AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
264
[682]265dnl Use EGL?
266ac_cv_my_have_egl="no"
267PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
268if test "${ac_cv_my_have_egl}" != "no"; then
269  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
270  EGL_LIBS="${EGL_LIBS} -lX11"
271fi
272AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
273
274
[711]275dnl Use libpng? (replacement for SDL_image)
276ac_cv_my_have_libpng="no"
277PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
278if test "${ac_cv_my_have_libpng}" != "no"; then
279  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
280fi
281AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
282
283
[981]284dnl Use Windows GDI+?
285ac_cv_my_have_gdiplus="no"
286AC_LANG_PUSH(C++)
[1156]287AC_CHECK_HEADERS(gdiplus.h,
[981]288 [ac_cv_my_have_gdiplus="yes"
289  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
290 [ac_cv_my_have_gdiplus="no"],
291 [#include <algorithm>
292  using std::min;
293  using std::max;
294  #include <windows.h>])
295AC_LANG_POP(C++)
296if test "${ac_cv_my_have_gdiplus}" != "no"; then
297  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
298fi
299AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
300
301
[623]302dnl Use libcaca? (required for font generation)
[178]303ac_cv_my_have_caca="no"
304PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
305if test "${ac_cv_my_have_caca}" != "no"; then
306  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
[92]307fi
[178]308AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
[92]309
[178]310
[623]311dnl Use libpipi? (required for video recording)
[178]312ac_cv_my_have_pipi="no"
313PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
314if test "${ac_cv_my_have_pipi}" != "no"; then
315  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
316fi
317AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
318
319
[623]320dnl Use GTK+? (required for the deushax editor)
[628]321ac_cv_my_have_gtkgl="no"
322PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
323PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
324if test "${ac_cv_my_have_gtkgl}" != "no"; then
325  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
326fi
327AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
[623]328
[642]329
[700]330dnl How to use the Lol Engine inside this tree
[796]331LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
[848]332LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
333LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS"
[220]334
[92]335AC_SUBST(MATH_LIBS)
[220]336AC_SUBST(LOL_CFLAGS)
337AC_SUBST(LOL_LIBS)
[92]338
[793]339AC_CONFIG_FILES(
340 [Makefile
[92]341  src/Makefile
[642]342  test/Makefile
[984]343  test/math/Makefile
[1112]344  test/sandbox/Makefile
[1043]345  test/tutorial/Makefile
346  test/xolotl/Makefile
[92]347  gfx/Makefile
348  gfx/font/Makefile
[785]349  tools/Makefile
[92]350])
[793]351AC_CONFIG_FILES(
352 [monsterz/Makefile
[785]353])
[793]354AC_CONFIG_FILES(
355 [deushax/Makefile
[785]356  deushax/art/Makefile
357  deushax/art/test/Makefile
358  deushax/gfx/Makefile
359  deushax/maps/Makefile
360])
[92]361
362AC_OUTPUT
363
Note: See TracBrowser for help on using the repository browser.