configure.in 10.6 KB
Newer Older
1 2 3 4 5 6 7 8
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.52)
AC_INIT(README)
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

APP_MAJOR_VERSION=1
APP_MINOR_VERSION=2
9
APP_MICRO_VERSION=4
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
APP_VERSION=$APP_MAJOR_VERSION.$APP_MINOR_VERSION.$APP_MICRO_VERSION
APP_UNDERSCORE_VERSION=${APP_MAJOR_VERSION}_${APP_MINOR_VERSION}_${APP_MICRO_VERSION}

AC_SUBST(APP_MAJOR_VERSION)
AC_SUBST(APP_MINOR_VERSION)
AC_SUBST(APP_MICRO_VERSION)
AC_SUBST(APP_VERSION)
AC_SUBST(APP_UNDERSCORE_VERSION)

AM_INIT_AUTOMAKE(adanaxisgpl,$APP_VERSION)
TOP_SUBDIRS="src data-adanaxis"
AC_SUBST(TOP_SUBDIRS)
AM_CONFIG_HEADER(config.h)

SDL_EXTRA_LIBS=""

dnl Checks for programs.
AC_PROG_MAKE_SET
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PATH_PROG(ac_prog_find, find)
AC_PATH_PROG(ac_prog_sdl_config, sdl-config)
if test "x$ac_prog_sdl_config" = "x"; then
    AC_PATH_PROG(ac_prog_sdl_config2, sdl11-config, "", [[$PATH:/usr/local/bin]])
    ac_prog_sdl_config="$ac_prog_sdl_config2"
fi
if test "x$ac_prog_sdl_config" = "x"; then
    AC_PATH_PROG(ac_prog_sdl_config3, sdl-config, "", [[/usr/local/bin]])
    ac_prog_sdl_config="$ac_prog_sdl_config3"
fi
if test "x$ac_prog_sdl_config" = "x"; then
    AC_MSG_NOTICE([Couldn't find sdl-config command.  Build probably doomed.])
else
    CPPFLAGS="$CPPFLAGS `$ac_prog_sdl_config --cflags`"
    LIBS="$LIBS `$ac_prog_sdl_config --libs`"
    
    AC_ARG_WITH(nosdlmain, [  --with-nosdlmain        Remove -lSDLmain from configure's tests], [    
        case "$LIBS" in
            *-lSDLmain*)
                SDL_EXTRA_LIBS="-lSDLmain"
                AC_MSG_NOTICE([Temporarily removed -lSDLmain from LIBS])
            ;;
        esac
    
        LIBS=`echo $LIBS | sed -e 's/-lSDLmain//'`
    ])

    AC_MSG_NOTICE([sdl-config set CPPFLAGS to $CPPFLAGS])
    AC_MSG_NOTICE([sdl-config set LIBS to $LIBS])
fi

dnl Remove NDEBUG for development work
CFLAGS="$CFLAGS -I\${srcdir} -I\${srcdir}/API -DNDEBUG"
CPPFLAGS="$CPPFLAGS -I\${srcdir} -I\${srcdir}/API -DNDEBUG"

AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h sys/syscall.h fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h syscall.h pwd.h utime.h memory.h direct.h)

AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(long long, 0)
AC_CHECK_SIZEOF(void*, 4)
AC_CHECK_SIZEOF(float, 4)
AC_CHECK_SIZEOF(double, 8)
AC_CHECK_SIZEOF(time_t, 0)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_BIGENDIAN

dnl binreloc support
AM_BINRELOC

dnl Checks for libraries.
AC_CHECK_HEADER(windows.h)

AC_MSG_NOTICE([****************************************************************])
AC_MSG_NOTICE([*                                                              *])
AC_MSG_NOTICE([* Choosing a platform pack.  Please check that this is correct *])
AC_MSG_NOTICE([*                                                              *])
AC_MSG_NOTICE([****************************************************************])

dnl Get GL
case "$target" in
    powerpc-apple-darwin*)
        AC_MSG_NOTICE([* Assuming Darwin platform is MacOS X.])
        AC_MSG_NOTICE([* Using platform pack from src/Platform/MacOSX.])
        LIBS="$LIBS -lz -lobjc -framework OpenGL -framework GLUT -framework ApplicationServices -framework QuickTime -framework Carbon"
        AC_CHECK_HEADERS(OpenGL/gl.h,, AC_MSG_ERROR([Cannot survive without OpenGL]))
        AC_CHECK_HEADERS(OpenGL/glu.h,, AC_MSG_ERROR([Cannot survive without OpenGL and GLU]))
        AC_CHECK_HEADERS(GLUT/glut.h,, AC_MSG_ERROR([Cannot survive without OpenGL and GLUT]))
        CPPFLAGS="$CPPFLAGS -I\${srcdir}/Platform/MacOSX -fpascal-strings"
        AC_LANG(C++)
        ;;
    *)
        if test "x$ac_cv_header_windows_h" = "xyes" ; then
            AC_MSG_NOTICE([* Header windows.h detected.  Assuming target is Windows.])
            AC_MSG_NOTICE([* Using platform pack from src/Platform/win32.])
            AC_CHECK_LIB(opengl32, main,, AC_MSG_ERROR([Cannot survive without OpenGL]))
            AC_CHECK_LIB(glu32, main,, AC_MSG_ERROR([Cannot survive without OpenGL and GLU]))
