source: trunk/configure.ac @ 632

Last change on this file since 632 was 632, checked in by sam, 11 years ago

Properly detect SDL libraries when sdl-config and pkg-config are here
together.

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