Adjust behaviour of gcd
[ghc-base.git] / configure.ac
index 72c1d9c..787bf66 100644 (file)
@@ -3,49 +3,76 @@ AC_INIT([Haskell base package], [1.0], [libraries@haskell.org], [base])
 # Safety check: Ensure that we are in the correct source directory.
 AC_CONFIG_SRCDIR([include/HsBase.h])
 
-AC_CONFIG_HEADERS([include/HsBaseConfig.h])
+AC_CONFIG_HEADERS([include/HsBaseConfig.h include/EventConfig.h])
 
-# do we have long longs?
-AC_CHECK_TYPES([long long])
+AC_ARG_WITH([cc],
+            [C compiler],
+            [CC=$withval])
+AC_PROG_CC()
 
-dnl ** Working vfork?
-AC_FUNC_FORK
+case `uname -s` in
+    MINGW*|CYGWIN*)
+        WINDOWS=YES;;
+    *)
+        WINDOWS=NO;;
+esac
 
-dnl ** determine whether or not const works
-AC_C_CONST
+# do we have long longs?
+AC_CHECK_TYPES([long long])
 
 dnl ** check for full ANSI header (.h) files
 AC_HEADER_STDC
 
 # check for specific header (.h) files that we are interested in
-AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h limits.h signal.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h time.h utime.h windows.h winsock.h])
+AC_CHECK_HEADERS([ctype.h errno.h fcntl.h inttypes.h limits.h signal.h sys/resource.h sys/select.h sys/stat.h sys/syscall.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/types.h sys/utsname.h sys/wait.h termios.h time.h unistd.h utime.h windows.h winsock.h langinfo.h poll.h sys/epoll.h sys/event.h sys/eventfd.h])
 
 # Enable large file support. Do this before testing the types ino_t, off_t, and
 # rlim_t, because it will affect the result of that test.
 AC_SYS_LARGEFILE
 
-dnl ** check for POSIX regex
-HavePosixRegex=NO
-AC_CHECK_HEADERS([regex.h], [AC_CHECK_FUNCS(regcomp, [HavePosixRegex=YES])])
-AC_SUBST(HavePosixRegex)
-
 dnl ** check for wide-char classifications
 dnl FreeBSD has an emtpy wctype.h, so test one of the affected
 dnl functions if it's really there.
 AC_CHECK_HEADERS([wctype.h], [AC_CHECK_FUNCS(iswspace)])
 
-AC_CHECK_FUNCS([ftime gmtime_r localtime_r lstat readdir_r])
-AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer times])
+AC_CHECK_FUNCS([lstat])
+AC_CHECK_FUNCS([getclock getrusage times])
 AC_CHECK_FUNCS([_chsize ftruncate])
 
-dnl ** check if it is safe to include both <time.h> and <sys/time.h>
-AC_HEADER_TIME
+AC_CHECK_FUNCS([epoll_ctl eventfd kevent kevent64 kqueue poll])
+
+# event-related fun
 
-dnl ** how do we get a timezone name, and UTC offset ?
-AC_STRUCT_TIMEZONE
+if test "$ac_cv_header_sys_epoll_h" = yes -a "$ac_cv_func_epoll_ctl" = yes; then
+  AC_DEFINE([HAVE_EPOLL], [1], [Define if you have epoll support.])
+fi
 
-dnl ** do we have altzone?
-FP_DECL_ALTZONE
+if test "$ac_cv_header_sys_event_h" = yes -a "$ac_cv_func_kqueue" = yes; then
+  AC_DEFINE([HAVE_KQUEUE], [1], [Define if you have kqueue support.])
+fi
+
+if test "$ac_cv_header_poll_h" = yes -a "$ac_cv_func_poll" = yes; then
+  AC_DEFINE([HAVE_POLL], [1], [Define if you have poll support.])
+fi
+
+dnl--------------------------------------------------------------------
+dnl * Deal with arguments telling us iconv is somewhere odd
+dnl--------------------------------------------------------------------
+
+AC_ARG_WITH([iconv-includes],
+  [AC_HELP_STRING([--with-iconv-includes],
+    [directory containing iconv.h])],
+    [ICONV_INCLUDE_DIRS=$withval; CPPFLAGS="-I$withval"],
+    [ICONV_INCLUDE_DIRS=])
+
+AC_ARG_WITH([iconv-libraries],
+  [AC_HELP_STRING([--with-iconv-libraries],
+    [directory containing iconv library])],
+    [ICONV_LIB_DIRS=$withval; LDFLAGS="-L$withval"],
+    [ICONV_LIB_DIRS=])
+
+AC_SUBST(ICONV_INCLUDE_DIRS)
+AC_SUBST(ICONV_LIB_DIRS)
 
 # map standard C types and ISO types to Haskell types
 FPTOOLS_CHECK_HTYPE(char)
@@ -66,11 +93,20 @@ FPTOOLS_CHECK_HTYPE(double)
 FPTOOLS_CHECK_HTYPE(ptrdiff_t)
 FPTOOLS_CHECK_HTYPE(size_t)
 FPTOOLS_CHECK_HTYPE(wchar_t)
-# Int32 is a HACK for non-ISO C compilers
-FPTOOLS_CHECK_HTYPE(sig_atomic_t, Int32)
+FPTOOLS_CHECK_HTYPE(sig_atomic_t)
 FPTOOLS_CHECK_HTYPE(clock_t)
 FPTOOLS_CHECK_HTYPE(time_t)
