1#----------------------------------------------------------------------------
2# Autoconf input script. Start the ./autgen.sh script to create
3# configure script.
4#----------------------------------------------------------------------------
5AC_PREREQ([2.54])
6
7AC_INIT([lincity-ng], [2.0], [matze@braunis.de])
8AC_CONFIG_SRCDIR([mk/jam/build.jam])
9AC_CONFIG_AUX_DIR([mk/autoconf])
10
11AC_CANONICAL_BUILD
12AC_CANONICAL_HOST
13AC_CANONICAL_TARGET
14
15#----------------------------------------------------------------------------
16# Configuration header
17#----------------------------------------------------------------------------
18AC_CONFIG_HEADERS(config.h)
19
20# stupid autoconf is adding default -g -O2 flags when we don't want this :-/
21test ".$CXXFLAGS" = "." && CXXFLAGS=" "
22test ".$CFLAGS" = "." && CFLAGS=" "
23
24#----------------------------------------------------------------------------
25# Check for build variant (debug, profile, optimize)
26#----------------------------------------------------------------------------
27VARIANT=optimize
28AC_ARG_ENABLE([optimize], [AC_HELP_STRING([--enable-optimize],
29    [build with optimizations enabled (default YES)])],
30    [test "$enableval" = "yes" && VARIANT=optimize])
31
32AC_ARG_ENABLE([debug], [AC_HELP_STRING([--enable-debug],
33    [build with debugging information (default NO)])],
34    [test "$enableval" = "yes" && VARIANT=debug])
35
36AC_ARG_ENABLE([profile], [AC_HELP_STRING([--enable-profile],
37    [build with profiling information (default NO)])],
38    [test "$enableval" = "yes" && VARIANT=profile])
39AC_SUBST([VARIANT])
40
41#----------------------------------------------------------------------------
42# find applications
43#----------------------------------------------------------------------------
44AC_PROG_CXX
45AC_PROG_INSTALL
46AC_CHECK_PROGS([XGETTEXT], xgettext)
47AC_CHECK_PROGS([XSLTPROC], xsltproc)
48
49# check if our c++ compiler is gcc3.2 or newer
50AC_MSG_CHECKING([whether g++ is new enough])
51AC_LANG_SAVE
52AC_LANG_CPLUSPLUS
53AC_TRY_COMPILE([], [
54#ifndef __GNUC__
55#error no gcc compiler found (__GNUC__ not defined)
56#endif
57#if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC__ < 2)
58#error gcc compiler too old. Need at least version 3.2.0
59#endif
60], [AC_MSG_RESULT([yes])], [
61	AC_MSG_RESULT([no])
62	AC_MSG_ERROR([
63Error: Your gcc version is too old. Lincity-ng needs at least gcc 3.2.0.
64])])
65AC_LANG_RESTORE
66
67#----------------------------------------------------------------------------
68# check headers
69#----------------------------------------------------------------------------
70AC_HEADER_DIRENT
71AC_HEADER_TIME
72AC_HEADER_STDC
73
74# compiler characteristics
75AC_C_CONST
76AC_C_INLINE
77AC_CHECK_FUNCS(gettimeofday mkdir popen)
78
79AM_ICONV
80AC_SUBST([ICONV_LIBS], [$LIBICONV])
81
82#----------------------------------------------------------------------------
83# find libraries
84#----------------------------------------------------------------------------
85AM_BINRELOC
86
87NP_FINDLIB([ZLIB], [zlib], [zlib],
88	NP_LANG_PROGRAM([[#include <zlib.h>]],
89            [[gzFile* file = gzopen("", "");]]),
90	[], [-lz],
91	[],
92	[AC_MSG_ERROR([Please install zlib])])
93
94PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.6.11])
95
96AX_CHECK_GL
97if test "$no_gl" = "yes"; then
98    AC_MSG_ERROR([Couldn't find opengl libraries or headers])
99fi
100
101AM_PATH_SDL([1.2.5], , AC_MSG_ERROR([Please install libsdl >= 1.2.5]))
102
103NP_FINDLIB([SDLMIXER], [SDL_mixer], [SDL_mixer >= 1.2],
104	NP_LANG_PROGRAM([#include <SDL_mixer.h>
105#if MIX_MAJOR_VERSION < 1
106# error SDLMix too old
107#else
108# if MIX_MAJOR_VERSION == 1
109#  if MIX_MINOR_VERSION < 2
110#   error SDLMix too old
111#  endif
112# endif
113#endif], [Mix_OpenAudio(0, 0, 0, 0);]),
114	[], [-lSDL_mixer],
115	[],
116	[AC_MSG_ERROR([Please install SDLMixer >=1.2.2])],
117	[$SDL_CFLAGS], [$SDL_LIBS])
118
119NP_FINDLIB([SDLIMAGE], [SDL_image], [SDL_image >= 1.2],
120	NP_LANG_PROGRAM([#include <SDL_image.h>], [IMG_Load("");]),
121	[], [-lSDL_image],
122	[],
123	[AC_MSG_ERROR([Please install SDLImage >= 1.2.1])],
124	[$SDL_CFLAGS], [$SDL_LIBS])
125
126NP_FINDLIB([SDLTTF], [SDL_ttf], [SDL_ttf >= 2.0.8],
127NP_LANG_PROGRAM([#include <SDL_ttf.h>], [if(!TTF_WasInit()) TTF_Init();]),
128	[], [-lSDL_ttf],
129	[],
130	[AC_MSG_ERROR([Please install SDL_ttf >= 2.0.8])],
131	[$SDL_CFLAGS], [$SDL_LIBS])
132
133NP_FINDLIB([SDLGFX], [SDL_gfx], [SDL_gfx >= 2.0.13],
134		NP_LANG_PROGRAM([#include <SDL_gfxPrimitives.h>
135#if SDL_GFXPRIMITIVES_MAJOR < 2
136# error SDL_GFX too old
137#endif
138], [hlineColor(0, 0, 0, 0, 0);]),
139	[], [-lSDL_gfx],
140	[],
141	[AC_MSG_ERROR([Please install SDL_gfx >= 2.0.13])],
142	[$SDL_CFLAGS], [$SDL_LIBS])
143
144NP_FINDLIB([PHYSFS], [physfs], [physfs >= 1.0.0],
145	NP_LANG_PROGRAM([
146#include <stdio.h>
147#include <physfs.h>
148#if PHYSFS_VER_MAJOR < 1
149# error PHYSFS is too old
150#endif]),
151	[], [-lphysfs],
152	[],
153	[AC_MSG_ERROR([Please install physfs >= 1.0])])
154
155AC_INIT_JAM
156AC_CONFIG_FILES([Jamconfig])
157
158# We have a config.h file
159CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H"
160
161AC_OUTPUT
162
163AC_MSG_NOTICE([
164
165Notice: This project uses jam (and not make) as build tool.
166])
167