65568c0341627207aa393c5f02bc9348392562a0
[supertux.git] / configure.ac
1 dnl ===========================================================================
2 dnl    "configure.in"
3 dnl
4 dnl current contact:
5 dnl          SuperTux development team
6 dnl
7 dnl original author:
8 dnl          Duong-Khang NGUYEN
9 dnl          neoneurone@users.sf.net
10 dnl ===========================================================================
11
12 dnl Process this file with autoconf to produce a configure script.
13 AC_PREREQ([2.54])
14 AC_INIT(supertux, 0.2-cvs)
15 AC_CONFIG_SRCDIR([src/supertux.cpp])
16 AC_CONFIG_AUX_DIR([mk/autoconf])
17 AC_CANONICAL_TARGET
18
19 AC_CONFIG_HEADERS(config.h)
20
21 # we don't want the stupid autoconf default -g -O2
22 test ".$CXXFLAGS" = "." && CXXFLAGS=" "
23
24 CXXFLAGS="$CXXFLAGS -ffast-math"
25
26 AC_PROG_CC
27 AC_PROG_CXX
28 AC_PROG_INSTALL
29
30 AC_CHECK_PROGS(XGETTEXT, xgettext)
31
32 dnl Checks for header files.
33 AC_HEADER_DIRENT
34 AC_HEADER_STDC
35 AC_CHECK_HEADERS(unistd.h)
36
37 dnl Checks for typedefs, structures, and compiler characteristics.
38 AC_C_CONST
39
40 dnl ===========================================================================
41 dnl Give advanced users some options to play with
42
43 VARIANT=optimize
44 AC_MSG_CHECKING(for gprof mode)
45 AC_ARG_ENABLE(gprof,
46               AC_HELP_STRING([--enable-gprof], [enable GNU profiling support]),
47               [enable_gprof=$enableval], [enable_gprof=no])
48 if test "$enable_gprof" = "yes"; then
49     #CXXFLAGS="$CXXFLAGS -pg"
50     VARIANT=profile
51     AC_MSG_RESULT([enabled])
52 else
53     AC_MSG_RESULT([disabled])
54 fi
55
56 AC_MSG_CHECKING(for debug mode)
57 AC_ARG_ENABLE(debug,
58               AC_HELP_STRING([--enable-debug], [enable debugging mode]),
59               [enable_debug=$enableval], [enable_debug=no])
60 if test "$enable_debug" = "yes"; then
61     AC_DEFINE([DEBUG], 1, [define to compile in debug checks])
62     #CXXFLAGS="$CXXFLAGS -Wall -Werror -O0 -g3"
63     VARIANT=debug
64     AC_MSG_RESULT([enabled])
65 else
66     #CXXFLAGS="$CXXFLAGS -O2 -g"
67     VARIANT=optimize
68     AC_MSG_RESULT([disabled])
69 fi
70 AC_SUBST([VARIANT])
71
72 AC_MSG_CHECKING(wether OpenGL should be used)
73 AC_ARG_ENABLE(opengl,
74               AC_HELP_STRING([--disable-opengl], [disable OpenGL support]),
75               [enable_opengl=$enableval], enable_opengl=yes)
76 if test "$enable_opengl" = "yes"; then
77     AC_MSG_RESULT([yes])
78 else
79     AC_MSG_RESULT([no])
80 fi
81
82 iconv_found=no
83 AC_MSG_CHECKING([for iconv])
84 AC_TRY_LINK([#include <iconv.h>], [iconv_open(0, 0);], [iconv_found="yes"])
85 AS_IF([test "$iconv_found" = no],
86     LIBS="$LIBS -liconv"
87     AC_TRY_LINK([#include <iconv.h>], [iconv_open(0, 0);], [iconv_found="yes"]))
88 AS_IF([test "$iconv_found" = no],
89     AC_MSG_ERROR([Couldn't find iconv library]),
90     AC_MSG_RESULT([found]))
91
92 dnl ===========================================================================
93 dnl Check for SDL
94 SDL_VERSION=1.2.4
95 AM_PATH_SDL($SDL_VERSION,
96             :,
97             AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]))
98
99 NP_FINDLIB([SDLMIXER], [SDL_mixer], [SDL_mixer >= 1.2],
100         NP_LANG_PROGRAM([#include <SDL_mixer.h>
101 #if MIX_MAJOR_VERSION < 1
102 # error SDLMix too old
103 #else
104 # if MIX_MAJOR_VERSION == 1
105 #  if MIX_MINOR_VERSION < 2
106 #   error SDLMix too old
107 #  endif
108 # endif
109 #endif], [Mix_OpenAudio(0, 0, 0, 0);]),
110         [], [-lSDL_mixer],
111         [],
112         [AC_MSG_ERROR([Please install SDLMixer >=1.2.2])],
113         [$SDL_CFLAGS], [$SDL_LIBS])
114
115 NP_FINDLIB([SDLIMAGE], [SDL_image], [SDL_image >= 1.2],
116         NP_LANG_PROGRAM([#include <SDL_image.h>], [IMG_Load("");]),
117         [], [-lSDL_image],
118         [],
119         [AC_MSG_ERROR([Please install SDLImage >= 1.2.1])],
120         [$SDL_CFLAGS], [$SDL_LIBS])
121
122 if test "$enable_opengl" = "yes"; then
123   AX_CHECK_GL
124 fi
125 if test "$no_gl" = "yes" -o "$enable_opengl" = "no"; then
126   GL_AVAILABLE="no"
127   AC_DEFINE([NOOPENGL],, [Define if opengl should not be used])
128 else
129   GL_AVAILABLE="yes"
130 fi
131 AC_SUBST([GL_AVAILABLE])
132
133 dnl Checks for library functions.
134 AC_CHECK_FUNCS(mkdir strdup strstr)
135
136 AC_INIT_JAM
137 AC_CONFIG_FILES([Jamconfig])
138
139 AC_OUTPUT
140
141 echo ""
142 echo "Features:"
143 echo "========="
144 echo " Profile Mode:   $enable_gprof"
145 echo " Debug Mode:     $enable_debug"
146 echo " OpenGL Support: $enable_opengl"
147 echo ""
148 echo ""
149 echo "       NOTE: This project uses jam (and not make) as build tool"
150 echo ""
151