source: trunk/configure.ac @ 1540

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

build: factor the LolFx compilation rule into configure.ac.

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