source: trunk/configure.ac @ 644

Last change on this file since 644 was 644, checked in by sam, 10 years ago

Disable -O2 when in debug mode, and disable -g when in release mode.

File size: 4.5 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)])
46
47AC_ARG_ENABLE(cppunit,
48  [  --enable-cppunit        use cppunit for unit tests (autodetected)])
49
50AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
51
52if test "${enable_debug}" = "yes"; then
53  AC_DEFINE(_DEBUG, 1, Define to 1 to activate debug)
54  OPT="-O0"
55else
56  OPT="-O2"
57fi
58
59if test "${enable_release}" = "yes"; then
60  AC_DEFINE(FINAL_RELEASE, 1, Define to 1 to activate final release)
61  REL=""
62else
63  REL="-g"
64fi
65
66# Optimizations
67CXXFLAGS="${CXXFLAGS} ${REL} ${OPT} -fno-strength-reduce -fomit-frame-pointer"
68# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
69CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
70
71AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
72
73# Use SDL? (always required)
74ac_cv_my_have_sdl="yes"
75AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
76if test "${SDL_CONFIG}" != "no"; then
77  SDL_CFLAGS="${SDL_CFLAGS} `sdl-config --cflags`"
78  SDL_LIBS="${SDL_LIBS} `sdl-config --libs`"
79fi
80PKG_CHECK_MODULES(SDL, sdl, [:],
81 [SDL_LIBS="${SDL_LIBS} -lSDL"])
82AC_CHECK_LIB(GL, glLoadIdentity, SDL_LIBS="${SDL_LIBS} -lGL") # FIXME: hackish
83PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [:],
84 [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"])
85PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [:],
86 [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"])
87save_CPPFLAGS="${CPPFLAGS}"
88SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
89SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
90
91CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
92AC_CHECK_HEADERS(SDL_mixer.h, [:], [ac_cv_my_have_sdl="no"])
93AC_CHECK_HEADERS(SDL_image.h, [:], [ac_cv_my_have_sdl="no"])
94CPPFLAGS="${save_CPPFLAGS}"
95if test "${ac_cv_my_have_sdl}" = "no"; then
96  AC_MSG_ERROR([[One of SDL, SDL_Image or SDL_Mixer not found]])
97else
98  AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL_image)
99fi
100AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
101
102
103dnl Use libcaca? (required for font generation)
104ac_cv_my_have_caca="no"
105PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
106if test "${ac_cv_my_have_caca}" != "no"; then
107  AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
108fi
109AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
110
111
112dnl Use libpipi? (required for video recording)
113ac_cv_my_have_pipi="no"
114PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
115if test "${ac_cv_my_have_pipi}" != "no"; then
116  AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
117fi
118AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
119
120
121dnl Use GTK+? (required for the deushax editor)
122ac_cv_my_have_gtkgl="no"
123PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
124PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
125if test "${ac_cv_my_have_gtkgl}" != "no"; then
126  AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
127fi
128AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
129
130
131dnl Use cppunit for unit tests?
132PKG_CHECK_MODULES(CPPUNIT, cppunit, [CPPUNIT="yes"], [CPPUNIT="no"])
133AM_CONDITIONAL(USE_CPPUNIT, test "$CPPUNIT" = "yes")
134
135
136# How to use the Lol Engine inside this tree
137LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src $SDL_CFLAGS"
138LOL_LIBS="$LOL_LIBS $SDL_LIBS"
139
140AC_SUBST(MATH_LIBS)
141AC_SUBST(LOL_CFLAGS)
142AC_SUBST(LOL_LIBS)
143
144AC_CONFIG_FILES([
145  Makefile
146  src/Makefile
147  test/Makefile
148  monsterz/Makefile
149  deushax/Makefile
150  tools/Makefile
151  art/Makefile
152  art/test/Makefile
153  gfx/Makefile
154  gfx/font/Makefile
155  maps/Makefile
156])
157
158AC_OUTPUT
159
Note: See TracBrowser for help on using the repository browser.