Gobligine/configure.in
Pali Rohár 6481203460 Fix compilation warnings in mng.cpp
Enable autodetect mng support in configure.in
2010-11-03 16:55:01 +01:00

372 lines
10 KiB
Text

AC_INIT(configure.in)
AC_PREREQ([2.50])
CXXFLAGS=$CXXFLAGS
AC_PROG_CXX
AM_CONFIG_HEADER(config.h)
test "$prefix" = "NONE" && prefix=/usr/local
datarootdir=.
test "$datadir" = "NONE" && datadir=$datarootdir
PATH=$prefix/bin:$PATH
LDFLAGS="$LDFLAGS -L$prefix/lib -L$prefix/bin"
OBJDIR=obj
if test "`uname -a | grep -is cygwin`" -o "`uname -a | grep -is mingw`"; then
ARCH=win32
OBJDIR=winobj
CPPFLAGS="$CPPFLAGS -DUSE_WIN32"
elif test "`uname -a | grep -is bsd`"; then
ARCH=bsd
CPPFLAGS="$CPPFLAGS -DBSD"
elif test "`uname -a | grep -is beos`"; then
ARCH=beos
CPPFLAGS="$CPPFLAGS -DUSE_BEOS"
elif test "`uname -a | grep -is darwin`"; then
ARCH=macosx
CPPFLAGS="$CPPFLAGS -DUSE_MAC"
else
ARCH=linux
fi
## Maemo section
AC_ARG_ENABLE(maemo,
[ --enable-maemo Build for Linux Maemo based devices (default: autodetect)])
AC_MSG_CHECKING([whether we are building for Linux Maemo based devices])
if ( test "$ARCH" = "linux" && test -f /etc/maemo_version && test "$enable_maemo" != "no" ) || test "$enable_maemo" = "yes"; then
CPPFLAGS="$CPPFLAGS -DUSE_MAEMO -DHAVE_STRCASESTR -DHAVE_STRNLEN"
MAEMO=yes
CFLAGS="$CFLAGS $(pkg-config --cflags libosso)"
CXXFLAGS="$CXXFLAGS $(pkg-config --cflags libosso)"
LDFLAGS="$LDFLAGS $(pkg-config --libs libosso)"
else
MAEMO=no
fi
AC_MSG_RESULT($MAEMO)
if test "$ARCH" = "bsd" ; then
CPPFLAGS="$CPPFLAGS -I/usr/X11R6/include -I/usr/local/include"
LIBS="$LIBS -L/usr/local/lib"
fi
if test "$ARCH" = "macosx" ; then
if test -d /usr/local/include; then
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
fi
if test -d /usr/local/lib; then
LIBS="$LIBS -L/usr/local/lib"
fi
if test -d /sw/include; then
CPPFLAGS="$CPPFLAGS -I/sw/include"
fi
if test -d /sw/lib; then
LIBS="$LIBS -L/sw/lib"
fi
if test -d /opt/local/include; then
CPPFLAGS="$CPPFLAGS -I/opt/local/include"
fi
if test -d /opt/local/lib; then
LIBS="$LIBS -L/opt/local/lib"
fi
fi
dnl --- EXTRA DIRS -------------
AC_ARG_WITH(extra-includes,
[ --with-extra-includes=DIR [Location of additional include directiories]], CPPFLAGS="$CPPFLAGS -I$withval")
AC_ARG_WITH(extra-libs,
[ --with-extra-libs=DIR [Location of additional library directories]], LDFLAGS="$LDFLAGS -L$withval")
AC_CHECK_FUNCS(strcasestr)
AC_CHECK_FUNCS(strnlen)
AC_CHECK_HEADER(zlib.h,, AC_MSG_ERROR(could not find zlib.h))
AC_CHECK_HEADER(png.h,, AC_MSG_ERROR(could not find png.h))
AC_ARG_ENABLE(win32,
[ --enable-win32 Force win32, useful for cross-compiling (default: no)])
if test "$enable_win32" = "yes"; then
ARCH=win32
OBJDIR=winobj
CPPFLAGS="$CPPFLAGS -DUSE_WIN32"
PATH="/usr/local/cross/bin:$PATH"
fi
AC_SUBST(OBJDIR)
if test "$ARCH" != win32; then
AC_PATH_X
else
no_x=yes
fi
if test "$no_x" != "yes"; then
if test "x$x_includes" != "x"; then
CPPFLAGS="$CPPFLAGS -I$x_includes"
fi
if test "x$x_libraries" != "x"; then
LDFLAGS="$LDFLAGS -L$x_libraries"
fi
LDFLAGS="$LDFLAGS -lX11"
AC_DEFINE(HAVE_X, 1, Define to 1 if you have X. Used for pasting from the clipboard.)
fi
AC_ARG_ENABLE(static,
[ --enable-static Compile a static binary (default: no)])
if test "$enable_static" = "yes"; then
LDFLAGS="$LDFLAGS -static"
fi
AC_ARG_ENABLE(profile,
[ --enable-profile Enable profiling support, implies --enable-debug (default: no)])
if test "$enable_profile" = "yes"; then
CXXFLAGS="-pg"
fi
AC_ARG_ENABLE(debug,
[ --enable-debug [Enable debug (default: no)]])
if test "$enable_debug" != "yes" -a "$enable_profile" != "yes"; then
CXXFLAGS="$CXXFLAGS -O2 -pipe -pedantic -fsigned-char -fomit-frame-pointer -fexpensive-optimizations -ffast-math"
else
CXXFLAGS="$CXXFLAGS -O0 -g -pedantic -fsigned-char -fno-exceptions -Wsign-compare -Wall -Wextra -Werror"
CPPFLAGS="$CPPFLAGS -DDEBUG"
fi
dnl --- GLES ------------------
AC_ARG_WITH(gles,
[ --with-gles [Use OpenGL ES 1.1 instead OpenGL (default: autodetect)]])
if test "$with_gles" != "no"; then
AC_CHECK_HEADER(GLES/gl.h,, GLES=no)
AC_CHECK_HEADER(SDL/SDL_gles.h,, GLES=no)
if test "$GLES" != "no"; then
AC_SEARCH_LIBS(glViewport, GLES_CM, LDFLAGS="$LDFLAGS $LIBS", GLES=no)
AC_SEARCH_LIBS(SDL_GLES_Init, SDL_gles, LDFLAGS="$LDFLAGS $LIBS", GLES=no)
fi
if test "$with_gles" != "" -a "$GLES" = "no"; then
AC_MSG_ERROR(gles libraries cannot be not found)
fi
else
GLES=no
fi
if test "$GLES" = "no"; then
if test "$ARCH" = "win32"; then
AC_CHECK_LIB(opengl32, main, LDFLAGS="$LDFLAGS -lopengl32", AC_MSG_ERROR(opengl libraries cannot be not found))
else
AC_SEARCH_LIBS(glViewport, GL opengl32 sdl, LDFLAGS="$LDFLAGS $LIBS", AC_MSG_ERROR(opengl libraries cannot be not found))
fi
else
CPPFLAGS="$CPPFLAGS -DUSE_GLES"
fi
dnl --- BZIP2 ------------------
AC_ARG_WITH(bzip2,
[ --with-bzip2 [Use bzip2 (default: yes)]])
if test "$with_bzip2" != "no"; then
AC_CHECK_HEADER(bzlib.h,, BZIP2=no)
if test "$BZIP2" != "no"; then
AC_CHECK_LIB(bz2, main, CPPFLAGS="$CPPFLAGS -DUSE_BZ2LIB" LDFLAGS="$LDFLAGS -lbz2", BZIP2=no)
fi
if test "$BZIP2" = "no"; then
AC_MSG_ERROR(libbzip2 headers and/or libraries could not be found)
fi
fi
dnl --- VORBIS -----------------
AC_ARG_WITH(vorbis,
[ --with-vorbis [Use vorbis (default: autodetect)]])
if test "$with_vorbis" != "no"; then
AC_CHECK_HEADER(ogg/ogg.h,, VORBIS=no)
AC_CHECK_HEADER(vorbis/codec.h,, VORBIS=no)
if test "$VORBIS" != "no"; then
AC_CHECK_LIB(vorbis, vorbis_info_init, CPPFLAGS="$CPPFLAGS -DUSE_VORBIS" LDFLAGS="$LDFLAGS -lvorbis -logg", VORBIS=no, -logg)
fi
if test "x$with_vorbis" != "x" -a "$VORBIS" = "no"; then
AC_MSG_ERROR(vorbis headers and/or libraries could not be found)
fi
else
VORBIS=no
fi
dnl --- THEORA -----------------
AC_ARG_WITH(theora,
[ --with-theora [Use theora (default: autodetect)]])
if test "$with_theora" != "no"; then
if test "$VORBIS" = "no" -a "x$with_theora" != "x"; then
AC_MSG_ERROR(vorbis is required for theora support)
fi
AC_CHECK_HEADER(ogg/ogg.h,, THEORA=no)
AC_CHECK_HEADER(theora/theora.h,, THEORA=no)
if test "$THEORA" != "no"; then
AC_CHECK_LIB(theora, theora_decode_init, CPPFLAGS="$CPPFLAGS -DUSE_THEORA" LDFLAGS="$LDFLAGS -ltheora -logg", THEORA=no, -logg)
fi
if test "x$with_theora" != "x" -a "$THEORA" = "no"; then
AC_MSG_ERROR(theora headers and/or libraries could not be found)
fi
else
THEORA=no
fi
dnl --- MIKMOD -----------------
AC_ARG_WITH(mikmod,
[ --with-mikmod [Use mikmod (default: autodetect)]])
if test "$with_mikmod" != "no"; then
AC_CHECK_HEADER(mikmod.h,, MIKMOD=no)
if test "$MIKMOD" != "no"; then
AC_CHECK_LIB(mikmod, MikMod_Init, CPPFLAGS="$CPPFLAGS -DUSE_MIKMOD" LDFLAGS="$LDFLAGS -lmikmod", MIKMOD=no)
fi
if test "x$with_mikmod" != "x" -a "$MIKMOD" = "no"; then
AC_MSG_ERROR(mikmod headers and/or libraries could not be found)
fi
fi
dnl --- MNG --------------------
AC_ARG_WITH(mng,
[ --with-mng [Use mng (default: autodetect)]])
if test "$with_mng" != "no"; then
AC_CHECK_HEADER(libmng.h,, MNG=no)
if test "$MNG" != "no"; then
AC_CHECK_LIB(mng, main, CPPFLAGS="$CPPFLAGS -DUSE_MNG" LDFLAGS="$LDFLAGS -lmng", MNG=no)
fi
if test "x$with_mng" != "x" -a "$MNG" = "no"; then
AC_MSG_ERROR(mng headers and/or libraries could not be found)
fi
fi
dnl --- SDL --------------------
AC_CHECK_PROGS(SDLCONFIG, sdl-config)
if test "x$SDLCONFIG" = "x"; then
AC_CHECK_PROGS(SDLCONFIG, sdl11-config)
fi
if test "x$SDLCONFIG" = "x"; then
echo "*** sdl-config not found";
exit 1;
fi
CPPFLAGS="$CPPFLAGS `$SDLCONFIG --cflags`"
if test "$enable_static" != "yes"; then
LDFLAGS="$LDFLAGS `$SDLCONFIG --libs`"
else
LDFLAGS="$LDFLAGS `$SDLCONFIG --static-libs`"
fi
if test "$ARCH" = "win32"; then
AC_ARG_ENABLE(stdio-redirect,
[ --enable-stdio-redirect Redirect STDIO to files on Win32 (default: yes)])
if test "$enable_stdio_redirect" = "no"; then
CPPFLAGS="$CPPFLAGS -DNO_STDIO_REDIRECT"
fi
fi
dnl --- LUA includes -----------
AC_ARG_WITH(lua-includes, [ --with-lua-includes=DIR [Location of lua include directiories
(default: check [PREFIX/include/lua51], [PREFIX/include/lua5.1] and [/usr/include/lua51], [/usr/include/lua5.1])]], LUA_INCLUDES="$withval")
if test "$LUA_INCLUDES" != ""; then
CPPFLAGS="$CPPFLAGS -I$LUA_INCLUDES"
fi
if test -d "$prefix/include/lua51"; then
CPPFLAGS="$CPPFLAGS -I$prefix/include/lua51"
fi
if test -d "$prefix/include/lua5.1"; then
CPPFLAGS="$CPPFLAGS -I$prefix/include/lua5.1"
fi
if test -d "/usr/include/lua51"; then
CPPFLAGS="$CPPFLAGS -I/usr/include/lua51"
fi
if test -d "/usr/include/lua5.1"; then
CPPFLAGS="$CPPFLAGS -I/usr/include/lua5.1"
fi
dnl --- LUA --------------------
if test "$ARCH" = "linux"; then
LDFLAGS="$LDFLAGS -ldl"
fi
AC_CHECK_HEADER(lua.h,, AC_MSG_ERROR(could not find lua.h))
AC_SEARCH_LIBS(lua_getfenv, lua lua51 lua5.1, LDFLAGS="$LDFLAGS $LIBS", AC_MSG_ERROR(Lua5.1 is required))
AC_SEARCH_LIBS(luaopen_base, lualib lualib51 lualib5.1, LDFLAGS="$LDFLAGS $LIBS", AC_MSG_ERROR(Lualib5.1 is required))
eval PKGDATADIR="$datadir"
AC_DEFINE_UNQUOTED(PKGDATADIR, "$PKGDATADIR",
[Define this to the path containing the game data.]
)
AC_SUBST(PKGDATADIR)
eval PREFIX="$prefix"
AC_DEFINE_UNQUOTED(PREFIX, "$PREFIX",
[Define this to the prefix of the path to install stratagus to.]
)
AC_SUBST(PREFIX)
if test "$ARCH" = "win32"; then
if test "`uname -a | grep -is cygwin`"; then
LDFLAGS="$LDFLAGS -lws2_32"
else
LDFLAGS="$LDFLAGS -lws2_32 -lmingwex"
fi
if ! test `echo $host | grep -is amd64`; then
LDFLAGS="$LDFLAGS -lwsock32"
fi
if ! test `echo $host | grep -is amd64` && ! test "`uname -a | grep -is cygwin`"; then
LDFLAGS="$LDFLAGS -lgmon"
fi
fi
if test "$ARCH" = "win32"; then
if test "$WINDRES" == ""; then
WINDRES="$host-windres";
fi
AC_CHECK_PROGS(WINDRES_CHECK, $WINDRES)
if test "x$WINDRES_CHECK" = "x"; then
WINDRES="windres"
AC_CHECK_PROGS(WINDRES_CHECK, $WINDRES)
fi
if test "x$WINDRES_CHECK" = "x"; then
echo "*** windres not found"
exit 1
fi
else
WINDRES=""
fi
if test "$STRIP" == ""; then
STRIP="$host-strip";
fi
AC_CHECK_PROGS(STRIP_CHECK, $STRIP)
if test "x$STRIP_CHECK" = "x"; then
STRIP="strip"
AC_CHECK_PROGS(STRIP_CHECK, $STRIP)
fi
if test "x$STRIP_CHECK" = "x"; then
echo "*** strip not found"
exit 1
fi
OUTFILE=stratagus
if test "$ARCH" = "win32"; then
OUTFILE=stratagus.exe
fi
AC_SUBST(OUTFILE)
AC_SUBST(WINDRES)
AC_SUBST(STRIP)
AC_SUBST(CPPFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(LDFLAGS)
if test "$ARCH" = "win32"; then
if ! test -f Rules.make; then
echo "include Rules.make.WIN32" >Rules.make
else
# touch it for dependency reasons
touch Rules.make
fi
AC_CONFIG_FILES(Rules.make.WIN32:Rules.make.in)
else
AC_CONFIG_FILES(Rules.make)
fi
AC_OUTPUT
# EOF #