[project @ 2004-10-11 14:25:44 by simonmar]
[ghc-hetmet.git] / aclocal.m4
index c0338fb..d660017 100644 (file)
@@ -199,13 +199,15 @@ case $HostPlatform in
 alpha-dec-osf*) fptools_cv_leading_underscore=no;;
 *cygwin32) fptools_cv_leading_underscore=yes;;
 *mingw32) fptools_cv_leading_underscore=yes;;
-*) AC_TRY_RUN([#ifdef HAVE_NLIST_H
+*) AC_RUN_IFELSE([AC_LANG_SOURCE([[#ifdef HAVE_NLIST_H
 #include <nlist.h>
 struct nlist xYzzY1[] = {{"xYzzY1", 0},{0}};
 struct nlist xYzzY2[] = {{"_xYzzY2", 0},{0}};
 #endif
 
-int main()
+int main(argc, argv)
+int argc;
+char **argv;
 {
 #ifdef HAVE_NLIST_H
     if(nlist(argv[0], xYzzY1) == 0 && xYzzY1[0].n_value != 0)
@@ -214,7 +216,7 @@ int main()
         exit(0);
 #endif
     exit(1);
-}], [fptools_cv_leading_underscore=yes], [fptools_cv_leading_underscore=no], [fptools_cv_leading_underscore=no])
+}]])],[fptools_cv_leading_underscore=yes],[fptools_cv_leading_underscore=no],[fptools_cv_leading_underscore=no])
 ;;
 esac]);
 AC_SUBST([LeadingUnderscore], [`echo $fptools_cv_leading_underscore | sed 'y/yesno/YESNO/'`])
@@ -493,8 +495,8 @@ AC_CACHE_CHECK([whether $fp_prog_ar_raw supports -input], [fp_cv_prog_ar_support
 if test $fp_prog_ar_is_gnu = no; then
   rm -f conftest*
   touch conftest.lst
-  if $fp_prog_ar_raw $fp_prog_ar_args conftest.a -input conftest.lst > /dev/null 2> /dev/null; then
-    fp_cv_prog_ar_supports_input=yes
+  if FP_EVAL_STDERR([$fp_prog_ar_raw $fp_prog_ar_args conftest.a -input conftest.lst]) >/dev/null; then
+    test -s conftest.err || fp_cv_prog_ar_supports_input=yes
   fi
   rm -f conftest*
 fi])
@@ -653,7 +655,7 @@ dnl
 AC_DEFUN(FPTOOLS_GHC_VERSION,
 [FPTOOLS_NOCACHE_CHECK([version of ghc], [fptools_version_of_ghc],
 ["${WithGhc-ghc}" --version > conftestghc 2>&1
-  cat conftestghc >&AC_FD_CC
+  cat conftestghc >&AS_MESSAGE_LOG_FD
 #Useless Use Of cat award...
   fptools_version_of_ghc=`cat conftestghc | sed -n -e 's/, patchlevel *\([[0-9]]\)/.\1/;s/.* version \([[0-9]][[0-9.]]*\).*/\1/p'`
   rm -fr conftest*
@@ -692,6 +694,19 @@ ifelse($#, [1], [dnl
 ])dnl
 
 
+AC_DEFUN(FPTOOLS_GHC_HAS_READLINE,
+[AC_CACHE_CHECK([whether ghc has readline package], [fptools_ghc_has_readline],
+[if "${GhcPkgCmd-ghc-pkg}" --show-package readline >/dev/null 2>&1; then
+    fptools_ghc_has_readline='yes';
+    GhcHasReadline='YES';
+ else
+    fptools_ghc_has_readline='no';
+    GhcHasReadline='NO';
+ fi
+ AC_SUBST(GhcHasReadline)
+])
+])
+
 dnl ** Map an arithmetic C type to a Haskell type.
 dnl    Based on autconf's AC_CHECK_SIZEOF.
 
@@ -709,7 +724,7 @@ AC_CACHE_VAL(AC_CV_NAME,
 [AC_CV_NAME_supported=yes
 fp_check_htype_save_cppflags="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-AC_TRY_RUN([#include <stdio.h>
+AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
 #include <stddef.h>
 
 #if HAVE_SYS_TYPES_H
@@ -780,9 +795,9 @@ main() {
   }
   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))]) dnl
+}]])],[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])])]) dnl
 CPPFLAGS="$fp_check_htype_save_cppflags"
 if test "$AC_CV_NAME_supported" = yes; then
   AC_MSG_RESULT($AC_CV_NAME)
