Make Control.Exception buildable by nhc98.
[haskell-directory.git] / aclocal.m4
index 1540a46..16d8bb9 100644 (file)
@@ -1,3 +1,24 @@
+# FP_DECL_ALTZONE
+# ---------------
+# Defines HAVE_DECL_ALTZONE to 1 if declared, 0 otherwise.
+#
+# Used by base package.
+AC_DEFUN([FP_DECL_ALTZONE],
+[AC_REQUIRE([AC_HEADER_TIME])dnl
+AC_CHECK_HEADERS([sys/time.h])
+AC_CHECK_DECLS([altzone], [], [],[#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif])
+])# FP_DECL_ALTZONE
+
+
 # FP_COMPUTE_INT(EXPRESSION, VARIABLE, INCLUDES, IF-FAILS)
 # --------------------------------------------------------
 # Assign VARIABLE the value of the compile-time EXPRESSION using INCLUDES for
@@ -40,7 +61,7 @@ m4_define([FP_CHECK_CONSTS_TEMPLATE],
 # FP_CHECK_CONSTS(EXPRESSION..., [INCLUDES = DEFAULT-INCLUDES], [VALUE-IF-FAIL = -1])
 # -----------------------------------------------------------------------------------
 # List version of FP_CHECK_CONST
-AC_DEFUN(FP_CHECK_CONSTS,
+AC_DEFUN([FP_CHECK_CONSTS],
 [FP_CHECK_CONSTS_TEMPLATE([$1])dnl
 for fp_const_name in $1
 do
@@ -49,16 +70,131 @@ done
 ])# FP_CHECK_CONSTS
 
 
-dnl @synopsis FP_READDIR_EOF_ERRNO
-dnl
-dnl Check what readdir() sets 'errno' to upon reaching 
-dnl end of directory; not setting it is the correct thing to do,
-dnl but mingw based versions have set it to ENOENT until recently
-dnl (summer 2004).
-dnl
-dnl
-AC_DEFUN(FP_READDIR_EOF_ERRNO,
-[AC_CACHE_CHECK([what readdir sets errno to upon EOF], fptools_cv_readdir_eof_errno,
+dnl ** Map an arithmetic C type to a Haskell type.
+dnl    Based on autconf's AC_CHECK_SIZEOF.
+
+dnl FPTOOLS_CHECK_HTYPE(TYPE [, DEFAULT_VALUE, [, VALUE-FOR-CROSS-COMPILATION])
+AC_DEFUN([FPTOOLS_CHECK_HTYPE],
+[changequote(<<, >>)dnl
+dnl The name to #define.
+define(<<AC_TYPE_NAME>>, translit(htype_$1, [a-z *], [A-Z_P]))dnl
+dnl The cache variable name.
+define(<<AC_CV_NAME>>, translit(fptools_cv_htype_$1, [ *], [_p]))dnl
+define(<<AC_CV_NAME_supported>>, translit(fptools_cv_htype_sup_$1, [ *], [_p]))dnl
+changequote([, ])dnl
+AC_MSG_CHECKING(Haskell type for $1)
+AC_CACHE_VAL(AC_CV_NAME,
+[AC_CV_NAME_supported=yes
+fp_check_htype_save_cppflags="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
+#include <stddef.h>
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
+#if HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+
+#if HAVE_SIGNAL_H
+# include <signal.h>
+#endif
+
+#if HAVE_TIME_H
+# include <time.h>
+#endif
+
+#if HAVE_TERMIOS_H
+# include <termios.h>
+#endif
+
+#if HAVE_STRING_H
+# include <string.h>
+#endif
+
+#if HAVE_CTYPE_H
+# include <ctype.h>
+#endif
+
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+#endif
+
+#if defined(HAVE_GL_GL_H)
+# include <GL/gl.h>
+#elif defined(HAVE_OPENGL_GL_H)
+# include <OpenGL/gl.h>
+#endif
+
+#if defined(HAVE_AL_AL_H)
+# include <AL/al.h>
+#elif defined(HAVE_OPENAL_AL_H)
+# include <OpenAL/al.h>
+#endif
+
+#if defined(HAVE_AL_ALC_H)
+# include <AL/alc.h>
+#elif defined(HAVE_OPENAL_ALC_H)
+# include <OpenAL/alc.h>
+#endif
+
+#if HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
+typedef $1 testing;
+
+main() {
+  FILE *f=fopen("conftestval", "w");
+  if (!f) exit(1);
+  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
+    fprintf(f, "%s%d\n",
+           ((testing)(-1) < (testing)0) ? "Int" : "Word",
+           sizeof(testing)*8);
+  } else {
+    fprintf(f,"%s\n",
+           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
+           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
+  }
+  fclose(f);
+  exit(0);
+}]])],[AC_CV_NAME=`cat conftestval`],
+[ifelse([$2], , [AC_CV_NAME=NotReallyAType; AC_CV_NAME_supported=no], [AC_CV_NAME=$2])],
+[ifelse([$3], , [AC_CV_NAME=NotReallyATypeCross; AC_CV_NAME_supported=no], [AC_CV_NAME=$3])])
+CPPFLAGS="$fp_check_htype_save_cppflags"]) dnl
+if test "$AC_CV_NAME_supported" = yes; then
+  AC_MSG_RESULT($AC_CV_NAME)
+  AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [Define to Haskell type for $1])
+else
+  AC_MSG_RESULT([not supported])
+fi
+undefine([AC_TYPE_NAME])dnl
+undefine([AC_CV_NAME])dnl
+undefine([AC_CV_NAME_supported])dnl
+])
+
+
+# FP_READDIR_EOF_ERRNO
+# --------------------
+# Defines READDIR_ERRNO_EOF to what readdir() sets 'errno' to upon reaching end
+# of directory (not set => 0); not setting it is the correct thing to do, but
+# MinGW based versions have set it to ENOENT until recently (summer 2004).
+AC_DEFUN([FP_READDIR_EOF_ERRNO],
+[AC_CACHE_CHECK([what readdir sets errno to upon EOF], [fptools_cv_readdir_eof_errno],
 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <dirent.h>
 #include <stdio.h>
 #include <errno.h>
@@ -102,44 +238,10 @@ char **argv;
   closedir(dp);
   rmdir("testdir");
   return 0;
-}]])],[fptools_cv_readdir_eof_errno=`cat conftestval`],[fptools_cv_readdir_eof_errno=bogus],[fptools_cv_readdir_eof_errno=0])])
-dnl the cross value is somewhat bogus.
+}]])],
+[fptools_cv_readdir_eof_errno=`cat conftestval`],
+[AC_MSG_WARN([failed to determine the errno value])
+ fptools_cv_readdir_eof_errno=0],
+[fptools_cv_readdir_eof_errno=0])])
 AC_DEFINE_UNQUOTED([READDIR_ERRNO_EOF], [$fptools_cv_readdir_eof_errno], [readdir() sets errno to this upon EOF])
