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