@@ -910,14 +925,66 @@ fi
 ])# FP_CHECK_DOCBOOK_DTD
 
 
+# FP_GEN_FO
+# ------------------
+# Generates a formatting objects document in conftest.fo.
+AC_DEFUN([FP_GEN_FO],
+[rm -f conftest.fo
+cat > conftest.fo << EOF
+<?xml version="1.0"?>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+  <fo:layout-master-set>
+    <fo:simple-page-master master-name="blank">
+      <fo:region-body/>
+    </fo:simple-page-master>
+  </fo:layout-master-set>
+  <fo:page-sequence master-reference="blank">
+    <fo:flow flow-name="xsl-region-body">
+      <fo:block>
+        Test!
+      </fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+</fo:root>
+EOF
+]) # FP_GEN_FO
+
+
+# FP_PROG_FOP
+# -----------
+# Set the output variable 'FopCmd' to the first working 'fop' in the current
+# 'PATH'. Note that /usr/bin/fop is broken in SuSE 9.1 (unpatched), so try
+# /usr/share/fop/fop.sh in that case (or no 'fop'), too.
+AC_DEFUN([FP_PROG_FOP],
+[AC_PATH_PROGS([FopCmd1], [fop])
+if test -n "$FopCmd1"; then
+  AC_CACHE_CHECK([for $FopCmd1 usability], [fp_cv_fop_usability],
+    [FP_GEN_FO
+    if "$FopCmd1" -fo conftest.fo -ps conftest.ps > /dev/null 2>&1; then
+      fp_cv_fop_usability=yes
+    else
+      fp_cv_fop_usability=no
+    fi
+    rm -rf conftest*])
+  if test x"$fp_cv_fop_usability" = xyes; then
+     FopCmd=$FopCmd1
+  fi
+fi
+if test -z "$FopCmd"; then
+  AC_PATH_PROGS([FopCmd2], [fop.sh], , [/usr/share/fop])
+  FopCmd=$FopCmd2
+fi
+AC_SUBST([FopCmd])
+])# FP_PROG_FOP
+
+
 # FP_PROG_FO_PROCESSOR
 # --------------------
 # Try to find an FO processor. PassiveTeX output is sometimes a bit strange, so
