source: trunk/configure.ac @ 795

Last change on this file since 795 was 795, checked in by sam, 8 years ago

build: fix an error causing -lopengl32 to be used on Linux; use AC_TRY_LINK
instead of AC_TRY_COMPILE.

File size: 6.5 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([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
72dnl Optimizations
73CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
74dnl 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
79dnl Which version of OpenGL to use?
80ac_cv_my_have_gl="no"
81PKG_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="${GLES2_CFLAGS}"
85  GL_LIBS="${GLES2_LIBS}"],
86 [:])
87AC_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"])
91AC_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"])
103if test "${ac_cv_my_have_gl}" = "no"; then
104  AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
105fi
106
107dnl Poor man's GL feature detection.
108save_LIBS="${LIBS}"
109LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
110AC_CHECK_FUNCS(glBegin)
111LIBS="${save_LIBS}"
112
113dnl Use SDL? (always required)
114ac_cv_my_have_sdl="yes"
115AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
116if test "${SDL_CONFIG}" != "no"; then
117  SDL_CFLAGS="${SDL_CFLAGS} `sdl-config --cflags`"
118  SDL_LIBS="${SDL_LIBS} `sdl-config --libs`"
119fi
120SDL_CFLAGS="${SDL_CFLAGS} ${GL_CFLAGS}"
121SDL_LIBS="${SDL_LIBS} ${GL_LIBS}"
122PKG_CHECK_MODULES(SDL, sdl, [:],
123 [SDL_LIBS="${SDL_LIBS} -lSDL"])
124PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [:],
125 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"])
126PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [:],
127 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"])
128SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
129SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
130
131save_CPPFLAGS="${CPPFLAGS}"
132CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
133AC_CHECK_HEADERS(SDL_mixer.h, [:], [ac_cv_my_have_sdl="no"])
134AC_CHECK_HEADERS(SDL_image.h, [:], [ac_cv_my_have_sdl="no"])
135CPPFLAGS="${save_CPPFLAGS}"
136if test "${ac_cv_my_have_sdl}" = "no"; then
137  AC_MSG_ERROR([[One of SDL, SDL_Image or SDL_Mixer not found]])
138else
139  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
140fi
141AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
142
143
144dnl Use EGL?
145ac_cv_my_have_egl="no"
146PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
147if test "${ac_cv_my_have_egl}" != "no"; then
148  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
149  EGL_LIBS="${EGL_LIBS} -lX11"
150fi
151AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
152
153
154dnl Use libpng? (replacement for SDL_image)
155ac_cv_my_have_libpng="no"
156PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
157if test "${ac_cv_my_have_libpng}" != "no"; then
158  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
159fi
160AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
161
162
163dnl Use libcaca? (required for font generation)
164ac_cv_my_have_caca="no"
165PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
166if test "${ac_cv_my_have_caca}" != "no"; then
167  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
168fi
169AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
170
171
172dnl Use libpipi? (required for video recording)
173ac_cv_my_have_pipi="no"
174PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
175if test "${ac_cv_my_have_pipi}" != "no"; then
176  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
177fi
178AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
179
180
181dnl Use GTK+? (required for the deushax editor)
182ac_cv_my_have_gtkgl="no"
183PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
184PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
185if test "${ac_cv_my_have_gtkgl}" != "no"; then
186  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
187fi
188AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
189
190
191dnl Use cppunit for unit tests?
192PKG_CHECK_MODULES(CPPUNIT, cppunit, [CPPUNIT="yes"], [CPPUNIT="no"])
193AM_CONDITIONAL(USE_CPPUNIT, test "$CPPUNIT" = "yes")
194
195
196dnl How to use the Lol Engine inside this tree
197LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src $SDL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
198LOL_LIBS="$LOL_LIBS $SDL_LIBS $EGL_LIBS $LIBPNG_LIBS"
199
200AC_SUBST(MATH_LIBS)
201AC_SUBST(LOL_CFLAGS)
202AC_SUBST(LOL_LIBS)
203
204AC_CONFIG_FILES(
205 [Makefile
206  src/Makefile
207  test/Makefile
208  gfx/Makefile
209  gfx/font/Makefile
210  tools/Makefile
211])
212AC_CONFIG_FILES(
213 [monsterz/Makefile
214])
215AC_CONFIG_FILES(
216 [deushax/Makefile
217  deushax/art/Makefile
218  deushax/art/test/Makefile
219  deushax/gfx/Makefile
220  deushax/maps/Makefile
221])
222
223AC_OUTPUT
224
Note: See TracBrowser for help on using the repository browser.