The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
AC_INIT(config.pl.in)

if test -z "$IN_GIMP"; then
   echo
   echo "*** WOAH there! ***"
   echo Please do NOT call configure directly, rather run
   echo perl Makefile.PL
   echo as you would do with any other perl extension...
   echo "This time I'll be doing it for you!"
   echo
   perl Makefile.PL
   exit
fi

AC_PREFIX_DEFAULT($prefix)dnl from Makefile.PL

AC_CONFIG_HEADER(config.h)

AC_ARG_WITH(cflags,  [  --with-cflags=FLAGS     Set CFLAGS to FLAGS (optional)],
   CFLAGS="$with_cflags")

AC_ARG_WITH(ldflags, [  --with-ldflags=FLAGS    Set LDFLAGS to FLAGS (optional)],
   LDFLAGS="$with_ldflags")

AC_ARG_WITH(includes,[  --with-includes=DIR     Additionally search for includes in dir DIR (optional)],
   CPPFLAGS="$CPPFLAGS -I$with_includes")

AC_ARG_WITH(libs,    [  --with-libs=DIR         Additionally search for libraries in dir in DIR (optional)],
   LIBS="$LIBS -L$with_libs")

AC_PATH_PROGS(GIMP,gimp)

AM_PATH_GIMP(1.0.4,, AC_MSG_WARN(
** unable to find gimp, make sure it's in your path (version 1.0.4+ required!)
** You can get the gimp from ftp://ftp.gimp.org/pub/gimp.
))

gimptool_major_version=`$GIMPTOOL $gimptool_args --version | \
   sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
gimptool_minor_version=`$GIMPTOOL $gimptool_args --version | \
   sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`

if test $gimptool_major_version -lt 2 && test $gimptool_minor_version -lt 1 ; then
   echo
   echo '** you are using a too old version of gimp (this includes all _stable_'
   echo '** 1.0.x versions!). While this plug-in should still compile with the'
   echo '** released 1.0.x versions of the gimp, many scripts will not, since they'
   echo '** already use the new API.'
   echo
fi


AM_PATH_GLIB(1.2.0,, AC_MSG_ERROR(
** unable to find glib, make sure it's in your path (version 1.2.0+ required!)
** You can get glib from ftp://ftp.gtk.org/pub/glib.
))

ac_gimp_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $GIMP_CFLAGS"
AC_EGREP_CPP(DIVIDE_MODE,[#include <libgimp/gimp.h>],AC_DEFINE(HAVE_DIVIDE_MODE))
AC_CHECK_HEADERS(libgimp/gimpmodule.h libintl.h)
CPPFLAGS="$ac_gimp_save_CPPFLAGS"

AC_CHECK_HEADERS(unistd.h)

CONFIG_H="config.h"

sinclude(configure.frag)

INTLLIBS=
MSGFMT=
AC_SUBST(INTLLIBS)
AC_SUBST(MSGFMT)

AC_OUTPUT(config.pl)

echo "now invoking perl to complete the configuration..."
exec $PERL $MAKEFILE_PL --writemakefile PREFIX="$prefix"