-])
-
-dnl @synopsis FP_DIRENT_FLAT_LAYOUT
-dnl
-dnl Check whether 'struct dirent' (in dirent.h) has d_name defined
-dnl as being the final field in a struct, or a pointer to somewhere
-dnl else. The former is the standardly thing to do, but mingw defns
-dnl have for the longest time gone for the latter. They no longer do,
-dnl hence the need to configure test for this.
-dnl
-dnl
-AC_DEFUN(FP_DIRENT_FLAT_LAYOUT,
-[AC_CACHE_CHECK([if struct dirent layout is flat], fptools_cv_dirent_flat_layout,
-[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <dirent.h>
-#include <stdio.h>
-#include <string.h>
-int
-main(argc, argv)
-int argc;
-char **argv;
-{
-  struct dirent de;
-  /*
-   * Check whether d_name is defined as
-   *    struct dirent { .... ; char d_name[..]; } 
-   * or
-   *    struct dirent { .... ; char* d_name; } 
-   * 
-   * Returns 0 if the former.
-   */
-  memset(&de,0,sizeof(struct dirent));
-  return ((int)de.d_name == 0);
-}]])],[fptools_cv_dirent_flat_layout=yes],[fptools_cv_dirent_flat_layout=no],[fptools_cv_dirent_flat_layout=yes])])
-dnl the cross value is somewhat bogus.
-if test "$fptools_cv_dirent_flat_layout" = yes; then
-AC_DEFINE([STRUCT_DIRENT_FLAT_LAYOUT], [1], [Define to 1 if struct dirent is a flat structure])
-fi
-])
+])# FP_READDIR_EOF_ERRNO