+AC_CHECK_FUNCS(access ftime getclock getpagesize getrusage gettimeofday mktime mprotect readlink setitimer stat lstat symlink sysconf timelocal times vadvise vfork localtime_r gmtime_r readdir_r getgrgid_r getgrnam_r getpwuid_r getpwnam_r)
+
+dnl ** Solaris2 needs additionl flag for getpw*_r()
+case "$TargetPlatform" in
+ *-solaris2*)
+ unix_SRC_HSC2HS_OPTS="-D_POSIX_PTHREAD_SEMANTICS"
+ AC_SUBST(unix_SRC_HSC2HS_OPTS)
+ ;;
+esac
+
+dnl ** check whether this machine has gmp3 installed
+AC_CHECK_LIB(gmp, __gmpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp,
+ AC_CHECK_LIB(gmp3, __gmpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp3,
+ HaveLibGmp=NO; LibGmp=not-installed))
+AC_SUBST(HaveLibGmp)
+AC_SUBST(LibGmp)
+
+dnl ** (Mac OS X only: check for HaskellSupport.framework)
+HaveFrameworkHaskellSupport=NO
+if test $HostPlatform = "powerpc-apple-darwin"; then
+ AC_MSG_CHECKING([for HaskellSupport.framework])
+ save_libs="$LIBS"
+ LIBS="-framework HaskellSupport"
+ AC_TRY_LINK_FUNC(__gmpz_fdiv_qr, HaveFrameworkHaskellSupport=YES,)
+ if test $HaveFrameworkHaskellSupport = YES; then
+ AC_DEFINE(HAVE_FRAMEWORK_HASKELLSUPPORT)
+ fi;
+ LIBS="$save_libs"
+ AC_MSG_RESULT([$HaveFrameworkHaskellSupport])
+fi;
+AC_SUBST(HaveFrameworkHaskellSupport)
+
+dnl ** check for mingwex library
+AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
+AC_SUBST(HaveLibMingwEx)
+
+if test $HaveLibMingwEx = YES ; then
+ AC_DEFINE(HAVE_MINGWEX)
+fi
+
+if test "$HaveLibGmp" = "NO"; then
+if test "$HostArch_CPP" = "ia64"; then
+AC_MSG_ERROR([You need to install libgmp (the in-tree version does not work on IA64).])
+fi;
+fi;
+
+dnl ** check whether this machine has GNU regex in libc.
+FPTOOLS_REGEX_IN_LIBC
+
+dnl ** check whether this machine has BFD and liberty installed (used for debugging)
+dnl the order of these tests matters: bfd needs liberty
+AC_CHECK_LIB(iberty, xmalloc)
+AC_CHECK_LIB(bfd, bfd_init)
+
+dnl ** check for readline, for Hugs and hslibs' Readline
+dnl ncurses supersedes termcap and curses, but for compatibility,
+dnl we have to check for all...
+AC_CHECK_LIB(ncurses, tputs, HaveLibTermcap=YES; LibTermcap=ncurses,
+ AC_CHECK_LIB(termcap, tputs, HaveLibTermcap=YES; LibTermcap=termcap,
+ AC_CHECK_LIB(curses, tputs, HaveLibTermcap=YES; LibTermcap=curses,
+ HaveLibTermcap=NO; LibTermcap=not-installed)))
+
+if test $HaveLibTermcap = YES ; then
+ LIBS="-l$LibTermcap $LIBS"
+ AC_CHECK_LIB(readline, readline, HaveLibReadline=YES, HaveLibReadline=NO)
+fi
+
+if test $HaveLibTermcap = YES && test x"$HaveLibReadline" = xYES ; then
+ AC_DEFINE(HAVE_READLINE_LIBS,1)
+ LibsReadline="readline $LibTermcap"
+else
+ AC_DEFINE(HAVE_READLINE_LIBS,0)
+ LibsReadline=
+fi
+AC_SUBST(LibsReadline)
+
+if test "$HaveLibReadline"; then
+ AC_CHECK_LIB(readline, rl_erase_empty_line,
+ [AC_DEFINE(HAVE_READLINE_4, 1)],
+ [AC_DEFINE(HAVE_READLINE_4, 0)])
+ AC_CHECK_LIB(readline, rl_free_undo_list,
+ [AC_DEFINE(HAVE_READLINE_4_2, 1)],
+ [AC_DEFINE(HAVE_READLINE_4_2, 0)])
+else
+ AC_DEFINE(HAVE_READLINE_4, 0)
+ AC_DEFINE(HAVE_READLINE_4_2, 0)
+fi
+
+dnl ** check for math library
+FPTOOLS_CHECK_LIBM()
+AC_SUBST(LIBM)
+
+dnl ** check for X Window System
+AC_PATH_XTRA()
+
+dnl ** check for OpenGL/GLUT/GLX include paths and libraries
+if test $GhcLibsWithHOpenGL = YES ; then
+FPTOOLS_HAVE_OPENGL
+fi
+
+dnl ################################################################
+dnl Check for libraries
+dnl ################################################################
+
+dnl ** check for libdl & RTLD_NEXT
+
+dnl (Mac OS X only) ... but don't check if we already have the
+dnl HaskellSupport.framework
+
+if test $HaveFrameworkHaskellSupport = YES; then
+ HaveLibDL=NO
+ HaveRtldNext=NO
+ HaveRtldLocal=YES
+ AC_DEFINE(HAVE_RTLDLOCAL)
+ HaveRtldGlobal=YES
+ AC_DEFINE(HAVE_RTLDGLOBAL)
+ HaveRtldNow=YES
+ AC_DEFINE(HAVE_RTLDNOW)
+ AC_SUBST(HaveLibDL)
+ AC_SUBST(HaveRtldNext)
+ AC_SUBST(HaveRtldLocal)
+ AC_SUBST(HaveRtldGlobal)
+ AC_SUBST(HaveRtldNow)
+else
+ AC_CHECK_LIB(dl, dlopen,
+ [HaveLibDL=YES
+ AC_DEFINE(HAVE_LIBDL)
+ LIBS="$LIBS -ldl"],
+ [HaveLibDL=NO])
+ AC_CHECK_FUNCS(dlopen)
+ AC_SUBST(HaveLibDL)
+
+ dnl ** sometimes RTLD_NEXT is hidden in #ifdefs we really don't wan to set
+ AC_MSG_CHECKING(for RTLD_NEXT from dlfcn.h)
+ AC_EGREP_CPP(yes,
+ [
+ #include <dlfcn.h>
+ #ifdef RTLD_NEXT
+ yes
+ #endif
+ ], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_RTLDNEXT)
+ HaveRtldNext=YES
+ ], [
+ AC_MSG_RESULT(no)
+ HaveRtldNext=NO
+ ])
+ AC_SUBST(HaveRtldNext)
+
+ dnl ** RTLD_LOCAL isn't available on cygwin or openbsd
+ AC_MSG_CHECKING(for RTLD_LOCAL from dlfcn.h)
+ AC_EGREP_CPP(yes,
+ [
+ #include <dlfcn.h>
+ #ifdef RTLD_LOCAL
+ yes
+ #endif
+ ], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_RTLDLOCAL)
+ HaveRtldLocal=YES
+ ], [
+ AC_MSG_RESULT(no)
+ HaveRtldLocal=NO
+ ])
+ AC_SUBST(HaveRtldLocal)
+
+ dnl ** RTLD_GLOBAL isn't available on openbsd
+ AC_MSG_CHECKING(for RTLD_GLOBAL from dlfcn.h)
+ AC_EGREP_CPP(yes,
+ [
+ #include <dlfcn.h>
+ #ifdef RTLD_GLOBAL
+ yes
+ #endif
+ ], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_RTLDGLOBAL)
+ HaveRtldGlobal=YES
+ ], [
+ AC_MSG_RESULT(no)
+ HaveRtldGlobal=NO
+ ])
+ AC_SUBST(HaveRtldGlobal)
+
+ dnl ** RTLD_NOW isn't available on openbsd
+ AC_MSG_CHECKING(for RTLD_NOW from dlfcn.h)
+ AC_EGREP_CPP(yes,
+ [
+ #include <dlfcn.h>
+ #ifdef RTLD_NOW
+ yes
+ #endif
+ ], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_RTLDNOW)
+ HaveRtldNow=YES
+ ], [
+ AC_MSG_RESULT(no)
+ HaveRtldNow=NO
+ ])
+ AC_SUBST(HaveRtldNow)
+fi
+
+FPTOOLS_CHECK_LIB_NOWARN(m, atan)
+
+dnl ---------- usleep ----------
+dnl --- stolen from guile configure ---
+dnl --- FIXME: /usr/include/unistd.h can't be right?
+
+### On some systems usleep has no return value. If it does have one,
+### we'd like to return it; otherwise, we'll fake it.
+AC_CACHE_CHECK([return type of usleep], cv_func_usleep_return_type,
+ [AC_EGREP_HEADER(changequote(<, >)<void[ ]+usleep>changequote([, ]),
+ /usr/include/unistd.h,
+ [cv_func_usleep_return_type=void],
+ [cv_func_usleep_return_type=int])])
+case "$cv_func_usleep_return_type" in
+ "void" )
+ AC_DEFINE(USLEEP_RETURNS_VOID, 1,
+ [Define if the system headers declare usleep to return void.])
+ ;;
+esac
+
+dnl --------------------------------------------------
+dnl * test for in_addr_t
+dnl --------------------------------------------------
+AC_MSG_CHECKING(for in_addr_t in netinet/in.h)
+AC_EGREP_HEADER(in_addr_t, netinet/in.h,
+ [ AC_DEFINE(HAVE_IN_ADDR_T) AC_MSG_RESULT(yes) ],
+ AC_MSG_RESULT(no))
+
+dnl --------------------------------------------------
+dnl * test for Linux sendfile(2)
+dnl --------------------------------------------------
+AC_MSG_CHECKING(for sendfile in sys/sendfile.h)
+AC_EGREP_HEADER(sendfile, sys/sendfile.h,
+ [ AC_DEFINE(HAVE_LINUX_SENDFILE) AC_MSG_RESULT(yes) ],
+ AC_MSG_RESULT(no))
+
+dnl --------------------------------------------------
+dnl * test for BSD sendfile(2)
+dnl --------------------------------------------------
+AC_MSG_CHECKING(for sendfile in sys/socket.h)
+AC_EGREP_HEADER(sendfile, sys/socket.h,
+ [ AC_DEFINE(HAVE_BSD_SENDFILE) AC_MSG_RESULT(yes) ],
+ AC_MSG_RESULT(no))
+
+dnl --------------------------------------------------
+dnl * test for GTK+
+dnl --------------------------------------------------
+
+AC_PATH_PROGS(GTK_CONFIG, gtk-config gtk12-config)
+if test "$GTK_CONFIG" != ""; then
+ AC_CACHE_CHECK([for version of GTK+], fptools_cv_gtk_version, [
+ fptools_cv_gtk_version=`$GTK_CONFIG --version`
+ ])
+ GTK_VERSION=$fptools_cv_gtk_version
+else
+ GTK_VERSION=
+fi
+
+case $fptools_cv_gtk_version in
+ 1.[[23]].*) ;;
+ *) AC_MSG_WARN([GTK+ not usable; need at least version 1.2])
+ GTK_CONFIG=
+ ;;
+esac
+
+AC_SUBST(GTK_CONFIG)
+AC_SUBST(GTK_VERSION)
+
+dnl --------------------------------------------------
+dnl * Miscellaneous feature tests
+dnl --------------------------------------------------