source: trunk/configure.ac @ 1647

Last change on this file since 1647 was 1647, checked in by sam, 7 years ago

build: hide the SDL_main.h inclusion in core.h, and only activate it
on Windows if using Visual Studio; if using MinGW, try to stick to the
original main() entry point.

File size: 13.3 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([subdir-objects no-define tar-ustar silent-rules])
8dnl AM_MAINTAINER_MODE
9
10dnl Versioning of the separate software we ship
11LOLUNIT_VERSION=0.1
12AC_SUBST(LOLUNIT_VERSION)
13LOLREMEZ_VERSION=0.2
14AC_SUBST(LOLREMEZ_VERSION)
15
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
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
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
47AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
48dnl conditional builds
49AC_ARG_ENABLE(debug,
50  [  --enable-debug          build debug versions of the game (default no)])
51AC_ARG_ENABLE(release,
52  [  --enable-release        build final release of the game (default no)])
53AC_ARG_ENABLE(experimental,
54  [  --enable-experimental   experimental build (default no)])
55
56AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
57AC_CHECK_HEADERS(fastmath.h pthread.h libutil.h util.h pty.h glob.h)
58AC_CHECK_HEADERS(sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h)
59AC_CHECK_HEADERS(sys/wait.h)
60AC_CHECK_HEADERS(linux/kdev_t.h linux/major.h)
61AC_CHECK_HEADERS(security/pam_appl.h security/pam_misc.h)
62AC_CHECK_HEADERS(pam/pam_appl.h pam/pam_misc.h)
63
64if test "${enable_debug}" = "yes"; then
65  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
66  OPT="-O"
67else
68  OPT="-O3 -ffast-math -fno-strength-reduce -fomit-frame-pointer"
69fi
70
71if test "${enable_release}" = "yes"; then
72  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
73  REL=""
74else
75  REL="-g"
76fi
77
78if test "${enable_experimental}" = "yes"; then
79  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
80fi
81
82dnl No exceptions
83CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
84dnl Optimizations
85CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
86dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
87CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
88
89AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
90AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
91AC_CHECK_LIB(util, forkpty, UTIL_LIBS="${UTIL_LIBS} -lutil")
92
93dnl Are we on the PS3?
94ac_cv_my_have_ps3="no"
95AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
96 [ac_cv_my_have_ps3="yes"
97  LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
98  dnl  For PSGL
99  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
100  GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
101  dnl  This is the old way
102  if test "x${CELLSDK}" != x -a "x${CELLSDK}" = x; then
103    CELL_SDK="${CELLSDK}"
104  fi
105  if test "x${enable_debug}" = xyes; then
106    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
107  elif test "x${enable_release}" = xyes; then
108    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
109  else
110    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
111  fi
112  dnl  For the runtime Cg compiler
113  GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
114  dnl  For the PNG decoder
115  LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
116  dnl  For the pad library
117  LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
118  dnl  Disable this warning, it's too verbose with vector.h
119  CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"
120  AC_PATH_PROG(MAKE_FSELF, make_fself, no)],
121 [MAKE_FSELF=no])
122AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no")
123AM_CONDITIONAL(USE_PS3, test "${ac_cv_my_have_ps3}" != "no")
124
125
126dnl  Are we building using MinGW?
127LIBS_save="$LIBS"
128LIBS="$LIBS -mwindows"
129AC_MSG_CHECKING(for -mwindows)
130AC_TRY_LINK([], [],
131 [AC_MSG_RESULT(yes)
132  LOL_LIBS="${LOL_LIBS} -mwindows"],
133 [AC_MSG_RESULT(no)])
134LIBS="$LIBS_save"
135
136
137dnl  Are we on the Xbox 360?
138dnl  Answer: NO! we don't know how to build for it anyway
139AM_CONDITIONAL(USE_X360, false)
140
141
142dnl Are we on a Direct3D 9 platform?
143#ac_cv_my_have_d3d9="no"
144#AC_CHECK_HEADERS(d3d9.h, [ac_cv_my_have_d3d9="yes"])
145#if test "${ac_cv_my_have_d3d9}" != "no"; then
146#  D3D_LIBS="${D3D_LIBS} -ld3d9 -ld3dx9 -lxinput"
147#  AC_DEFINE(USE_D3D9, 1, Define to 1 to use DirectX 9)
148#fi
149#AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no")
150
151
152LIBS_save="$LIBS"
153LIBS="$LIBS -Wl,-framework -Wl,OpenGL"
154AC_MSG_CHECKING(for -framework OpenGL)
155AC_TRY_LINK([], [],
156 [AC_MSG_RESULT(yes)
157  GL_LIBS="${GL_LIBS} -framework OpenGL"
158  CXXFLAGS="${CXXFLAGS} -ObjC++"],
159 [AC_MSG_RESULT(no)])
160LIBS="$LIBS_save"
161
162
163dnl Which version of OpenGL to use?
164ac_cv_my_have_gl="no"
165PKG_CHECK_MODULES(GLES2, glesv2,
166 [ac_cv_my_have_gl="yes"
167  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
168  GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
169  GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
170 [:])
171AC_CHECK_HEADER(GLES2/gl2.h,
172 [AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
173  ac_cv_my_have_gl="yes"])
174
175PKG_CHECK_MODULES(GL, gl,
176 [ac_cv_my_have_gl="yes"
177  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
178 [:])
179
180AC_CHECK_LIB(GL, glLoadIdentity,
181 [ac_cv_my_have_gl="yes"
182  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
183  GL_LIBS="-lGL"])
184AC_CHECK_HEADER(GL/gl.h,
185 [LIBS_save="$LIBS"
186  LIBS="$LIBS -lopengl32"
187  AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
188  AC_TRY_LINK([#include <GL/gl.h>],
189   [glLoadIdentity();],
190   [ac_cv_my_have_gl="yes"
191    AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
192    AC_MSG_RESULT(yes)
193    GL_LIBS="-lopengl32"],
194   [AC_MSG_RESULT(no)])
195  LIBS="$LIBS_save"])
196AC_CHECK_HEADER(PSGL/psgl.h,
197 [ac_cv_my_have_gl="yes"])
198
199if test "${ac_cv_my_have_gl}" = "no"; then
200  AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
201fi
202
203dnl Use Glew?
204ac_cv_my_have_glew="no"
205PKG_CHECK_MODULES(GLEW, glew,
206 [ac_cv_my_have_glew="yes"
207  GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
208  GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
209 [:])
210AC_CHECK_HEADER(glew.h,
211 [LIBS_save="${LIBS}"
212  LIBS="${LIBS} -lglew32 ${GL_LIBS}"
213  AC_MSG_CHECKING(for glewInit in -lglew32)
214  AC_TRY_LINK(
215   [#include <glew.h>],
216   [glewInit();],
217   [ac_cv_my_have_glew="yes"
218    GL_LIBS="-lglew32 ${GL_LIBS}"
219    AC_MSG_RESULT(yes)],
220   [AC_MSG_RESULT(no)])
221  LIBS="${LIBS_save}"])
222if test "${ac_cv_my_have_glew}" != "no"; then
223  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
224  AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew)
225fi
226AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
227
228dnl Poor man's GL feature detection if all else failed.
229save_LIBS="${LIBS}"
230LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
231AC_CHECK_FUNCS(glBegin)
232LIBS="${save_LIBS}"
233
234
235dnl Use SDL? (always required on Linux or Win32)
236ac_cv_my_have_sdl="no"
237ac_cv_my_have_sdl_image="no"
238ac_cv_my_have_sdl_mixer="no"
239dnl
240dnl  First, try the proper pkg-config check
241PKG_CHECK_MODULES(SDL, sdl, [ac_cv_my_have_sdl="yes"], [:])
242PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [ac_cv_my_have_sdl_mixer="yes"], [:])
243PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [ac_cv_my_have_sdl_image="yes"], [:])
244dnl
245dnl  Then the old sdl-config method
246if test "x${cross_compiling}" != xyes -a "${ac_cv_my_have_sdl}" != yes; then
247  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
248  if test "${SDL_CONFIG}" != "no"; then
249    SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
250    SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
251    ac_cv_my_have_sdl="yes"
252  fi
253fi
254dnl
255dnl  Maybe all this has failed, try direct inclusion
256save_CPPFLAGS="${CPPFLAGS}"
257save_LIBS="${LIBS}"
258CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
259LIBS="${LIBS} ${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
260AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
261AC_CHECK_HEADERS(SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
262AC_CHECK_HEADERS(SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
263AC_CHECK_LIB(SDL, main,
264 [SDL_LIBS="${SDL_LIBS} -lSDL"],
265 [ac_cv_my_have_sdl="no"])
266AC_CHECK_LIB(SDL_mixer, main,
267 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
268 [ac_cv_my_have_sdl_mixer="no"])
269AC_CHECK_LIB(SDL_image, main,
270 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
271 [ac_cv_my_have_sdl_image="no"])
272SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
273SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
274CPPFLAGS="${save_CPPFLAGS}"
275LIBS="${save_LIBS}"
276if test "${ac_cv_my_have_sdl}" = "no"; then
277  AC_MSG_WARN([SDL not found])
278else
279  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
280fi
281if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
282  AC_MSG_WARN([SDL_mixer not found])
283else
284  AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
285fi
286if test "${ac_cv_my_have_sdl_image}" = "no"; then
287  AC_MSG_WARN([SDL_image not found])
288else
289  AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
290fi
291AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
292AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes")
293AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes")
294
295
296dnl  Use Flex's FlexLexer.h or ours?
297ac_cv_my_have_flexlexer_h="no"
298AC_LANG_PUSH(C++)
299AC_CHECK_HEADERS(FlexLexer.h, [ac_cv_my_have_flexlexer_h="yes"])
300AC_LANG_POP(C++)
301if test "x${ac_cv_my_have_flexlexer_h}" = "xno"; then
302  LOL_CFLAGS="$LOL_CFLAGS -I\$(top_srcdir)/contrib/flex-2.5.35/include"
303fi
304
305
306dnl  Use NativeClient?
307ac_cv_my_have_nacl="no"
308AC_LANG_PUSH(C++)
309AC_CHECK_HEADERS(ppapi/cpp/instance.h,
310 [ac_cv_my_have_nacl="yes"
311  dnl  Disable this warning, it's too verbose with vector.h
312  CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"])
313AC_LANG_POP(C++)
314AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
315
316
317dnl Use EGL?
318ac_cv_my_have_egl="no"
319PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
320if test "${ac_cv_my_have_egl}" != "no"; then
321  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
322  EGL_LIBS="${EGL_LIBS} -lX11"
323fi
324AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
325
326
327dnl Use libpng? (replacement for SDL_image)
328ac_cv_my_have_libpng="no"
329PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
330if test "${ac_cv_my_have_libpng}" != "no"; then
331  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
332fi
333AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
334
335
336dnl Use Windows GDI+?
337ac_cv_my_have_gdiplus="no"
338AC_LANG_PUSH(C++)
339AC_CHECK_HEADERS(gdiplus.h,
340 [ac_cv_my_have_gdiplus="yes"
341  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
342 [ac_cv_my_have_gdiplus="no"],
343 [#include <algorithm>
344  using std::min;
345  using std::max;
346  #include <windows.h>])
347AC_LANG_POP(C++)
348if test "${ac_cv_my_have_gdiplus}" != "no"; then
349  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
350fi
351AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
352
353
354dnl Use libcaca? (required for font generation)
355ac_cv_my_have_caca="no"
356PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
357if test "${ac_cv_my_have_caca}" != "no"; then
358  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
359fi
360AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
361
362
363dnl Use libpipi? (required for video recording)
364ac_cv_my_have_pipi="no"
365PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
366if test "${ac_cv_my_have_pipi}" != "no"; then
367  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
368fi
369AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
370
371
372dnl Use GTK+? (required for the deushax editor)
373ac_cv_my_have_gtkgl="no"
374PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
375PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
376if test "${ac_cv_my_have_gtkgl}" != "no"; then
377  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
378fi
379AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
380
381
382dnl  Can we build neercs?
383AM_CONDITIONAL(BUILD_NEERCS, test "${ac_cv_my_have_caca}" != "no" -a "${ac_cv_header_glob_h}" = "yes")
384
385
386dnl  LolFx compilation rule
387LOLFX_BUILD='(echo "char const *"; echo "lolfx_$(notdir $(basename $(filter %.lolfx, $^))) ="; $(SED) '"'"'s/"/\\"/g'"'"' $(filter %.lolfx, $^) | $(SED) '"'"'s/\([[^\r]]*\).*/"\1\\n"/'"'"'; echo ";") | $(CXXCOMPILE) -xc++ -c - -o $@'
388AC_SUBST(LOLFX_BUILD)
389
390
391dnl Extra libraries we may need
392AC_SUBST(MATH_LIBS)
393AC_SUBST(PAM_LIBS)
394AC_SUBST(UTIL_LIBS)
395
396dnl How to use the Lol Engine inside this tree
397LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
398LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
399LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
400
401AC_SUBST(LOL_CFLAGS)
402AC_SUBST(LOL_LIBS)
403
404
405AC_CONFIG_FILES(
406 [Makefile
407  src/Makefile
408  src/data/Makefile
409  src/data/font/Makefile
410  tutorial/Makefile
411  test/Makefile
412  test/math/Makefile
413  test/sandbox/Makefile
414  test/xolotl/Makefile
415  build/Makefile
416  binaries/Makefile
417  games/Makefile
418  tools/Makefile
419])
420AC_CONFIG_FILES(
421 [games/monsterz/Makefile
422])
423AC_CONFIG_FILES(
424 [games/deushax/Makefile
425  games/deushax/art/Makefile
426  games/deushax/art/test/Makefile
427  games/deushax/gfx/Makefile
428  games/deushax/maps/Makefile
429])
430AC_CONFIG_FILES(
431 [games/mrpigeon/Makefile
432])
433AC_CONFIG_FILES(
434 [games/orbital/Makefile
435])
436AC_CONFIG_FILES(
437 [games/ToukyDemo/Makefile
438])
439AC_CONFIG_FILES(
440 [tools/neercs/Makefile
441])
442
443AC_OUTPUT
444
Note: See TracBrowser for help on using the repository browser.