-FPTOOLS_CHECK_HTYPE(dev_t, Word32)
+FPTOOLS_CHECK_HTYPE(useconds_t)
+FPTOOLS_CHECK_HTYPE_ELSE(suseconds_t,
+                         [if test "$WINDOWS" = "YES"
+                          then
+                              AC_CV_NAME=Int32
+                              AC_CV_NAME_supported=yes
+                              AC_MSG_RESULT([not found...on Windows, so using Int32])
+                          else
+                              AC_MSG_ERROR([type not found])
+                          fi])
+FPTOOLS_CHECK_HTYPE(dev_t)
 FPTOOLS_CHECK_HTYPE(ino_t)
 FPTOOLS_CHECK_HTYPE(mode_t)
 FPTOOLS_CHECK_HTYPE(off_t)
@@ -83,7 +119,6 @@ FPTOOLS_CHECK_HTYPE(tcflag_t)
 FPTOOLS_CHECK_HTYPE(nlink_t)
 FPTOOLS_CHECK_HTYPE(ssize_t)
 FPTOOLS_CHECK_HTYPE(rlim_t)
-FPTOOLS_CHECK_HTYPE(wint_t)
 
 FPTOOLS_CHECK_HTYPE(intptr_t)
 FPTOOLS_CHECK_HTYPE(uintptr_t)
@@ -94,7 +129,8 @@ FPTOOLS_CHECK_HTYPE(uintmax_t)
 FP_CHECK_CONSTS([E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EADV EAFNOSUPPORT EAGAIN EALREADY EBADF EBADMSG EBADRPC EBUSY ECHILD ECOMM ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ EDIRTY EDOM EDQUOT EEXIST EFAULT EFBIG EFTYPE EHOSTDOWN EHOSTUNREACH EIDRM EILSEQ EINPROGRESS EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK EMSGSIZE EMULTIHOP ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH ENFILE ENOBUFS ENODATA ENODEV ENOENT ENOEXEC ENOLCK ENOLINK ENOMEM ENOMSG ENONET ENOPROTOOPT ENOSPC ENOSR ENOSTR ENOSYS ENOTBLK ENOTCONN ENOTDIR ENOTEMPTY ENOTSOCK ENOTTY ENXIO EOPNOTSUPP EPERM EPFNOSUPPORT EPIPE EPROCLIM EPROCUNAVAIL EPROGMISMATCH EPROGUNAVAIL EPROTO EPROTONOSUPPORT EPROTOTYPE ERANGE EREMCHG EREMOTE EROFS ERPCMISMATCH ERREMOTE ESHUTDOWN ESOCKTNOSUPPORT ESPIPE ESRCH ESRMNT ESTALE ETIME ETIMEDOUT ETOOMANYREFS ETXTBSY EUSERS EWOULDBLOCK EXDEV ENOCIGAR], [#include <stdio.h>
 #include <errno.h>])
 
-FP_CHECK_CONSTS([SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 SIGPOLL SIGPROF SIGSYS SIGTRAP SIGURG SIGVTALRM SIGXCPU SIGXFSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SIG_DFL SIG_IGN SIG_ERR], [
+# we need SIGINT in TopHandler.lhs
+FP_CHECK_CONSTS([SIGINT], [
 #if HAVE_SIGNAL_H
 #include <signal.h>
 #endif])
@@ -102,9 +138,38 @@ FP_CHECK_CONSTS([SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIG
 dnl ** can we open files in binary mode?
 FP_CHECK_CONST([O_BINARY], [#include <fcntl.h>], [0])
 
-# Check for idiosyncracies in some mingw impls of directory handling.
-FP_READDIR_EOF_ERRNO
-
-AC_CONFIG_FILES([config.mk])
+# We can't just use AC_SEARCH_LIBS for this, as on OpenBSD the iconv.h
+# header needs to be included as iconv_open is #define'd to something
+# else. We therefore use our own FP_SEARCH_LIBS_PROTO, which allows us
+# to give prototype text.
+FP_SEARCH_LIBS_PROTO(iconv,
+                     [
+#include <stddef.h>
+#include <iconv.h>
+                      ],
+                     [iconv_t cd;
+                      cd = iconv_open("", "");
+                      iconv(cd,NULL,NULL,NULL,NULL);
+                      iconv_close(cd);],
+                     iconv,
+                     [EXTRA_LIBS="$EXTRA_LIBS $ac_lib"],
+                     [if test "$WINDOWS" = "NO"
+                      then
+                          AC_MSG_ERROR([iconv is required on non-Windows platforms])
+                      fi])
+
+# If possible, we use libcharset instead of nl_langinfo(CODESET) to
+# determine the current locale's character encoding.
+FP_SEARCH_LIBS_PROTO(
+    [locale_charset],
+    [#include <libcharset.h>],
+    [const char* charset = locale_charset();],
+    [charset],
+    [AC_DEFINE([HAVE_LIBCHARSET], [1], [Define to 1 if you have libcharset.])
+     EXTRA_LIBS="$EXTRA_LIBS $ac_lib"])
+
+
+AC_SUBST(EXTRA_LIBS)
+AC_CONFIG_FILES([base.buildinfo])
 
 AC_OUTPUT