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

dnl Are we in the right directory?  Check for the existence of xplanet.cc.
AC_INIT(xplanet.cc)

AC_CONFIG_AUX_DIR(./autoconf)

AC_PATH_PROG(CP, cp, cp)
AC_PATH_PROG(GZIP, gzip, gzip)
AC_PROG_INSTALL
AC_PATH_PROG(RM, rm, rm)
AC_PATH_PROG(STRIP, strip, strip)
AC_PATH_PROG(TAR, tar, tar)
AC_PATH_PROG(WISH, wish, wish)

version="0.43"
AC_SUBST(version)

dnl Checks for compilers.
AC_PROG_CC
AC_PROG_CXX

dnl Locate X include files and libraries
AC_PATH_XTRA

dnl Check for strptime function
AC_CONFIG_HEADER(checkfuncs.h)
AC_CHECK_FUNC(strptime, AC_DEFINE(HAVE_STRPTIME))

AC_CHECK_HEADERS(string.h strings.h)

dnl Check for getopt_long
dnl AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPT_LONG))

if test "x$GXX" = "xyes"; then
    OTHER_CXXFLAGS="-Wall -O3"
fi
AC_SUBST(OTHER_CXXFLAGS)

AC_ARG_WITH(auxdir, [  --with-auxdir=DIR       subdirectory under PREFIX containing map and marker 
                          files [share/xplanet]], auxdir="$withval", auxdir="share/xplanet")
AC_SUBST(auxdir)

AC_ARG_WITH(map-extension, [  --with-map-extension=EXTENSION
                          use EXTENSION as default map extension [ppm]], mapext="$withval", mapext="ppm")
AC_SUBST(mapext)

AC_ARG_WITH(markerfile, [  --with-markerfile=FILE  use (planet-name)-FILE as default marker file 
                          [-markers.txt]], markerfile="$withval", markerfile="-markers.txt")
AC_SUBST(markerfile)

# Macros to check for OpenGL/Mesa are adapted from xscreensaver-3.14
AM_FIND_GL

# Macros to check for Imlib from James Baughman
AM_PATH_IMLIB(1.8.0, , [
echo "ERROR: xplanet needs a system with Imlib 1.8.2 or higher"
echo "You can obtain it from:"
echo "ftp://ftp.enlightenment.org/pub/enlightenment/"
echo "ftp://www.rasterman.com/pub/enlightenment/"
echo "ftp://ftp.labs.redhat.com/pub/imlib/"
AC_MSG_ERROR([Fatal Error: no Imlib detected.])])

AC_OUTPUT(Makefile auxfiles.h tkxplanet)

echo "
xplanet $version is now hopefully configured!
"
