source: trunk/configure.ac @ 797

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

build: make build-mingw properly use the contrib libglew.

File size: 7.1 KB
RevLine 
[700]1dnl configure script for Lol Engine
[92]2
[221]3AC_INIT(lolengine, 0.0)
[92]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
[623]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
[92]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,
[97]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)])
[658]46AC_ARG_ENABLE(experimental,
47  [  --enable-experimental   experimental build (default no)])
[92]48
[642]49AC_ARG_ENABLE(cppunit,
50  [  --enable-cppunit        use cppunit for unit tests (autodetected)])
51
[92]52AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
53
[421]54if test "${enable_debug}" = "yes"; then
[658]55  AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
[693]56  OPT="-O"
[644]57else
[694]58  OPT="-O2 -fno-strength-reduce -fomit-frame-pointer"
[421]59fi
60
[644]61if test "${enable_release}" = "yes"; then
[658]62  AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
[644]63  REL=""
64else
65  REL="-g"
66fi
67
[658]68if test "${enable_experimental}" = "yes"; then
69  AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
70fi
71
[700]72dnl Optimizations
[693]73CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
[700]74dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
[92]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
[700]79dnl Which version of OpenGL to use?
[673]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"
[795]89  AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
90  GL_LIBS="-lGL"])
[793]91AC_CHECK_HEADER(GL/gl.h,
[795]92 [LIBS_save="$LIBS"
93  LIBS="$LIBS -lopengl32"
94  AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
95  AC_TRY_LINK([#include <GL/gl.h>],
[793]96   [glLoadIdentity();],
97   [ac_cv_my_have_gl="yes"
[795]98    AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hacky
[797]99    AC_MSG_RESULT(yes)
[795]100    GL_LIBS="-lopengl32"],
[797]101   [AC_MSG_RESULT(no)])
[795]102  LIBS="$LIBS_save"])
[673]103if test "${ac_cv_my_have_gl}" = "no"; then
104  AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
105fi
106
[796]107dnl Use Glew?
108ac_cv_my_have_glew="no"
109PKG_CHECK_MODULES(GLEW, glew, [ac_cv_my_have_glew="yes"], [:])
[797]110AC_CHECK_HEADER(GL/glew.h,
111 [LIBS_save="$LIBS"
112  LIBS="$LIBS -lglew32"
113  AC_MSG_CHECKING(for glewInit in -lglew32)
114  AC_TRY_LINK([#include <GL/glew.h>],
115   [glewInit();],
116   [ac_cv_my_have_glew="yes"
117    AC_MSG_RESULT(yes)],
118   [AC_MSG_RESULT(no)])
119  LIBS="$LIBS_save"])
[796]120if test "${ac_cv_my_have_glew}" != "no"; then
121  AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
122  AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew)
123fi
124AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
125
[782]126dnl Poor man's GL feature detection.
127save_LIBS="${LIBS}"
128LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
129AC_CHECK_FUNCS(glBegin)
130LIBS="${save_LIBS}"
131
[700]132dnl Use SDL? (always required)
[253]133ac_cv_my_have_sdl="yes"
[92]134AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
135if test "${SDL_CONFIG}" != "no"; then
[632]136  SDL_CFLAGS="${SDL_CFLAGS} `sdl-config --cflags`"
137  SDL_LIBS="${SDL_LIBS} `sdl-config --libs`"
[92]138fi
[673]139SDL_CFLAGS="${SDL_CFLAGS} ${GL_CFLAGS}"
140SDL_LIBS="${SDL_LIBS} ${GL_LIBS}"
[632]141PKG_CHECK_MODULES(SDL, sdl, [:],
142 [SDL_LIBS="${SDL_LIBS} -lSDL"])
143PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [:],
144 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"])
145PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [:],
146 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"])
147SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
148SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
149
[673]150save_CPPFLAGS="${CPPFLAGS}"
[632]151CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
152AC_CHECK_HEADERS(SDL_mixer.h, [:], [ac_cv_my_have_sdl="no"])
153AC_CHECK_HEADERS(SDL_image.h, [:], [ac_cv_my_have_sdl="no"])
[92]154CPPFLAGS="${save_CPPFLAGS}"
[632]155if test "${ac_cv_my_have_sdl}" = "no"; then
156  AC_MSG_ERROR([[One of SDL, SDL_Image or SDL_Mixer not found]])
157else
[680]158  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
[92]159fi
160AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
161
162
[682]163dnl Use EGL?
164ac_cv_my_have_egl="no"
165PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
166if test "${ac_cv_my_have_egl}" != "no"; then
167  AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
168  EGL_LIBS="${EGL_LIBS} -lX11"
169fi
170AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
171
172
[711]173dnl Use libpng? (replacement for SDL_image)
174ac_cv_my_have_libpng="no"
175PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
176if test "${ac_cv_my_have_libpng}" != "no"; then
177  AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
178fi
179AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
180
181
[623]182dnl Use libcaca? (required for font generation)
[178]183ac_cv_my_have_caca="no"
184PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
185if test "${ac_cv_my_have_caca}" != "no"; then
186  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
[92]187fi
[178]188AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
[92]189
[178]190
[623]191dnl Use libpipi? (required for video recording)
[178]192ac_cv_my_have_pipi="no"
193PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
194if test "${ac_cv_my_have_pipi}" != "no"; then
195  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
196fi
197AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
198
199
[623]200dnl Use GTK+? (required for the deushax editor)
[628]201ac_cv_my_have_gtkgl="no"
202PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
203PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
204if test "${ac_cv_my_have_gtkgl}" != "no"; then
205  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
206fi
207AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
[623]208
[642]209
210dnl Use cppunit for unit tests?
211PKG_CHECK_MODULES(CPPUNIT, cppunit, [CPPUNIT="yes"], [CPPUNIT="no"])
212AM_CONDITIONAL(USE_CPPUNIT, test "$CPPUNIT" = "yes")
213
214
[700]215dnl How to use the Lol Engine inside this tree
[796]216LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
217LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $EGL_CFLAGS $GLEW_CFLAGS $LIBPNG_CFLAGS"
218LOL_LIBS="$LOL_LIBS $SDL_LIBS $EGL_LIBS $GLEW_LIBS $LIBPNG_LIBS"
[220]219
[92]220AC_SUBST(MATH_LIBS)
[220]221AC_SUBST(LOL_CFLAGS)
222AC_SUBST(LOL_LIBS)
[92]223
[793]224AC_CONFIG_FILES(
225 [Makefile
[92]226  src/Makefile
[642]227  test/Makefile
[92]228  gfx/Makefile
229  gfx/font/Makefile
[785]230  tools/Makefile
[92]231])
[793]232AC_CONFIG_FILES(
233 [monsterz/Makefile
[785]234])
[793]235AC_CONFIG_FILES(
236 [deushax/Makefile
[785]237  deushax/art/Makefile
238  deushax/art/test/Makefile
239  deushax/gfx/Makefile
240  deushax/maps/Makefile
241])
[92]242
243AC_OUTPUT
244
Note: See TracBrowser for help on using the repository browser.