dnl Process this file with autoconf to produce a configure script.
AC_INIT(preload.h)
AM_CONFIG_HEADER(conf.h)
AM_INIT_AUTOMAKE(pspell-modules, .11)

dnl Checks for programs.
AC_PROG_CXX
AC_LANG_CPLUSPLUS

dnl Configure libtool
AM_PROG_LIBTOOL

if test "$DONT_FIND_MODULES" != "1"
then
  echo "BEGIN FIND MODULES TEST" >> config.log
  echo "int main() {}" > confmain.cc
  $CXX -c confmain.cc -o confmain.o >> config.log 2>&1

  tmp_libdir=`(
    test "x$prefix" = xNONE && prefix="$ac_default_prefix"
    test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
    eval echo \""[$]libdir"\"
  )`
  
  LIBS="-L$tmp_libdir"

  define([TEST_MODULE],
  [
    AC_MSG_CHECKING(for $1 module)
    if (sh ./libtool --mode=link \
           $CXX confmain.o -o confmain -L$tmp_libdir -lpspell_$1 \
	                                          >> config.log 2>&1)
    then
      AC_MSG_RESULT(found)
      LIBS="$LIBS -lpspell_$1"
      AC_DEFINE(have_$1)
    else
      AC_MSG_RESULT(not found)
    fi
  ])
  
  TEST_MODULE(aspell)
  TEST_MODULE(ispell)
  
  rm confmain* .libs/confmain* 2>> config.log

fi

AC_OUTPUT(Makefile)
