AC_INIT
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

AC_PROG_CC
AC_PROG_CXX

dnl------------ libtool configuration
dnl Enable building of the convenience library
dnl and set LIBLTDL accordingly
AC_LIBLTDL_CONVENIENCE
dnl Substitute INCLTDL and LIBLTDL in the Makefiles
AC_SUBST(INCLTDL)
AC_SUBST(LIBLTDL)
dnl Prepare to make DLLs
AC_LIBTOOL_WIN32_DLL
dnl Check for dlopen support
AC_LIBTOOL_DLOPEN
dnl Configure libtool
AC_PROG_LIBTOOL
dnl Configure libltdl
AC_CONFIG_SUBDIRS(libltdl)

AC_MSG_CHECKING(if -no-undefined is required to build a shared library)
LT_LDFLAGS=
case $host in
  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
    LT_LDFLAGS=-no-undefined
    AC_MSG_RESULT(yes)
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
esac
AC_MSG_CHECKING(how to build plugins)
case $host in
  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
    PLUGIN_MAKEFILE_TARGET=all_win32_dlltool
    AC_MSG_RESULT(dlltool for cygwin/mingw)
    ;;
  *)
    PLUGIN_MAKEFILE_TARGET=all_libtool
    AC_MSG_RESULT(libtool)
    ;;
esac
AC_SUBST(PLUGIN_MAKEFILE_TARGET)


AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBS)
AC_SUBST(LT_LDFLAGS)

AC_OUTPUT(config.h Makefile test1-static/Makefile test2-dynamic/Makefile test3-twomodules/Makefile test4-interdep/Makefile test5-execsymbols/Makefile test6-ltdlopen/Makefile test7-win32dll/Makefile test8-execlass/Makefile test9-modclass/Makefile test10-modvirtual/Makefile test11-modglobalconstr/Makefile test12-modglobalconstr2/Makefile testscript)