source: trunk/configure.ac @ 642

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

Add an optional cppunit dependency for unit tests.

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