source: trunk/configure.ac @ 1984

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

build: safety measure in configure.ac to error out if a Lol Engine m4
macro is undefined.

File size: 11.9 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
9AM_DEFAULT_VERBOSITY=0
10
11dnl Versioning of the separate software we ship
12LOLUNIT_VERSION=0.1
13AC_SUBST(LOLUNIT_VERSION)
14LOLREMEZ_VERSION=0.2
15AC_SUBST(LOLREMEZ_VERSION)
16
17AM_CONFIG_HEADER(config.h)
18
19AM_PROG_CC_C_O
20AC_PROG_CPP
21AC_PROG_CXX
22AC_PROG_CXXCPP
23AC_PROG_RANLIB
24
25AC_LIBTOOL_WIN32_DLL
26AM_PROG_LIBTOOL
27AC_LIBTOOL_CXX
28
29AC_C_CONST
30AC_C_INLINE
31
32dnl Ensure an error is thrown if pkg-config M4 files are not found.
33m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
34m4_pattern_forbid([^PKG_CHECK_MODULES$])
35m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])
36
37dnl  Same for Lol Engine M4 files.
38m4_pattern_forbid([^LOL_])
39
40
41dnl Do not use PKG_CONFIG_LIBDIR when cross-compiling.
42if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
43  export PKG_CONFIG_LIBDIR=/dev/null
44fi
45
46dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
47dnl now otherwise it might be set in an obscure if statement. Same thing for
48dnl PKG_PROG_PKG_CONFIG which needs to be called first.
49AC_EGREP_CPP(yes, foo)
50PKG_PROG_PKG_CONFIG()
51
52AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
53dnl conditional builds
54AC_ARG_ENABLE(debug,
55  [  --enable-debug          build debug versions of the game (default no)])
56AC_ARG_ENABLE(release,
57  [  --enable-release        build final release of the game (default no)])
58AC_ARG_ENABLE(experimental,
59  [  --enable-experimental   experimental build (default no)])
60
61AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
62AC_CHECK_HEADERS(fastmath.h pthread.h libutil.h util.h pty.h glob.h)
63AC_CHECK_HEADERS(sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h)
64AC_CHECK_HEADERS(sys/wait.h)
65AC_CHECK_HEADERS(linux/kdev_t.h linux/major.h)
66AC_CHECK_HEADERS(security/pam_appl.h security/pam_misc.h)
67AC_CHECK_HEADERS(pam/pam_appl.h pam/pam_misc.h)
68
69if test "${enable_debug}" = "yes"; then
70  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
71  OPT="-O"
72else
73  OPT="-O3 -ffast-math -fno-strength-reduce -fomit-frame-pointer"
74fi
75
76if test "${enable_release}" = "yes"; then
77  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
78  REL=""
79else
80  REL="-g"
81fi
82
83if test "${enable_experimental}" = "yes"; then
84  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
85fi
86
87dnl No exceptions
88CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
89dnl Optimizations
90CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
91dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
92CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
93
94AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
95AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
96AC_CHECK_LIB(util, forkpty, UTIL_LIBS="${UTIL_LIBS} -lutil")
97
98dnl Are we on the PS3?
99ac_cv_my_have_ps3="no"
100AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
101 [ac_cv_my_have_ps3="yes"
102  LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
103  dnl  For PSGL
104  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
105  GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
106  dnl  This is the old way; we now use CELL_SDK instead of CELLSDK
107  if test "x${CELLSDK}" != x -a "x${CELL_SDK}" = x; then
108    CELL_SDK="${CELLSDK}"
109  fi
110  if test "x${enable_debug}" = xyes; then
111    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
112  elif test "x${enable_release}" = xyes; then
113    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
114  else
115    GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
116  fi
117  dnl  For the runtime Cg compiler
118  GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
119  dnl  For the PNG decoder
120  LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
121  dnl  For the pad library
122  LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
123  dnl  Disable this warning, it's too verbose with vector.h
124  CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"
125  AC_PATH_PROG(MAKE_FSELF, make_fself, no)
126  if test "${MAKE_FSELF}" = "no"; then
127    AC_MSG_ERROR([[Building for PS3 but make_fself not found]])
128  fi],
129 [MAKE_FSELF=no])
130AM_CONDITIONAL(USE_PS3, test "${ac_cv_my_have_ps3}" != "no")
131
132
133dnl  Are we building using MinGW?
134LIBS_save="$LIBS"
135LIBS="$LIBS -mwindows -mwin32"
136AC_MSG_CHECKING(for -mwindows -mwin32)
137AC_TRY_LINK([], [],
138 [AC_MSG_RESULT(yes)
139  CXXFLAGS="${CXXFLAGS} -mwindows -mwin32"
140  LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16"],
141 [AC_MSG_RESULT(no)])
142LIBS="$LIBS_save"
143
144
145dnl  Are we on the Xbox 360?
146dnl  Answer: NO! we don't know how to build for it anyway
147AM_CONDITIONAL(USE_X360, false)
148
149
150dnl Are we on a Direct3D 9 platform?
151#ac_cv_my_have_d3d9="no"
152#AC_CHECK_HEADERS(d3d9.h, [ac_cv_my_have_d3d9="yes"])
153#if test "${ac_cv_my_have_d3d9}" != "no"; then
154#  D3D_LIBS="${D3D_LIBS} -ld3d9 -ld3dx9 -lxinput"
155#  AC_DEFINE(USE_D3D9, 1, Define to 1 to use DirectX 9)
156#fi
157#AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no")
158
159LOL_CHECK_OPENGL
160
161
162dnl Use SDL? (always required on Linux or Win32)
163ac_cv_my_have_sdl="no"
164ac_cv_my_have_sdl_image="no"
165ac_cv_my_have_sdl_mixer="no"
166dnl
167dnl  First, try the proper pkg-config check
168PKG_CHECK_MODULES(SDL, sdl, [ac_cv_my_have_sdl="yes"], [:])
169PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [ac_cv_my_have_sdl_mixer="yes"], [:])
170PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [ac_cv_my_have_sdl_image="yes"], [:])
171dnl
172dnl  Then the old sdl-config method
173if test "x${cross_compiling}" != xyes -a "${ac_cv_my_have_sdl}" != yes; then
174  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
175  if test "${SDL_CONFIG}" != "no"; then
176    SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
177    SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
178    ac_cv_my_have_sdl="yes"
179  fi
180fi
181dnl
182dnl  Maybe all this has failed, try direct inclusion
183save_CPPFLAGS="${CPPFLAGS}"
184save_LIBS="${LIBS}"
185CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
186LIBS="${LIBS} ${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
187AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
188AC_CHECK_HEADERS(SDL_mixer.h SDL/SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
189AC_CHECK_HEADERS(SDL_image.h SDL/SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
190AC_CHECK_LIB(SDL, main,
191 [SDL_LIBS="${SDL_LIBS} -lSDL"],
192 [ac_cv_my_have_sdl="no"])
193AC_CHECK_LIB(SDLmain, main,
194 [SDL_LIBS="${SDL_LIBS} -lSDLmain -lSDL"])
195AC_CHECK_LIB(SDL_mixer, main,
196 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
197 [ac_cv_my_have_sdl_mixer="no"])
198AC_CHECK_LIB(SDL_image, main,
199 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
200 [ac_cv_my_have_sdl_image="no"])
201SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
202SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
203CPPFLAGS="${save_CPPFLAGS}"
204LIBS="${save_LIBS}"
205if test "${ac_cv_my_have_sdl}" = "no"; then
206  AC_MSG_WARN([SDL not found])
207else
208  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
209fi
210if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
211  AC_MSG_WARN([SDL_mixer not found])
212else
213  AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
214fi
215if test "${ac_cv_my_have_sdl_image}" = "no"; then
216  AC_MSG_WARN([SDL_image not found])
217else
218  AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
219fi
220AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
221AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes")
222AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes")
223
224
225dnl  Use Flex's FlexLexer.h or ours?
226ac_cv_my_have_flexlexer_h="no"
227AC_LANG_PUSH(C++)
228AC_CHECK_HEADERS(FlexLexer.h, [ac_cv_my_have_flexlexer_h="yes"])
229AC_LANG_POP(C++)
230if test "x${ac_cv_my_have_flexlexer_h}" = "xno"; then
231  LOL_CFLAGS="$LOL_CFLAGS -I\$(top_srcdir)/contrib/flex-2.5.35/include"
232fi
233
234
235dnl  Use NativeClient?
236ac_cv_my_have_nacl="no"
237AC_LANG_PUSH(C++)
238AC_CHECK_HEADERS(ppapi/cpp/instance.h,
239 [ac_cv_my_have_nacl="yes"
240  dnl  Disable this warning, it's too verbose with vector.h
241  CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"])
242AC_LANG_POP(C++)
243AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
244
245
246dnl  Use Android? FIXME: super hacks!
247ac_cv_my_have_android="no"
248AC_CHECK_LIB(log, __android_log_vprint,
249 [ac_cv_my_have_android="yes"
250  LOL_LIBS="${LOL_LIBS} -llog -module"])
251AM_CONDITIONAL(USE_ANDROID, test "${ac_cv_my_have_android}" != "no")
252
253
254dnl  Use EGL?
255ac_cv_my_have_egl="no"
256PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
257if test "${ac_cv_my_have_egl}" != "no"; then
258  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
259  EGL_LIBS="${EGL_LIBS} -lX11"
260fi
261AC_CHECK_LIB(EGL, main,
262 [ac_cv_my_have_egl="yes"
263  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
264  EGL_LIBS="-lEGL"])
265dnl  Raspberry Pi is different, check for it with extra libs; also we
266dnl  look for a different function to bypass autoconf caching
267AC_CHECK_LIB(EGL, eglGetDisplay,
268 [ac_cv_my_have_egl="yes"
269  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
270  EGL_LIBS="-lEGL -lvcos -lvchiq_arm -lbcm_host -lGLESv2"],
271 [:],
272 [-lvcos -lvchiq_arm -lbcm_host -lGLESv2])
273AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
274
275
276dnl Use libpng? (replacement for SDL_image)
277ac_cv_my_have_libpng="no"
278PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
279if test "${ac_cv_my_have_libpng}" != "no"; then
280  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
281fi
282AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
283
284
285dnl Use Windows GDI+?
286ac_cv_my_have_gdiplus="no"
287AC_LANG_PUSH(C++)
288AC_CHECK_HEADERS(gdiplus.h,
289 [ac_cv_my_have_gdiplus="yes"
290  LOL_LIBS="${LOL_LIBS} -lgdiplus"],
291 [ac_cv_my_have_gdiplus="no"],
292 [#include <algorithm>
293  using std::min;
294  using std::max;
295  #include <windows.h>])
296AC_LANG_POP(C++)
297if test "${ac_cv_my_have_gdiplus}" != "no"; then
298  AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
299fi
300AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
301
302
303dnl Use libcaca? (required for font generation)
304ac_cv_my_have_caca="no"
305PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
306if test "${ac_cv_my_have_caca}" != "no"; then
307  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
308fi
309AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
310
311
312dnl Use libpipi? (required for video recording)
313ac_cv_my_have_pipi="no"
314PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
315if test "${ac_cv_my_have_pipi}" != "no"; then
316  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
317fi
318AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
319
320
321dnl Use GTK+? (required for the deushax editor)
322ac_cv_my_have_gtkgl="no"
323PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
324PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
325if test "${ac_cv_my_have_gtkgl}" != "no"; then
326  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
327fi
328AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
329
330
331dnl  Can we build neercs?
332AM_CONDITIONAL(BUILD_NEERCS, test "${ac_cv_my_have_caca}" != "no" -a "${ac_cv_header_glob_h}" = "yes")
333
334
335dnl Extra libraries we may need
336AC_SUBST(MATH_LIBS)
337AC_SUBST(PAM_LIBS)
338AC_SUBST(UTIL_LIBS)
339
340dnl How to use the Lol Engine inside this tree
341LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
342LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
343LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
344
345AC_SUBST(LOL_CFLAGS)
346AC_SUBST(LOL_LIBS)
347
348
349AC_CONFIG_FILES(
350 [Makefile
351  src/Makefile
352  src/data/Makefile
353  src/data/font/Makefile
354  tutorial/Makefile
355  test/Makefile
356  test/math/Makefile
357  test/sandbox/Makefile
358  test/xolotl/Makefile
359  build/Makefile
360  binaries/Makefile
361  people/Makefile
362  games/Makefile
363  tools/Makefile
364  tools/vslol/Makefile
365])
366AC_CONFIG_FILES(
367 [games/monsterz/Makefile
368])
369AC_CONFIG_FILES(
370 [games/deushax/Makefile
371  games/deushax/art/Makefile
372  games/deushax/art/test/Makefile
373  games/deushax/gfx/Makefile
374  games/deushax/maps/Makefile
375])
376AC_CONFIG_FILES(
377 [games/mrpigeon/Makefile
378])
379AC_CONFIG_FILES(
380 [games/orbital/Makefile
381])
382AC_CONFIG_FILES(
383 [tools/neercs/Makefile
384])
385AC_CONFIG_FILES(
386 [people/jnat/Makefile
387  people/jnat/TestProject/Makefile
388  people/peeweek/Makefile
389  people/touky/Makefile
390])
391
392AC_OUTPUT
393
Note: See TracBrowser for help on using the repository browser.