-# try FOP first.  Furthermore, /usr/bin/fop is broken in SuSE 9.1, so try the
-# "real" fop.sh first. Sets the output variables FopCmd, XmltexCmd, DvipsCmd,
-# and PdfxmltexCmd.
+# try FOP first. Sets the output variables FopCmd, XmltexCmd, DvipsCmd, and
+# PdfxmltexCmd.
 AC_DEFUN([FP_PROG_FO_PROCESSOR],
-[AC_PATH_PROGS([FopCmd], [fop.sh fop], [], [$PATH:/usr/share/fop])
+[AC_REQUIRE([FP_PROG_FOP])
 AC_PATH_PROG([XmltexCmd], [xmltex])
 AC_PATH_PROG([DvipsCmd], [dvips])
 if test -z "$FopCmd"; then
@@ -1022,7 +1089,7 @@ AC_DEFUN([FP_CHECK_GL_HELPER],
       fp_try_lib=`echo $fp_try_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
     fi
     LIBS="$fp_try_lib ${$1_LIBS} $fp_save_LIBS"
-    AC_TRY_LINK([$3], [$4], [fp_cv_check_$1_lib="$fp_try_lib ${$1_LIBS}"; break])
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([$3], [$4])], [fp_cv_check_$1_lib="$fp_try_lib ${$1_LIBS}"; break])
   done
   LIBS="$fp_save_LIBS"
   CPPFLAGS="$fp_save_CPPFLAGS"])
@@ -1044,7 +1111,7 @@ AC_DEFUN([FP_CHECK_GL_HELPER],
 # -----------
 AC_DEFUN([FP_CHECK_GL],
 [AC_REQUIRE([FP_PATH_X])
-AC_REQUIRE([AC_CANONICAL_SYSTEM])
+AC_REQUIRE([AC_CANONICAL_TARGET])
 
 AC_ARG_ENABLE([hopengl],
   [AC_HELP_STRING([--enable-hopengl],
@@ -1084,7 +1151,7 @@ else
         *-lopengl32*|*opengl32.lib*) ;;
         *) fp_save_LIBS="$LIBS"
            LIBS="$LIBS -lopengl32"
-           AC_TRY_LINK([@%:@include <GL/gl.h>], [glEnd()],
+           AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <GL/gl.h>]], [[glEnd()]])],
              [GL_LIBS="$GL_LIBS -lopengl32"; GL_LIBS0="$GL_LIBS0 -lopengl32"])
            LIBS="$fp_save_LIBS"
            ;;
@@ -1155,116 +1222,19 @@ AC_SUBST([GLUT_LIBS])
 ])# FP_CHECK_GLUT
 
 
-dnl @synopsis FP_EMPTY_STRUCTS
-dnl 
-dnl Check whether empty structs is accepted by CC.
+# FP_EMPTY_STRUCTS
+# ---------------- 
+# Define output variable SUPPORTS_EMPTY_STRUCTS if empty structs are accepted by
+# CC.
 dnl
 AC_DEFUN(FP_EMPTY_STRUCTS,
-[AC_CACHE_CHECK(empty struct support, fptools_cv_empty_structs,
-[AC_TRY_COMPILE([
-typedef struct { /*empty*/ } StgFoo;
-],
-[int i;], 
-fptools_cv_empty_structs=yes,
-fptools_cv_empty_structs=no)])
-if test "$fptools_cv_empty_structs" = yes; then
-AC_DEFINE([SUPPORTS_EMPTY_STRUCTS], [1], [Define to 1 if C compiler supports declaration of empty structure types.])
-fi
-])
-
-
-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,
-[AC_TRY_RUN([#include <dirent.h>
-#include <stdio.h>
-#include <errno.h>
-int
-main(argc, argv)
-int argc;
-char **argv;
-{
-  FILE *f=fopen("conftestval", "w");
-#if defined(__MINGW32__)
-  int fd = mkdir("testdir");
-#else
-  int fd = mkdir("testdir", 0666);
-#endif
-  DIR* dp;
-  struct dirent* de;
-  int err = 0;
-
-  if (!f) return 1;
-  if (fd == -1) { 
-     fprintf(stderr,"unable to create directory; quitting.\n");
-     return 1;
-  }
-  close(fd);
-  dp = opendir("testdir");
-  if (!dp) { 
-     fprintf(stderr,"unable to browse directory; quitting.\n");
-     rmdir("testdir");
-     return 1;
-  }
-
-  /* the assumption here is that readdir() will only return NULL
-   * due to reaching the end of the directory.
-   */
-  while (de = readdir(dp)) {
-       ;
-  }
-  err = errno;
-  fprintf(f,"%d", err);
-  fclose(f);
-  closedir(de);
-  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.
-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_TRY_RUN([#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])
+[AC_CACHE_CHECK(empty struct support, fp_cv_empty_structs,
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[typedef struct { /* empty */ } StgFoo;]],
+[[int i;]])],
+[fp_cv_empty_structs=yes],
+[fp_cv_empty_structs=no])])
+if test x"$fp_cv_empty_structs" = xyes; then
+  AC_DEFINE([SUPPORTS_EMPTY_STRUCTS], [1], [Define to 1 if C compiler supports declaration of empty structure types.])
 fi
 ])