dnl **************************************************************
dnl Process this file with autoconf to produce a configure script.
dnl **************************************************************

AC_PREREQ(2.50)
AC_INIT(wastesedge, 0.3.5, adonthell-devel@nongnu.org, wastesedge)
AM_INIT_AUTOMAKE(wastesedge, 0.3.5)

dnl ***************
dnl gettext support
dnl ***************

AM_GNU_GETTEXT([external])

dnl ********************
dnl Additional arguments
dnl ********************

AC_ARG_WITH(data-dir,
[  --with-data-dir=DIR     Directory where data files will be installed],
            adonthelldatadir="$withval", adonthelldatadir=none)

AC_ARG_WITH(adonthell-binary,
[  --with-adonthell-binary=PATH  to the 'adonthell' binary],
            adonthell_binary="$withval", adonthell_binary=none)

dnl Checking for Adonthell
if test x$adonthelldatadir = xnone; then
   AC_PATH_PROG(adonthell_binary, adonthell-0.3)
   if test x$adonthell_binary = x ; then
       echo "*** Waste's Edge requires the Adonthell game engine. Exiting ..."
       exit 1
   fi
else
   echo "Using $adonthell_binary as the Adonthell binary"
fi

dnl Checking for the proper version
AC_MSG_CHECKING(for Adonthell's version)
$adonthell_binary -v &> adonthell.ver

changequote(<<, >>)
adonthell_major_ver=`sed 's/\([0-9]*\)\.[0-9]*\.[0-9]*/\1/p; d' adonthell.ver`
adonthell_minor_ver=`sed 's/[0-9]*\.\([0-9]*\)\.[0-9]*/\1/p; d' adonthell.ver`
adonthell_micro_ver=`sed 's/[0-9]*\.[0-9]*\.\([0-9]*\)/\1/p; d' adonthell.ver` 
changequote([, ])

rm -f adonthell.ver

adonthellver="$adonthell_major_ver.$adonthell_minor_ver.$adonthell_micro_ver"

AC_MSG_RESULT($adonthellver)

if test $adonthell_major_ver -eq 0 -a $adonthell_minor_ver -eq 3 -a $adonthell_micro_ver -gt 4 ;
then
    haveadonthell=yes
fi

if test x$haveadonthell != xyes ; then
   echo "*** This version of Waste's Edge requires Adonthell v0.3.5 or greater!"
   exit 1
fi

dnl Checking for the Adonthell data directory
if test x$adonthelldatadir = xnone; then
   AC_MSG_CHECKING(for Adonthell data directory)
   adonthelldatadir=`$adonthell_binary -d`
   AC_MSG_RESULT($adonthelldatadir)
else
   echo "Destination directory: $adonthelldatadir"
fi

dnl Sets where the game will install itself
gamedatadir="${adonthelldatadir}/games/wastesedge"

AC_SUBST(gamedatadir)
AC_SUBST(adonthell_binary)

AC_OUTPUT([ 
wastesedge.desktop
wastesedge.spec
Makefile
audio/Makefile
gfx/cutscene/Makefile
gfx/mapcharacters/Makefile
gfx/mapobjects/exteriors/Makefile
gfx/mapobjects/floorings/Makefile
gfx/mapobjects/furnitures/Makefile
gfx/mapobjects/houses/redwyne-inn/Makefile
gfx/mapobjects/houses/Makefile
gfx/mapobjects/icons/arrows/Makefile
gfx/mapobjects/icons/Makefile
gfx/mapobjects/stairs/Makefile
gfx/mapobjects/terrains/Makefile
gfx/mapobjects/walls/cellar/Makefile
gfx/mapobjects/walls/inside/Makefile
gfx/mapobjects/walls/stone/Makefile
gfx/mapobjects/walls/Makefile
gfx/mapobjects/Makefile
gfx/portraits/Makefile
gfx/window/background/original/Makefile
gfx/window/background/silverleaf/Makefile
gfx/window/background/Makefile
gfx/window/border/original/mini/Makefile
gfx/window/border/original/normal/Makefile
gfx/window/border/original/Makefile
gfx/window/border/silverleaf/mini/Makefile
gfx/window/border/silverleaf/normal/Makefile
gfx/window/border/silverleaf/Makefile
gfx/window/border/Makefile
gfx/window/cursor/original/Makefile
gfx/window/cursor/silverleaf/Makefile
gfx/window/cursor/Makefile
gfx/window/font/blue/Makefile
gfx/window/font/green/Makefile
gfx/window/font/original/Makefile
gfx/window/font/red/Makefile
gfx/window/font/silverleaf/Makefile
gfx/window/font/violet/Makefile
gfx/window/font/white/Makefile
gfx/window/font/yellow/Makefile
gfx/window/font/Makefile
gfx/window/scrollbar/original/Makefile
gfx/window/scrollbar/silverleaf/Makefile
gfx/window/scrollbar/Makefile
gfx/window/Makefile
gfx/Makefile
m4/Makefile
maps/Makefile
pixmaps/Makefile
po/Makefile.in
scripts/dialogues/Makefile
scripts/game_events/Makefile
scripts/modules/Makefile
scripts/schedules/Makefile
scripts/schedules/audio/Makefile
scripts/schedules/mapcharacters/Makefile
scripts/schedules/mapviews/Makefile
scripts/Makefile
scripts/actions/Makefile
])
