source: trunk/configure.ac @ 2163

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