source: trunk/configure.ac @ 693

Last change on this file since 693 was 693, checked in by sam, 9 years ago

Reduce optimisation strength in debug mode.

File size: 5.8 KB
Line 
1# $Id$
2
3AC_INIT(lolengine, 0.0)
4AC_PREREQ(2.50)
5AC_CONFIG_AUX_DIR(.auto)
6AC_CANONICAL_SYSTEM
7AM_INIT_AUTOMAKE([no-define tar-ustar])
8dnl AM_MAINTAINER_MODE
9
10AM_CONFIG_HEADER(config.h)
11
12AM_PROG_CC_C_O
13AC_PROG_CPP
14AC_PROG_CXX
15AC_PROG_CXXCPP
16AC_PROG_RANLIB
17
18AC_LIBTOOL_WIN32_DLL
19AM_PROG_LIBTOOL
20AC_LIBTOOL_CXX
21
22AC_C_CONST
23AC_C_INLINE
24
25dnl Ensure an error is thrown if pkg-config M4 files are not found.
26m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
27m4_pattern_forbid([^PKG_CHECK_MODULES$])
28m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])
29
30dnl Do not use PKG_CONFIG_LIBDIR when cross-compiling.
31if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
32  export PKG_CONFIG_LIBDIR=/dev/null
33fi
34
35dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
36dnl now otherwise it might be set in an obscure if statement. Same thing for
37dnl PKG_PROG_PKG_CONFIG which needs to be called first.
38AC_EGREP_CPP(yes, foo)
39PKG_PROG_PKG_CONFIG()
40
41dnl conditional builds
42AC_ARG_ENABLE(debug,
43  [  --enable-debug          build debug versions of the game (default no)])
44AC_ARG_ENABLE(release,
45  [  --enable-release        build final release of the game (default no)])
46AC_ARG_ENABLE(experimental,
47  [  --enable-experimental   experimental build (default no)])
48
49AC_ARG_ENABLE(cppunit,
50  [  --enable-cppunit        use cppunit for unit tests (autodetected)])
51
52AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
53
54if test "${enable_debug}" = "yes"; then
55  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
56  OPT="-O"
57else
58  OPT="-O2 --fno-strength-reduce -fomit-frame-pointer"
59fi
60
61if test "${enable_release}" = "yes"; then
62  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
63  REL=""
64else
65  REL="-g"
66fi
67
68if test "${enable_experimental}" = "yes"; then
69  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
70fi
71
72# Optimizations
73CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
74# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
75CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
76
77AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
78
79# Which version of OpenGL to use?
80ac_cv_my_have_gl="no"
81PKG_CHECK_MODULES(GLES1, glesv1_cm,
82 [ac_cv_my_have_gl="yes"
83  AC_DEFINE(HAVE_GLES_1X, 1, Define to 1 if GLES 1.x is available)
84  GL_CFLAGS="${GLES1_CFLAGS}"
85  GL_LIBS="${GLES1_LIBS}"],
86 [:])
87PKG_CHECK_MODULES(GLES2, glesv2,
88 [ac_cv_my_have_gl="yes"
89  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
90  GL_CFLAGS="${GLES2_CFLAGS}"
91  GL_LIBS="${GLES2_LIBS}"],
92 [:])
93AC_CHECK_LIB(GL, glLoadIdentity,
94 [ac_cv_my_have_gl="yes"
95  AC_DEFINE(HAVE_GL_1X, 1, Define to 1 if GL 1.x is available)
96  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)
97  GL_LIBS="-lGL"]) # FIXME: hackish
98if test "${ac_cv_my_have_gl}" = "no"; then
99  AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
100fi
101
102# Use SDL? (always required)
103ac_cv_my_have_sdl="yes"
104AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
105if test "${SDL_CONFIG}" != "no"; then
106  SDL_CFLAGS="${SDL_CFLAGS} `sdl-config --cflags`"
107  SDL_LIBS="${SDL_LIBS} `sdl-config --libs`"
108fi
109SDL_CFLAGS="${SDL_CFLAGS} ${GL_CFLAGS}"
110SDL_LIBS="${SDL_LIBS} ${GL_LIBS}"
111PKG_CHECK_MODULES(SDL, sdl, [:],
112 [SDL_LIBS="${SDL_LIBS} -lSDL"])
113PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [:],
114 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"])
115PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [:],
116 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"])
117SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
118SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
119
120save_CPPFLAGS="${CPPFLAGS}"
121CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
122AC_CHECK_HEADERS(SDL_mixer.h, [:], [ac_cv_my_have_sdl="no"])
123AC_CHECK_HEADERS(SDL_image.h, [:], [ac_cv_my_have_sdl="no"])
124CPPFLAGS="${save_CPPFLAGS}"
125if test "${ac_cv_my_have_sdl}" = "no"; then
126  AC_MSG_ERROR([[One of SDL, SDL_Image or SDL_Mixer not found]])
127else
128  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
129fi
130AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
131
132
133dnl Use EGL?
134ac_cv_my_have_egl="no"
135PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
136if test "${ac_cv_my_have_egl}" != "no"; then
137  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
138  EGL_LIBS="${EGL_LIBS} -lX11"
139fi
140AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
141
142
143dnl Use libcaca? (required for font generation)
144ac_cv_my_have_caca="no"
145PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
146if test "${ac_cv_my_have_caca}" != "no"; then
147  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
148fi
149AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
150
151
152dnl Use libpipi? (required for video recording)
153ac_cv_my_have_pipi="no"
154PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
155if test "${ac_cv_my_have_pipi}" != "no"; then
156  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
157fi
158AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
159
160
161dnl Use GTK+? (required for the deushax editor)
162ac_cv_my_have_gtkgl="no"
163PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
164PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
165if test "${ac_cv_my_have_gtkgl}" != "no"; then
166  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
167fi
168AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
169
170
171dnl Use cppunit for unit tests?
172PKG_CHECK_MODULES(CPPUNIT, cppunit, [CPPUNIT="yes"], [CPPUNIT="no"])
173AM_CONDITIONAL(USE_CPPUNIT, test "$CPPUNIT" = "yes")
174
175
176# How to use the Lol Engine inside this tree
177LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src $SDL_CFLAGS $EGL_CFLAGS"
178LOL_LIBS="$LOL_LIBS $SDL_LIBS $EGL_LIBS"
179
180AC_SUBST(MATH_LIBS)
181AC_SUBST(LOL_CFLAGS)
182AC_SUBST(LOL_LIBS)
183
184AC_CONFIG_FILES([
185  Makefile
186  src/Makefile
187  test/Makefile
188  monsterz/Makefile
189  deushax/Makefile
190  tools/Makefile
191  art/Makefile
192  art/test/Makefile
193  gfx/Makefile
194  gfx/font/Makefile
195  maps/Makefile
196])
197
198AC_OUTPUT
199
Note: See TracBrowser for help on using the repository browser.