dnl         AC_CHECK_LIB(glut32, main,, AC_MSG_ERROR([Cannot survive without OpenGL and GLUT]))
            AC_CHECK_LIB(wsock32, main,, AC_MSG_ERROR([Not configured to build without wsock32 library]))
            AC_CHECK_LIB(winmm, main,, AC_MSG_ERROR([Not configured to build without winmm library]))
            AC_CHECK_LIB(iphlpapi, main,, AC_MSG_ERROR([Not configured to build without iphlpapi library]))
            CFLAGS="$CFLAGS -I\${srcdir}/Platform/win32"
            CPPFLAGS="$CPPFLAGS -I\${srcdir}/Platform/win32"
        else
            AC_MSG_NOTICE([* Assuming generic X Windows platform.])
            AC_MSG_NOTICE([* Using platform pack from src/Platform/X11.])

            AC_LANG(C++)

            dnl We need the following for GL to link
            AC_PATH_XTRA
            CFLAGS="$CFLAGS"
            CPPFLAGS="$CPPFLAGS $X_CFLAGS"
            LDFLAGS="$LDFLAGS"
            LIBS="$LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
            AC_CHECK_LIB(m, main)
            AC_CHECK_LIB(Xext, main)
            AC_CHECK_LIB(dl, dlopen)
            AC_CHECK_LIB(crypt, crypt)

            AC_ARG_WITH(mesa, [  --with-mesa             Use MesaGL libs instead of GL LIBS], [
dnl Use Mesa
                AC_CHECK_LIB(MesaGL, main,, AC_MSG_ERROR([Cannot find and link MesaGL]))
                AC_CHECK_LIB(MesaGLU, main,, AC_MSG_ERROR([Cannot find and link MesaGLU]))
            ],[
dnl Use GL
                AC_CHECK_LIB(GL, main,, AC_CHECK_LIB(gl, main,, AC_MSG_ERROR([Cannot find and link GL.  Try --with-mesa])))
                AC_CHECK_LIB(GLU, main,, AC_CHECK_LIB(glu, main,, AC_MSG_ERROR([Cannot find and link GLU])))
            ])

            AC_CHECK_LIB(glut, main,, AC_CHECK_LIB(GLUT, main,, AC_MSG_ERROR([Cannot find and link GLUT])))
            CPPFLAGS="$CPPFLAGS -I\${srcdir}/Platform/X11"
        fi
        AC_CHECK_HEADERS(GL/gl.h,, AC_MSG_ERROR([No GL/gl.h header]))
        AC_CHECK_HEADERS(GL/glu.h,, AC_MSG_ERROR([No GL/glu.h header]))
dnl     AC_CHECK_HEADERS(GL/glext.h,, AC_MSG_NOTICE([No GL/glext.h header]))
dnl     AC_CHECK_HEADERS(GL/glut.h,, [AC_CHECK_HEADERS(GLUT/glut.h,, AC_MSG_ERROR([No glut.h header]))])
        ;;
esac

AC_FUNC_MEMCMP
AC_REPLACE_FUNCS(dup2 memmove strcasecmp strncasecmp strerror strftime strchr strstr strtoul crypt flock acosh erf)
AC_CHECK_FUNCS(getcwd fcntl lockf symlink pause dlopen telldir seekdir mktime timegm cosh sinh tanh)

