initial commit, lordsawar source, slightly modified
[lordsawar] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl This is useful to force using autoreconf 2.5.x
3 AC_PREREQ(2.59)
4 AC_INIT([lordsawar], [0.1.7-pre2], [http://sv.nongnu.org/bugs/?group=lordsawar], [lordsawar])
5 AC_CONFIG_SRCDIR([config.h.in])
6 AM_CONFIG_HEADER(config.h)
7 AC_CONFIG_MACRO_DIR([m4])
8
9 AC_CANONICAL_HOST
10 AC_CANONICAL_TARGET
11
12 AM_INIT_AUTOMAKE
13
14 IT_PROG_INTLTOOL([0.35.5])
15
16 GETTEXT_PACKAGE=lordsawar
17 AC_SUBST(GETTEXT_PACKAGE)
18 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"],
19                    [The domain to use with gettext])
20 AM_GLIB_GNU_GETTEXT
21
22 PROGRAMNAME_LOCALEDIR=[${datadir}/locale]
23 AC_SUBST(PROGRAMNAME_LOCALEDIR)
24     
25 dnl Checks for programs.
26 AC_PROG_CXX
27 AC_PROG_LIBTOOL
28
29 dnl The minimum SDL version required
30 SDL_VERSION=1.2.0
31
32 ac_save_ldflags=$LDFLAGS
33 dnl Check for SDL
34 AM_PATH_SDL($SDL_VERSION,
35             :,
36             AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
37 )
38         
39 LDFLAGS=$ac_save_ldflags
40 AC_SUBST(SDL_CFLAGS)
41
42 dnl And check for SDL_mixer. In detail, we need .ogg support
43 dnl we need some extended cflags or get problems
44 ac_save_cflags=$CFLAGS
45 ac_save_ldflags=$LDFLAGS
46 ac_save_libs=$LIBS
47
48 use_sound=1
49 AC_ARG_ENABLE(sound, [  --enable-sound         Enable or disable sound usage (default on)],
50                 use_sound="$enableval", use_sound="yes")
51
52 SDLSOUND_LIBS=
53 if test $use_sound = yes; then
54
55     CFLAGS="$CFLAGS $SDL_CFLAGS"
56     LDFLAGS="$LDFLAGS -lSDL_mixer"
57     LIBS="-lSDL_mixer $LIBS"
58     
59     dnl check if ogg vorbis support is enabled
60     dnl only under linux the SDL_mixer under windows supports it
61     if test $CC = "gcc" || test $CXX = "g++"; then
62
63        AC_TRY_RUN([
64        #include <SDL/SDL_mixer.h>
65        #include <stdio.h> 
66
67        int main()
68        {
69            if (!Mix_LoadMUS("${srcdir}" "/dat/music/victory.ogg"))
70                return -1;
71            return 0;
72        }
73        ],, AC_MSG_ERROR([*** SDL_mixer is not installed or has not been compiled
74                          *** with ogg vorbis support]),[])
75
76        AC_MSG_RESULT([Test SDL_Mixer Run OK.])
77
78     else AC_MSG_WARN([Skipping SDL_Mixer Run. We are cross-compiling for windows!])
79     fi
80
81     AC_DEFINE([FL_SOUND], 1, [enables sound])
82
83     SDLSOUND_LIBS="-lSDL_mixer"
84
85     CFLAGS=$ac_save_CFLAGS
86     LDFLAGS="$ac_save_LDFLAGS"
87     LIBS="$ac_save_libs"
88 fi
89 AC_SUBST(SDLSOUND_LIBS)
90
91         
92 dnl Check for expat
93 expat=0
94 AC_ARG_WITH(expat, [  --with-expat=<dir>      Use expat from here],
95                       [
96                       expat=$withval
97                       CPPFLAGS="$CPPFLAGS -I$withval/include"
98                       LDFLAGS="$LDFLAGS -L$withval/lib"
99                       LIBS="$LIBS -lexpat"
100                       ]
101                       )
102 #echo "EXPAT=$expat"
103 if test $expat = 0 ; then
104    AC_CHECK_HEADERS(expat.h,[],AC_MSG_ERROR([*** Expat not found!]))
105    AC_CHECK_LIB(expat,XML_ParserCreate,[],[AC_MSG_ERROR([*** Expat not found!])])
106 fi
107
108 dnl Check for libtar
109 libtar=0
110 AC_ARG_WITH(libtar, [  --with-libtar=<dir>      Use libtar from here],
111                       [
112                       libtar=$withval
113                       CPPFLAGS="$CPPFLAGS -I$withval/include"
114                       LDFLAGS="$LDFLAGS -L$withval/lib"
115                       LIBS="$LIBS -ltar"
116                       ]
117                       )
118 if test $libtar = 0 ; then
119    AC_CHECK_HEADERS(libtar.h,[],AC_MSG_ERROR([*** Libtar not found!]))
120    AC_CHECK_LIB(tar,tar_open,[],[AC_MSG_ERROR([*** Libtar not found!])])
121 fi
122
123 dnl this is needed in cross-compile with mingw32
124 AC_ARG_ENABLE(winlibs,             
125               [  --enable-winlibs         enable windows cross-compiling libs],
126               LIBS="-lmingw32 -lws2_32 -lintl -lz -lpthreadGC2 -lpthreadGCE2 $LIBS"
127               flrc=true;
128               ,flrc=false
129              )
130
131 AM_CONDITIONAL(FL_RESRC, test x$flrc = xtrue)
132
133 dnl Now check gettext.h
134 #winnls=no
135 #AC_ARG_ENABLE(winnls,             
136 #              [  --enable-winnls         enable windows cross-compiling nls],
137 #              USE_NLS=yes
138 #              winnls=yes
139 #              AC_SUBST(USE_NLS)
140 #             )
141
142 #if test $winnls = no ; then
143 AM_GNU_GETTEXT_VERSION([0.17])
144 AM_GNU_GETTEXT([external])
145 #fi
146
147 dnl Check for glib
148
149 PKG_CHECK_MODULES(GLIBMM, glibmm-2.4)
150
151 AC_SUBST(GLIBMM_CFLAGS)
152 AC_SUBST(GLIBMM_LIBS)
153
154 dnl Check for gtkmm
155
156 PKG_CHECK_MODULES(GTKMM, gtkmm-2.4)
157
158 AC_SUBST(GTKMM_CFLAGS)
159 AC_SUBST(GTKMM_LIBS)
160                                               
161 dnl Check for libgnet
162
163 PKG_CHECK_MODULES(LIBGNET, gnet-2.0)
164
165 AC_SUBST(LIBGNET_CFLAGS)
166 AC_SUBST(LIBGNET_LIBS)
167
168
169 dnl Finally, check for libsigc++
170 PKG_CHECK_MODULES(LIBSIGC, sigc++-2.0)
171
172 AC_SUBST(LIBSIGC_CFLAGS)
173 AC_SUBST(LIBSIGC_LIBS)
174 AC_SUBST(HOME)
175
176
177 dnl----------------------------------------------------------------------
178 dnl Below here are options to modify default behaviour
179
180 dnl Do we want to compile the editor?
181 AC_ARG_ENABLE(editor,
182             [  --enable-editor  compile editor (default=yes)],
183             use_editor="$enableval", use_editor="yes")
184 AM_CONDITIONAL([WANT_EDITOR], [test $use_editor = "yes"])
185
186 dnl Do we want to compile the play by mail server?
187 AC_ARG_ENABLE(pbm,
188             [  --enable-pbm     compile play-by-mail (default=yes)],
189             use_pbm="$enableval", use_pbm="yes")
190 AM_CONDITIONAL([WANT_PBM], [test $use_pbm = "yes"])
191
192 dnl ...the standard screen resolution...
193 AC_ARG_WITH(resolution,
194            [  --with-resolution=RES standard resolution for lordsawar [default=800x600]], 
195             SCREEN_RESOLUTION="$withval", SCREEN_RESOLUTION="800x600")
196 AC_SUBST(SCREEN_RESOLUTION)
197
198 dnl ...do we want to zip (and by the way obfuscate) the save files...
199 AC_ARG_ENABLE(zipfiles,
200              [  --enable-zipping    zip save files (experimental) [default=no]],
201              zipfiles="$enableval", zipfiles="no")
202
203 ZIP_FILES="false"
204 if test x$zipfiles = xyes; then
205     ZIP_FILES="true"
206 fi
207 AC_SUBST(ZIP_FILES)
208
209
210 dnl ..do we want to disable optimizations? (useful only for some debugging cases)...
211 AC_ARG_ENABLE(optimizations,
212              [  --enable-optimizations    enable compiler optimizations (disable for debugging) [default=yes]],
213              use_opts="$enableval", use_opts="yes")
214
215 if test x$use_opts = xno; then
216     AC_MSG_WARN([Optimizations have been disabled])
217     CXXFLAGS=-g
218 fi
219
220
221 AC_DEFUN([AC_CHOOSE_BOOST],[
222     am_boost_dir_default=ifelse([$1], , /usr/include, $1)
223     BOOST_CPPFLAGS=''
224     AC_ARG_WITH(boost_includedir,
225                 AS_HELP_STRING([--with-boost-includedir=DIR],
226                                [Use Boost library installed at specified path (default /usr/include)]),
227                 [am_boost_dir=$withval],
228                 [am_boost_dir=$am_boost_dir_default])
229
230     AC_MSG_CHECKING([for boost directory])
231     if test -d $am_boost_dir/boost; then
232         AC_MSG_RESULT([$am_boost_dir/boost])
233         BOOST_CPPFLAGS="-I$am_boost_dir"
234         old_CPPFLAGS=$CPPFLAGS
235         CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
236         AC_LANG_PUSH(C++)
237         AC_CHECK_HEADERS([boost/version.hpp],
238                          [ifelse([$2], , :, [$2])],
239                          [ifelse([$3], , :, [$3])])
240         AC_LANG_POP(C++)
241         CPPFLAGS=$old_CPPFLAGS
242         AC_SUBST(BOOST_CPPFLAGS)
243     else
244         AC_MSG_RESULT([not found])
245         AC_MSG_ERROR([*** Can't find directory $am_boost_dir/boost])
246         ifelse([$3], , :, [$3])
247     fi
248 ])
249
250 AC_CHOOSE_BOOST(,,[AC_MSG_ERROR([*** Boost library not found! Install it.])])
251
252
253 dnl ...and finally a workaround to get the absolute data path
254 if test x$prefix = xNONE; then
255     prefix="/usr/local"
256 fi
257
258 rm -f src/main.o
259
260 LORDSAWAR_DATADIR="$datadir/lordsawar"
261 LORDSAWAR_DATADIR=${LORDSAWAR_DATADIR/'${prefix}'/$prefix}
262 AC_SUBST(LORDSAWAR_DATADIR)
263
264 AC_CONFIG_FILES([
265         dat/Makefile 
266         dat/army/Makefile 
267         dat/army/default/Makefile 
268         dat/army/bigdefault/Makefile 
269         dat/tilesets/Makefile
270         dat/tilesets/default/Makefile
271         dat/tilesets/bigdefault/Makefile
272         dat/tilesets/stark/Makefile
273         dat/tilesets/bigstark/Makefile
274         dat/tilesets/wesnoth/Makefile
275         dat/tilesets/bigwesnoth/Makefile
276         dat/shield/Makefile 
277         dat/shield/default/Makefile 
278         dat/shield/plain/Makefile 
279         dat/shield/dol/Makefile 
280         dat/citysets/Makefile 
281         dat/citysets/default/Makefile 
282         dat/citysets/bigdefault/Makefile 
283         dat/citysets/dol/Makefile 
284         dat/citysets/bigdol/Makefile 
285         dat/various/Makefile 
286         dat/various/items/Makefile
287         dat/various/editor/Makefile
288         dat/map/Makefile 
289         dat/music/Makefile
290         dat/glade/Makefile
291         dat/glade/editor/Makefile
292         po/Makefile.in
293         Makefile 
294         src/Makefile
295         doc/Makefile
296         help/Makefile
297         help/figures/Makefile
298         src/editor/Makefile
299         src/pbm/Makefile
300         src/gui/Makefile])
301 AC_OUTPUT
302 echo ""
303 echo "LordsAWar is now configured. Type 'make' to compile it."
304 echo ""
305 echo "Configuration:"
306 echo " Installation location : $prefix"
307 echo " Editor compilation    : $use_editor"
308 echo " Play-by-mail          : $use_pbm"
309 echo " Sound support         : $use_sound"
310 echo ""
311 echo "Extra Options:"
312 echo " Compiler Optimizations: $use_opts"