[project @ 1998-04-07 08:22:03 by sof]
[ghc-hetmet.git] / aclocal.m4
index 05e0334..d1f9a64 100644 (file)
@@ -1,8 +1,26 @@
+# $Id: aclocal.m4,v 1.20 1998/03/03 19:04:48 reid Exp $
 #
 # Extra autoconf macros for the Glasgow fptools
 #
 
 #
+# Are we running under the GNU libc?  Need -D_GNU_SOURCE to get 
+# caddr_t and such.
+#
+AC_DEFUN(AC_GNU_LIBC,
+[AC_CACHE_CHECK([GNU libc], ac_cv_gnu_libc,
+[AC_EGREP_CPP(yes,
+[#include <features.h>
+#ifdef __GLIBC__
+yes
+#endif
+], ac_cv_gnu_libc=yes, ac_cv_gnu_libc=no)])
+if test "$ac_cv_gnu_libc" = yes; then
+  AC_DEFINE(_GNU_SOURCE)
+fi
+])
+
+#
 # Has timezone the type time_t or long (HP-UX 10.20 apparently
 # has `long'..)
 #
@@ -58,13 +76,16 @@ dnl ** check for leading underscores in symbol names
 AC_DEFUN(AC_UNDERSCORE,
 [AC_CHECK_LIB(elf, nlist, LIBS="-lelf $LIBS")dnl
 AC_CACHE_CHECK([leading underscore in symbol names], ac_cv_lead_uscore,
-[#
+#
 # Hack!: nlist() under Digital UNIX insist on there being an _,
 # but symbol table listings show none. What is going on here?!?
 #
-if test $HostPlatform = "alpha-dec-osf1"; then
-   ac_cv_lead_uscore='no'
-else
+changequote(<<, >>)dnl
+<<
+case $HostPlatform in
+alpha-dec-osf*) ac_cv_lead_uscore='no';;
+*) >>
+changequote([, ])dnl
 AC_TRY_RUN([#ifdef HAVE_NLIST_H
 #include <nlist.h>
 changequote(<<, >>)dnl
@@ -83,8 +104,8 @@ changequote([, ])dnl
 #endif
     exit(1);
 }], ac_cv_lead_uscore=yes, ac_cv_lead_uscore=no, ac_cv_lead_uscore=NO)
-fi
-])
+;;
+esac);
 LeadingUnderscore=`echo $ac_cv_lead_uscore | sed 'y/yesno/YESNO/'`
 AC_SUBST(LeadingUnderscore)
 ])
@@ -103,6 +124,11 @@ changequote([, ])dnl
 else
    ac_cv_happy_version="";
 fi;
+if expr "$ac_cv_happy_version" "<" 1.4 > /dev/null 2>&1; then
+   echo
+   echo "Happy version 1.4 or later is required to compile GHC."
+   exit 1;
+fi;
 ])
 HappyVersion=$ac_cv_happy_version;
 AC_SUBST(HappyVersion)
