X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=aclocal.m4;h=564bcca8a61074e011704043741fd61ceed616a4;hb=007ad2be2af3375088b3ec774578cc6a1d218ff6;hp=19370ff58ad7c7fa972677e90b273e4a6937d344;hpb=66d0cd00c6fe1588f68604e513f4b2c7336359a1;p=ghc-hetmet.git diff --git a/aclocal.m4 b/aclocal.m4 index 19370ff..564bcca 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -4,11 +4,83 @@ # ensure we don't clash with any pre-supplied autoconf ones. -# FP_ALTZONE +# FP_EVAL_STDERR(COMMAND) +# ------------------------ +# Eval COMMAND, save its stderr (without lines resulting from shell tracing) +# into the file conftest.err and the exit status in the variable fp_status. +AC_DEFUN([FP_EVAL_STDERR], +[{ (eval $1) 2>conftest.er1 + fp_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + (exit $fp_status); }[]dnl +])# FP_EVAL_STDERR + + +# FP_CHECK_FLAG(FLAG, [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED]) +# ----------------------------------------------------------------------- +# Check to see whether the compiler for the current language supports a +# particular option. +# +# Implementation note: When given an unkown option, GCC issues an warning on +# stderr only, but returns an exit value of 0 nevertheless. Consequently we have +# to check stderr *and* the exit value. +# +# Used by ghc. +AC_DEFUN(FP_CHECK_FLAG, +[AC_LANG_COMPILER_REQUIRE()dnl +AC_LANG_CASE([C], [fp_compiler="$CC" m4_pushdef([fp_Flags], [CFLAGS])], + [C++], [fp_compiler="$CXX" m4_pushdef([fp_Flags], [CXXFLAGS])], + [Fortran 77], [fp_compiler="$F77" m4_pushdef([fp_Flags], [FFLAGS])]) +m4_pushdef([fp_Cache], [fp_cv_[]fp_Flags[]AS_TR_SH([$1])])[]dnl +AC_CACHE_CHECK([whether $fp_compiler accepts $1], [fp_Cache], +[AC_LANG_CONFTEST([AC_LANG_PROGRAM()]) +fp_save_flags="$fp_Flags" +fp_Flags="$fp_Flags $1" +fp_Cache=no +if FP_EVAL_STDERR([$ac_compile conftest.$ac_ext]) >/dev/null; then + test -s conftest.err || fp_Cache=yes +fi +fp_Flags="$fp_save_flags" +rm -f conftest.err conftest.$ac_ext]) +AS_IF([test $fp_Cache = yes], [$2], [$3])[]dnl +m4_popdef([fp_Cache])[]dnl +m4_popdef([fp_Flags])[]dnl +])# FP_CHECK_FLAG + + +# FP_PROG_CONTEXT_DIFF +# -------------------- +# Figure out how to do context diffs. Sets the output variable ContextDiffCmd. +# +# Note: NeXTStep thinks diff'ing a file against itself is "trouble". +# +# Used by ghc, glafp-utils/ltx, and glafp-utils/runstdtest. +AC_DEFUN([FP_PROG_CONTEXT_DIFF], +[AC_CACHE_CHECK([for a working context diff], [fp_cv_context_diff], +[echo foo > conftest1 +echo foo > conftest2 +fp_cv_context_diff=no +for fp_var in '-C 1' '-c1' +do + if diff $fp_var conftest1 conftest2 > /dev/null 2>&1; then + fp_cv_context_diff="diff $fp_var" + break + fi +done]) +if test x"$fp_cv_context_diff" = xno; then + AC_MSG_ERROR([cannot figure out how to do context diffs]) +fi +AC_SUBST(ContextDiffCmd, [$fp_cv_context_diff]) +])# FP_PROG_CONTEXT_DIFF + + +# FP_DECL_ALTZONE # ------------------- # Defines HAVE_DECL_ALTZONE to 1 if declared, 0 otherwise. +# # Used by base package. -AC_DEFUN([FP_ALTZONE], +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 @@ -21,7 +93,44 @@ AC_CHECK_DECLS([altzone], [], [],[#if TIME_WITH_SYS_TIME # include # endif #endif]) -])# FP_ALTZONE +])# FP_DECL_ALTZONE + + +# FP_COMPUTE_INT(EXPRESSION, VARIABLE, INCLUDES, IF-FAILS) +# --------------------------------------------------------- +# Assign VARIABLE the value of the compile-time EXPRESSION using INCLUDES for +# compilation. Execute IF-FAILS when unable to determine the value. Works for +# cross-compilation, too. +# +# Implementation note: We are lazy and use an internal autoconf macro, but it +# is supported in autoconf versions 2.50 up to the actual 2.57, so there is +# little risk. +AC_DEFUN([FP_COMPUTE_INT], +[_AC_COMPUTE_INT([$1], [$2], [$3], [$4])[]dnl +])# FP_COMPUTE_INT + + +# FP_CHECK_ALIGNMENT(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES]) +# ------------------------------------------------------------------ +# A variation of AC_CHECK_SIZEOF for computing the alignment restrictions of a +# given type. Defines ALIGNMENT_TYPE. +AC_DEFUN([FP_CHECK_ALIGNMENT], +[AS_LITERAL_IF([$1], [], + [AC_FATAL([$0: requires literal arguments])])[]dnl +AC_CHECK_TYPE([$1], [], [], [$3]) +AC_CACHE_CHECK([alignment of $1], AS_TR_SH([fp_cv_alignment_$1]), +[if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then + FP_COMPUTE_INT([(long) (&((struct { char c; $1 ty; } *)0)->ty)], + [AS_TR_SH([fp_cv_alignment_$1])], + [AC_INCLUDES_DEFAULT([$3])], + [AC_MSG_ERROR([cannot compute alignment ($1) +See `config.log' for more details.], [77])]) +else + AS_TR_SH([fp_cv_alignment_$1])=0 +fi])dnl +AC_DEFINE_UNQUOTED(AS_TR_CPP(alignment_$1), $AS_TR_SH([fp_cv_alignment_$1]), + [The alignment of a `$1'.]) +])# FP_CHECK_ALIGNMENT dnl ** check for leading underscores in symbol names @@ -87,7 +196,7 @@ esac); LeadingUnderscore=`echo $fptools_cv_lead_uscore | sed 'y/yesno/YESNO/'` AC_SUBST(LeadingUnderscore) case $LeadingUnderscore in -YES) AC_DEFINE(LEADING_UNDERSCORE);; +YES) AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.]);; esac ]) @@ -236,31 +345,6 @@ AlexVersion=$fptools_cv_alex_version; AC_SUBST(AlexVersion) ]) -dnl -dnl What's the best way of doing context diffs? -dnl -dnl (NB: NeXTStep thinks diff'ing a file against itself is "trouble") -dnl -AC_DEFUN(FPTOOLS_PROG_DIFF, -[AC_CACHE_CHECK([for ok way to do context diffs], fptools_cv_context_diffs, -[echo foo > conftest1 -echo foo > conftest2 -if diff -C 1 conftest1 conftest2 > /dev/null 2>&1 ; then - fptools_cv_context_diffs='diff -C 1' -else - if diff -c1 conftest1 conftest2 > /dev/null 2>&1 ; then - fptools_cv_context_diffs='diff -c1' - else - echo "Can't figure out how to do context diffs." - echo "Neither \`diff -C 1' nor \`diff -c1' works." - exit 1 - fi -fi -rm -f conftest1 conftest2 -]) -ContextDiffCmd=$fptools_cv_context_diffs -AC_SUBST(ContextDiffCmd) -]) dnl dnl Check whether ld supports -x @@ -416,7 +500,7 @@ AC_DEFUN(FPTOOLS_GCC_NEEDS_NO_OMIT_LFPTR, fptools_cv_gcc_needs_no_omit_lfptr='yes') ]) if test "$fptools_cv_gcc_needs_no_omit_lfptr" = "yes"; then - AC_DEFINE(HAVE_GCC_MNO_OMIT_LFPTR) + AC_DEFINE([HAVE_GCC_MNO_OMIT_LFPTR], [1], [Define to 1 if gcc supports -mno-omit-leaf-frame-pointer.]) fi ]) @@ -531,49 +615,6 @@ ifelse($#, [1], [dnl ])dnl -dnl ** figure out the alignment restriction of a type -dnl (required SIZEOF test but AC_CHECK_SIZEOF doesn't call PROVIDE -dnl so we can't call REQUIRE) - -dnl FPTOOLS_CHECK_ALIGNMENT(TYPE) -AC_DEFUN(FPTOOLS_CHECK_ALIGNMENT, -[changequote(<<, >>)dnl -dnl The name to #define. -define(<>, translit(alignment_$1, [a-z *], [A-Z_P]))dnl -dnl The cache variable name. -define(<>, translit(ac_cv_alignment_$1, [ *], [_p]))dnl -dnl The name of the corresponding size. -define(<>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl -changequote([, ])dnl -AC_MSG_CHECKING(alignment of $1) -AC_CACHE_VAL(AC_CV_NAME, -[AC_TRY_RUN([ -#include -#if HAVE_STDDEF_H -#include -#endif -#ifndef offsetof -#define offsetof(ty,field) ((size_t)((char *)&((ty *)0)->field - (char *)(ty *)0)) -#endif -int -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d", offsetof(struct { char c; $1 ty;},ty)); - exit(0); -}], -AC_CV_NAME=`cat conftestval`, -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 -]) - dnl ** Map an arithmetic C type to a Haskell type. dnl Based on autconf's AC_CHECK_SIZEOF. @@ -658,7 +699,7 @@ main() { ifelse([$2], , AC_CV_NAME=NotReallyAType, AC_CV_NAME=$2), ifelse([$3], , AC_CV_NAME=NotReallyATypeCross, AC_CV_NAME=$3))]) dnl AC_MSG_RESULT($AC_CV_NAME) -AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME) +AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [Define to Haskell type for $1]) undefine([AC_TYPE_NAME])dnl undefine([AC_CV_NAME])dnl ]) @@ -688,15 +729,26 @@ eval "$cv_name=-1", eval "$cv_name=-1")])dnl eval "fptools_check_cconst_result=`echo '$'{$cv_name}`" AC_MSG_RESULT($fptools_check_cconst_result) -AC_DEFINE_UNQUOTED(CCONST_$1, $fptools_check_cconst_result) +AC_DEFINE_UNQUOTED(CCONST_$1, $fptools_check_cconst_result, [The value of $1.]) unset fptools_check_cconst_result ]) + +# FP_CHECK_CCONSTS_TEMPLATE(CONST...) +# ----------------------------------- +m4_define([FP_CHECK_CCONSTS_TEMPLATE], +[AC_FOREACH([FP_Const], [$1], + [AH_TEMPLATE(AS_TR_CPP(CCONST_[]FP_Const), + [The value of ]FP_Const[.])])[]dnl +])# FP_CHECK_CCONSTS_TEMPLATE + + dnl ** Invoke AC_CHECK_CCONST on each argument (which have to separate with dnl spaces) dnl AC_DEFUN(FPTOOLS_CHECK_CCONSTS, -[for ac_const_name in $1 +[FP_CHECK_CCONSTS_TEMPLATE([$1])dnl +for ac_const_name in $1 do FPTOOLS_CHECK_CCONST($ac_const_name)dnl done @@ -724,16 +776,10 @@ AC_LANG_RESTORE ]) AC_MSG_RESULT($fptools_cv_have_o_binary) if test "$fptools_cv_have_o_binary" = yes; then -AC_DEFINE(HAVE_O_BINARY) + AC_DEFINE([HAVE_O_BINARY], [1], [Define to 1 if fcntl.h defines O_BINARY.]) fi ]) -dnl *** Helper function ** -dnl -AC_DEFUN(FPTOOLS_IN_SCOPE, -[AC_TRY_LINK([extern char* $1;],[return (int)&$2], $3=yes, $3=no) -]) - dnl Based on AC_TRY_LINK - run iftrue if links cleanly with no warning @@ -807,24 +853,6 @@ AC_DEFUN(FPTOOLS_CHECK_LIB_NOWARN, )])] ) -dnl check for prototypes -dnl -AC_DEFUN([AC_C_PROTOTYPES], -[AC_CACHE_CHECK([prototypes], ac_cv_prototypes, -[AC_TRY_COMPILE([ -void foo(int); -void foo(i) -int i; { -return; -} -], -[int i;], -ac_cv_prototypes=yes, -ac_cv_prototypes=no)]) -if test "$ac_cv_prototypes" = yes; then -AC_DEFINE([HAVE_PROTOTYPES]) -fi -]) dnl ** Check which CATALOG file we have to use with DocBook SGML. dnl @@ -1103,56 +1131,3 @@ dnl and we don't want to be global namespace polluters. ]) # LocalWords: fi - - -dnl -dnl Check to see whether CC (gcc) supports a particular option. -dnl -AC_DEFUN(FPTOOLS_CC_FLAG, -[ -AC_CACHE_CHECK([whether $CC accepts $1], [ac_cv_cc_$2], -[save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $1" - AC_LANG_C - AC_TRY_COMPILE(,[int main(){return(0);}], - [ac_cv_cc_$2=yes], - [ac_cv_cc_$2=no]) - CFLAGS="$save_CFLAGS" -]) -if test "$ac_cv_cc_$2"x = "yesx"; then - $2=$1; -else - $2=""; -fi; -]) - -dnl -dnl Check to see whether 'struct msghdr' contains msg_control -dnl -AC_DEFUN(FPTOOLS_MSGHDR_MSG_CONTROL, -[AC_CACHE_CHECK([for msg_control in struct msghdr], fptools_cv_struct_msghdr_msg_control, -[AC_TRY_COMPILE([#include -#include -#include ], [struct msghdr m; m.msg_control;], -fptools_cv_struct_msghdr_msg_control=yes, fptools_cv_struct_msghdr_msg_control=no)]) -if test $fptools_cv_struct_msghdr_msg_control = yes; then - AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL) -fi -AC_SUBST(HAVE_MSGHDR_MSG_CONTROL)dnl -]) - -dnl -dnl Check to see whether 'struct msghdr' contains msg_accrights -dnl -AC_DEFUN(FPTOOLS_MSGHDR_MSG_ACCRIGHTS, -[AC_CACHE_CHECK([for msg_accrights in struct msghdr], fptools_cv_struct_msghdr_msg_accrights, -[AC_TRY_COMPILE([#include -#include -#include ], [struct msghdr m; m.msg_accrights;], -fptools_cv_struct_msghdr_msg_accrights=yes, fptools_cv_struct_msghdr_msg_accrights=no)]) -if test $fptools_cv_struct_msghdr_msg_accrights = yes; then - AC_DEFINE(HAVE_MSGHDR_MSG_ACCRIGHTS) -fi -AC_SUBST(HAVE_MSGHDR_MSG_ACCRIGHTS)dnl -]) -