AC_CHECK_LIB(PCRE, main,, AC_CHECK_LIB(pcre, main,, AC_MSG_ERROR([PCRE library not found - home is ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/])))
AC_CHECK_LIB(expat, main,, AC_MSG_ERROR([expat library not found - home is http://expat.sourceforge.net/]))
AC_CHECK_LIB(jpeg, main,, AC_MSG_ERROR([libjpeg library not found - home is http://www.ijg.org/]))
AC_CHECK_LIB(tiff, main,, AC_MSG_ERROR([libtiff library not found - home is http://www.libtiff.org/]))
AC_CHECK_LIB(SDL-1.1, main,, AC_CHECK_LIB(SDL, main,, AC_MSG_ERROR([libSDL library not found - home is http://www.libsdl.org/])))
AC_CHECK_LIB(ogg, main,, AC_MSG_ERROR([libogg library not found - home is http://www.xiph.org/]))
AC_CHECK_LIB(vorbis, main,, AC_MSG_ERROR([libvorbis library not found - home is http://www.xiph.org/]))
AC_CHECK_LIB(vorbisfile, main,, AC_MSG_ERROR([libvorbisfile library not found - home is http://www.xiph.org/]))
AC_CHECK_LIB(SDL_mixer, main,, AC_MSG_ERROR([libSDL_mixer library not found - home is http://www.libsdl.org/]))
 
AC_CHECK_HEADERS(pcre.h,, [AC_CHECK_HEADERS(pcre/pcre.h,, AC_MSG_ERROR([Cannot find pcre.h header]))])
AC_CHECK_HEADERS(expat.h,, [AC_CHECK_HEADERS(expat/expat.h,, AC_MSG_ERROR([Cannot find expat.h header]))])
AC_CHECK_HEADERS(SDL.h,, [AC_CHECK_HEADERS(SDL/SDL.h,, AC_MSG_ERROR([Cannot find SDL.h header]))])
AC_CHECK_HEADERS(SDL_mixer.h,, [AC_CHECK_HEADERS(SDL/SDL_mixer.h,, AC_MSG_ERROR([Cannot find SDL_mixer.h header]))])
AC_CHECK_HEADERS(SDL_main.h,, [AC_CHECK_HEADERS(SDL/SDL_main.h,, AC_MSG_ERROR([Cannot find SDL_main.h header]))])
AC_CHECK_HEADERS(SDL_opengl.h,, [AC_CHECK_HEADERS(SDL/SDL_opengl.h,, AC_MSG_NOTICE([Cannot find SDL_opengl.h header]))])
 
dnl Switch to C++ for sstream and valarray
AC_LANG(C++)

dnl Checks for header files
AC_CHECK_HEADERS(sstream,,[
AC_MSG_WARN([sstream not found.  Using copy from distribution])
CPPFLAGS="$CPPFLAGS -I\${srcdir}/Support/gcc-2.95.2"
])

AC_CHECK_HEADERS(valarray,,[
AC_MSG_WARN([valarray not found.  Will fall back to vector])
])

dnl Checks for library functions.
AC_TRY_COMPILE([
#if defined(HAVE_SDL_SDL_MIXER_H)
#include <SDL/SDL_mixer.h>
#else
#if defined(HAVE_SDL_MIXER_H)
#include <SDL_mixer.h>
#else
#include "SDL_mixer.h"
#endif
#endif

#undef main
],[
Mix_ChannelFinished(0)
],
[
AC_DEFINE(HAVE_MIX_CHANNELFINISHED,1,[Define if Mix_ChannelFinished exists in SDL_mixer.h])
],[
AC_MSG_WARN([Old version of SDL_mixer.  End-of-channel events disabled.])
]
)

AC_TRY_COMPILE([
#define USE_RWOPS 1
#if defined(HAVE_SDL_SDL_MIXER_H)
#include <SDL/SDL_mixer.h>
#else
#if defined(HAVE_SDL_MIXER_H)
#include <SDL_mixer.h>
#else
#include "SDL_mixer.h"
#endif
#endif

#undef main
],[
Mix_LoadMUS_RW(0)
],
[
AC_DEFINE(HAVE_MIX_LOADMUS_RW,1,[Define if Mix_LoadMUS_RW exists in SDL_mixer.h])
],[
AC_MSG_WARN([Old version of SDL_mixer (no Mix_LoadMUS_RW).  Music load from .mush files disabled.])
]
)

AC_TRY_COMPILE([
#include <iosfwd>
#undef main
],[
std::ostringstream test;
test << "bar";
],,[
AC_MSG_NOTICE([iosfwd does not define ostringstream])
AC_DEFINE(HAVE_SSTREAM_NOT_IN_IOSFWD,1,[Define if including iosfwd doesn't define ostringstream])
]
)
AC_TRY_COMPILE([
#include <sstream>
#undef main
],[
std::ostringstream test;
],,[
AC_MSG_ERROR([stringstream not available])
]
)

AC_TRY_COMPILE([
#if defined(HAVE_WINDOWS_H) || defined (_MSC_VER)
#include <windows.h>
#endif
#if defined(__APPLE__) || defined(MACOSX)
#define HAVE_OPENGL_GL_H
#define HAVE_OPENGL_GLU_H
#endif
#ifdef HAVE_GL_GL_H
#include <GL/gl.h>
#elif defined(HAVE_OPENGL_GL_H)
#include <OpenGL/gl.h>
#else
#include "GL/gl.h"
#endif
#undef main
void foo1(GLenum bar) {}
void foo1(unsigned int bar) {}
],[

],,[
AC_MSG_NOTICE([GLenum is unsigned int])
AC_DEFINE(HAVE_GLENUM_IS_UNSIGNED_INT,1,[Define if GLenum is of type unsigned int])
]
)
dnl Check that autogenerated Makefile.am files are there
AC_CHECK_FILE(src,[
AC_CHECK_FILE(src/Makefile.am,,[
AC_MSG_ERROR([src/Makefile.am not present.  Please run autogen])
])
])

LIBS="$LIBS $SDL_EXTRA_LIBS"

AC_OUTPUT(Makefile src/Makefile data-adanaxis/Makefile)
AC_MSG_NOTICE([Verdict was:])
AC_MSG_NOTICE([CPPFLAGS=$CPPFLAGS])
AC_MSG_NOTICE([LDFLAGS=$LDFLAGS])
AC_MSG_NOTICE([LIBS=$LIBS])