@@ -240,7 +266,7 @@ AC_DEFUN(AC_HAVE_GCC,
     ac_cv_have_gcc='no'
 else
 changequote(, )dnl
-    cmd_string="`$CC -v 2>&1 | grep 'version ' | sed -e 's/.*version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/expr 20 \\\< \1 \\\* 10 + \2/g' `"
+    cmd_string="`$CC -v 2>&1 | grep 'version ' | sed -e 's/.*version [^0-9]*\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/expr 20 \\\< \1 \\\* 10 + \2/g' `"
 changequote([, ])dnl
     if test `eval $cmd_string 2>/dev/null` != "1"; then
        echo ''
@@ -261,26 +287,25 @@ AC_SUBST(HaveGcc)
 # Substitutes: GNUCPP and RAWCPP (latter is 'GNUCPP -traditional')
 #
 AC_DEFUN(AC_PROG_GNUCPP,
-[AC_CACHE_CHECK([how to invoke cpp directly], ac_cv_gnu_cpp,
-[if echo $CPP | grep gcc >/dev/null 2>&1; then
-    echo > conftest.c
-    gcc -v -E conftest.c >/dev/null 2>conftest.out
-    echo '/(\S+(\/|\\\\)cpp)/ && print "[$]1";' > conftest.pl
-    # GNUCPP: used in jmake.c (GnuCppCmd) and in mkdependC
-    # (where we could do with the usual pre-#defines)
-    ac_cv_gnu_cpp="`eval $PerlCmd -n conftest.pl conftest.out`"
-    rm -fr conftest*
-else
-    # It is likely that this will go terribly wrong..
-    ac_cv_gnu_cpp='cc -E'
-fi
+[AC_CACHE_CHECK([how to invoke GNU cpp directly], ac_cv_gnu_cpp,
+[if test "$HaveGcc" = "YES"; then
+       echo > conftest.c
+       gcc -v -E conftest.c >/dev/null 2>conftest.out
+       # \x5c = backslash
+       echo 'tr/\x5c/\//; /(\S+\/cpp)/ && print "[$]1";' > conftest.pl
+       ac_cv_gnu_cpp="`eval $PerlCmd -n conftest.pl conftest.out`"
+       rm -fr conftest*
+ else
+       # We need to be able to invoke CPP directly, preferably
+       # with input from stdin (mkdependHS and hscpp depend on
+       # this at the moment).
+       # Take a guess at what to use, this probably won't work.
+       echo Warning: GNU cpp not found, using $CPP
+       ac_cv_gnu_cpp = $CPP
+ fi
 ])
 GNUCPP=$ac_cv_gnu_cpp
-if test "$GNUCPP" = "cc -E"; then
-   RAWCPP="$GNUCPP"
-else
-   RAWCPP="$GNUCPP -traditional"
-fi
+RAWCPP="$GNUCPP -traditional"
 AC_SUBST(GNUCPP)
 AC_SUBST(RAWCPP)
 ])
@@ -315,3 +340,45 @@ else
 fi
 rm -fr conftest*
 ])
+
+dnl ** figure out whether types can be word-aligned
+dnl    (test based on test in smalltalk-1.1.5 configuration)
+dnl    (required SIZEOF test but AC_CHECK_SIZEOF doesn't call PROVIDE
+dnl     so we can't call REQUIRE)
+
+dnl GHC_CHECK_ALIGNMENT(TYPE)
+AC_DEFUN(GHC_CHECK_ALIGNMENT,
+[changequote(<<, >>)dnl
+dnl The name to #define.
+define(<<AC_TYPE_NAME>>, translit(alignment_$1, [a-z *], [A-Z_P]))dnl
+dnl The cache variable name.
+define(<<AC_CV_NAME>>, translit(ac_cv_alignment_$1, [ *], [_p]))dnl
+dnl The name of the corresponding size.
+define(<<AC_CV_SIZEOF_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
+changequote([, ])dnl
+AC_MSG_CHECKING(alignment of $1)
+AC_CACHE_VAL(AC_CV_NAME,
+[AC_TRY_RUN([
+main()
+{
+    unsigned int vec[3];
+    $1 test, *testptr;
+
+    test = *($1 *)&vec[1];
+    testptr = ($1 *)&vec[1];
+    *testptr = test;
+
+    exit(0);
+}
+],
+AC_CV_NAME=$ac_cv_sizeof_unsigned_int,
+AC_CV_NAME=$AC_CV_SIZEOF_NAME,
+AC_CV_NAME=$AC_CV_SIZEOF_NAME)])
+AC_MSG_RESULT($AC_CV_NAME)
+AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
+AC_PROVIDE($AC_TYPE_NAME)
+undefine([AC_TYPE_NAME])dnl
+undefine([AC_CV_NAME])dnl
+undefine([AC_CV_SIZEOF_NAME])dnl
+])
+