Eric Blake wrote: > According to Paolo Bonzini on 10/16/2008 10:38 AM: >> Hi all, this is *the* patch to add shell functions to Autoconf at last. > >> I am submitting it in one piece for testing, but I'm not really calling >> for review; for that, I'll submit it split in 12 pieces. Also, the zsh >> issue has to be understood better (and could be a deal breaker, though I >> don't think so). > >> But if you love using the bleeding edge of Autoconf, install the git >> master branch somewhere and throw the functionized Autoconf at it. The >> patch applies on top of 2535dcc192d86c46478463049b2acb39f4856413. Any >> Debian, Fedora or Gentoo mavens listening? > > Heads up - with my recent patch to add AS_FUNCTION_DESCRIBE, there is a > build conflict where this patch uses the wrong argument ordering. Either > Paolo or I will try and post an updated patch soon that applies against > git head. Here it is. Paolo
2008-10-16 Paolo Bonzini <bonzini@xxxxxxx> * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_OLD, _AC_CHECK_HEADER_NEW): Use a shell function. * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL): Use a shell function. * lib/autoconf/functions.m4 (AC_CHECK_FUNC): Use a shell function. * lib/autoconf/general.m4 (_AC_COMPUTE_INT_COMPILE, _AC_COMPUTE_INT_RUN): Add IF-SUCCESS argument. (AC_COMPUTE_INT): Use a shell function. (AC_CHECK_DECL): Use a shell function. (_AC_RUN_IFELSE): Use a shell function. (_AC_LINK_IFELSE): Use a shell function. (_AC_COMPILE_IFELSE): Use a shell function. (_AC_PREPROC_IFELSE): Use a shell function. * lib/autoconf/types.m4 (_AC_TYPE_INT, _AC_TYPE_UNSIGNED_INT): Use a shell function. (AC_CHECK_MEMBER): Use a shell function. (_AC_CHECK_TYPE_NEW): Use a shell function. diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4 index c325f30..75c6bf0 100644 --- a/lib/autoconf/functions.m4 +++ b/lib/autoconf/functions.m4 @@ -65,11 +65,20 @@ # AC_CHECK_FUNC(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # ----------------------------------------------------------------- AC_DEFUN([AC_CHECK_FUNC], -[AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl -AC_CACHE_CHECK([for $1], [ac_var], -[AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])], - [AS_VAR_SET([ac_var], [yes])], - [AS_VAR_SET([ac_var], [no])])]) +[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_func], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_func], [LINENO FUNC], + [Tests whether FUNC exists, setting a cache variable accordingly])], [ + AS_LINENO_PUSH([$[]1]) + AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$[]2])dnl + AC_CACHE_CHECK([for $[]2], [ac_var], + [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$][2])], + [AS_VAR_SET([ac_var], [yes])], + [AS_VAR_SET([ac_var], [no])])]) + AS_VAR_POPDEF([ac_var])dnl + AS_LINENO_POP +])dnl +ac_func_[]_AC_LANG_ABBREV[]_check_func "$LINENO" "$1" +AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl AS_VAR_IF([ac_var], [yes], [$2], [$3])dnl AS_VAR_POPDEF([ac_var])dnl ])# AC_CHECK_FUNC diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index beb3104..728ec5e 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -1882,7 +1882,7 @@ m4_define([_AC_CACHE_DUMP], # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. +# setting the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n ['s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p']`; do eval ac_val=\$$ac_var @@ -2362,18 +2362,26 @@ AC_DEFUN([AC_RUN_LOG], # This macro can be used during the selection of a preprocessor. # eval is necessary to expand ac_cpp. AC_DEFUN([_AC_PREPROC_IFELSE], -[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl -AS_IF([_AC_DO_STDERR([$ac_cpp conftest.$ac_ext]) >/dev/null && { +[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_try_cpp], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_try_cpp], [LINENO], + [Try to preprocess conftest.$ac_ext, and return whether this succeeded.])], [ + AS_LINENO_PUSH([$[]1]) + AS_IF([_AC_DO_STDERR([$ac_cpp conftest.$ac_ext]) >/dev/null && { test -z "$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag$ac_[]_AC_LANG_ABBREV[]_werror_flag" || test ! -s conftest.err }], - [$2], - [_AC_MSG_LOG_CONFTEST - $3]) -rm -f conftest.err m4_ifval([$1], [conftest.$ac_ext])[]dnl + [ac_retval=0], + [_AC_MSG_LOG_CONFTEST + ac_retval=1]) + rm -f conftest.err + AS_LINENO_POP + return $ac_retval +])dnl +m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl +AS_IF([ac_func_[]_AC_LANG_ABBREV[]_try_cpp "$LINENO"], [$2], [$3]) +m4_ifvaln([$1], [rm -f conftest.$ac_ext]) ])# _AC_PREPROC_IFELSE - # AC_PREPROC_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # --------------------------------------------------------------- # Try to preprocess PROGRAM. Requires that the preprocessor for the @@ -2434,17 +2442,26 @@ AC_DEFUN([AC_EGREP_HEADER], # ---------------------------------------------------------------- # Try to compile PROGRAM. # This macro can be used during the selection of a compiler. -m4_define([_AC_COMPILE_IFELSE], -[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl -rm -f conftest.$ac_objext -AS_IF([_AC_DO_STDERR($ac_compile) && { +AC_DEFUN([_AC_COMPILE_IFELSE], +[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_try_compile], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_try_compile], [LINENO], + [Try to compile conftest.$ac_ext, and return whether this succeeded.])], [ + AS_LINENO_PUSH([$[]1]) + rm -f conftest.$ac_objext + AS_IF([_AC_DO_STDERR($ac_compile) && { test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext], - [$2], + [ac_retval=0], [_AC_MSG_LOG_CONFTEST - $3]) -rm -f core conftest.err conftest.$ac_objext m4_ifval([$1], [conftest.$ac_ext])[]dnl + ac_retval=1]) + rm -f core conftest.err conftest.$ac_objext + AS_LINENO_POP + return $ac_retval +])dnl +m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl +AS_IF([ac_func_[]_AC_LANG_ABBREV[]_try_compile "$LINENO"], [$2], [$3]) +m4_ifvaln([$1], [rm -f conftest.$ac_ext]) ])# _AC_COMPILE_IFELSE @@ -2482,25 +2499,34 @@ AU_DEFUN([AC_TRY_COMPILE], # reported by Chris Johns in # <http://lists.gnu.org/archive/html/autoconf/2007-03/msg00085.html>. # -m4_define([_AC_LINK_IFELSE], -[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl -rm -f conftest.$ac_objext conftest$ac_exeext -AS_IF([_AC_DO_STDERR($ac_link) && { +AC_DEFUN([_AC_LINK_IFELSE], +[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_try_link], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_try_link], [LINENO], + [Try to link conftest.$ac_ext, and return whether this succeeded.])], [ + AS_LINENO_PUSH([$[]1]) + rm -f conftest.$ac_objext conftest$ac_exeext + AS_IF([_AC_DO_STDERR($ac_link) && { test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || AS_TEST_X([conftest$ac_exeext]) }], - [$2], + [ac_retval=0], [_AC_MSG_LOG_CONFTEST - $3]) -dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization) -dnl information created by the PGI compiler (conftest_ipa8_conftest.oo), -dnl as it would interfere with the next link command. -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl + ac_retval=1]) + # Delete also the IPA/IPO (Inter Procedural Analysis/Optimization) + # information created by the PGI compiler (conftest_ipa8_conftest.oo), + # as it would interfere with the next link command. + rm -rf conftest.dSYM + rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + AS_LINENO_POP + return $ac_retval +])dnl +m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl +AS_IF([ac_func_[]_AC_LANG_ABBREV[]_try_link "$LINENO"], [$2], [$3]) +m4_ifvaln([$1], [rm -f conftest.$ac_ext]) ])# _AC_LINK_IFELSE @@ -2544,22 +2570,27 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])], [$4], [$5])]) # We also remove conftest.o as if the compilation fails, some compilers # don't remove it. We remove gmon.out and bb.out, which may be # created during the run if the program is built with profiling support. -m4_define([_AC_RUN_IFELSE], -[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl -rm -f conftest$ac_exeext -AS_IF([_AC_DO_VAR(ac_link) && _AC_DO_TOKENS(./conftest$ac_exeext)], - [$2], +AC_DEFUN([_AC_RUN_IFELSE], +[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_try_run], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_try_run], [LINENO], + [Try to link conftest.$ac_ext, and return whether this succeeded. + Assumes that executables *can* be run.])], [ + AS_LINENO_PUSH([$[]1]) + AS_IF([_AC_DO_VAR(ac_link) && _AC_DO_TOKENS(./conftest$ac_exeext)], + [ac_retval=0], [AS_ECHO(["$as_me: program exited with status $ac_status"]) >&AS_MESSAGE_LOG_FD -_AC_MSG_LOG_CONFTEST -m4_ifvaln([$3], - [( exit $ac_status ) -$3])dnl])[]dnl -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext m4_ifval([$1], - [conftest.$ac_ext])[]dnl + _AC_MSG_LOG_CONFTEST + ac_retval=$ac_status]) + rm -rf conftest.dSYM + rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest$ac_exeext + AS_LINENO_POP + return $ac_retval +])dnl +m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl +AS_IF([ac_func_[]_AC_LANG_ABBREV[]_try_run "$LINENO"], [$2], [$3]) +m4_ifvaln([$1], [rm -f conftest.$ac_ext]) ])# _AC_RUN_IFELSE - # AC_RUN_IFELSE(PROGRAM, # [ACTION-IF-TRUE], [ACTION-IF-FALSE], # [ACTION-IF-CROSS-COMPILING = RUNTIME-ERROR]) @@ -2636,15 +2667,27 @@ $2], # ------------------------------------------------------- # Check whether SYMBOL (a function, variable, or constant) is declared. AC_DEFUN([AC_CHECK_DECL], -[AS_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$1])dnl -AC_CACHE_CHECK([whether $1 is declared], [ac_Symbol], -[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])], -[#ifndef $1 - (void) $1; +[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_decl], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_decl], + [LINENO SYMBOL], + [Tests whether SYMBOL is declared, setting a cache variable accordingly.])], [ +AS_LINENO_PUSH([$[]1]) +ac_symbol=[$]2 +ac_includes=[$]3 +AS_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$ac_symbol])dnl +AC_CACHE_CHECK([whether $ac_symbol is declared], [ac_Symbol], +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_includes], +[#ifndef $ac_symbol + (void) $ac_symbol; #endif ])], [AS_VAR_SET([ac_Symbol], [yes])], [AS_VAR_SET([ac_Symbol], [no])])]) +AS_VAR_POPDEF([ac_Symbol])dnl +AS_LINENO_POP +])dnl +ac_func_[]_AC_LANG_ABBREV[]_check_decl "$LINENO" "$1" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4], ["])])" +AS_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$1])dnl AS_VAR_IF([ac_Symbol], [yes], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_Symbol])dnl ])# AC_CHECK_DECL @@ -2760,8 +2803,9 @@ AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs]) ## ----------------------------------- ## -# _AC_COMPUTE_INT_COMPILE(EXPRESSION, VARIABLE, PROLOGUE, [IF-FAILS]) -# ------------------------------------------------------------------- +# _AC_COMPUTE_INT_COMPILE(EXPRESSION, VARIABLE, PROLOGUE, [IF-SUCCESS], +# [IF-FAILURE]) +# --------------------------------------------------------------------- # Compute the integer EXPRESSION and store the result in the VARIABLE. # Works OK if cross compiling, but assumes twos-complement arithmetic. m4_define([_AC_COMPUTE_INT_COMPILE], @@ -2797,32 +2841,56 @@ while test "x$ac_lo" != "x$ac_hi"; do _AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) <= $ac_mid])], [ac_hi=$ac_mid], [ac_lo=`expr '(' $ac_mid ')' + 1`]) done +AS_VAR_PUSHDEF([ac_Result], [$2])dnl case $ac_lo in -?*) $2=$ac_lo;; -'') $4 ;; +?*) AS_VAR_SET([ac_Result], [$ac_lo]); $4 ;; +'') $5 ;; esac[]dnl +AS_VAR_POPDEF([ac_Result])dnl ])# _AC_COMPUTE_INT_COMPILE -# _AC_COMPUTE_INT_RUN(EXPRESSION, VARIABLE, PROLOGUE, [IF-FAILS]) -# --------------------------------------------------------------- +# _AC_COMPUTE_INT_RUN(EXPRESSION, VARIABLE, PROLOGUE, [IF-SUCCESS], +# [IF-FAILURE]) +# ----------------------------------------------------------------- # Store the evaluation of the integer EXPRESSION in VARIABLE. m4_define([_AC_COMPUTE_INT_RUN], -[_AC_RUN_IFELSE([AC_LANG_INT_SAVE([$3], [$1])], - [$2=`cat conftest.val`], [$4])]) +[AS_VAR_PUSHDEF([ac_Result], [$2])dnl +_AC_RUN_IFELSE([AC_LANG_INT_SAVE([$3], [$1])], + [AS_VAR_SET([ac_Result], [`cat conftest.val`]); $4], [$5]) +rm -f conftest.val +AS_VAR_POPDEF([ac_Result])dnl +]) # AC_COMPUTE_INT(VARIABLE, EXPRESSION, PROLOGUE, [IF-FAILS]) # ---------------------------------------------------------- AC_DEFUN([AC_COMPUTE_INT], [AC_LANG_COMPILER_REQUIRE()dnl +AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_compute_int], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_compute_int], + [LINENO VAR EXPR INCLUDES], + [Tries to find the compile-time value of EXPR in a program that includes + INCLUDES, setting VAR accordingly. Returns whether the value could + be computed])], [ +AS_LINENO_PUSH([$[]1]) +ac_var=[$]2 +ac_expr=[$]3 +ac_prologue=[$]4 if test "$cross_compiling" = yes; then - _AC_COMPUTE_INT_COMPILE([$2], [$1], [$3], [$4]) + _AC_COMPUTE_INT_COMPILE([$ac_expr], [$ac_var], [$ac_prologue], + [ac_retval=0], [ac_retval=1]) else - _AC_COMPUTE_INT_RUN([$2], [$1], [$3], [$4]) + _AC_COMPUTE_INT_RUN([$ac_expr], [$ac_var], [$ac_prologue], + [ac_retval=0], [ac_retval=1]) fi -rm -f conftest.val[]dnl -])# _AC_COMPUTE_INT +rm -f conftest.val +AS_LINENO_POP +return $ac_retval +])dnl +AS_IF([ac_func_[]_AC_LANG_ABBREV[]_compute_int "$LINENO" "$1" "$2" "AS_ESCAPE([$3], ["])"], + [], [$4]) +])# AC_COMPUTE_INT # _AC_COMPUTE_INT(EXPRESSION, VARIABLE, PROLOGUE, [IF-FAILS]) # ----------------------------------------------------------- diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4 index 16b2737..4801cea 100644 --- a/lib/autoconf/headers.m4 +++ b/lib/autoconf/headers.m4 @@ -103,47 +103,59 @@ AC_DEFUN([AC_CHECK_HEADER], # because it obfuscate the code to try to factor everything, in particular # because of the cache variables, and the `checking...' messages. m4_define([_AC_CHECK_HEADER_MONGREL], -[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl +[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_mongrel], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_header_mongrel], + [LINENO FUNC INCLUDES], + [Tests whether HEADER exists, giving a warning if it cannot be compiled + using the include files in INCLUDES and setting a cache variable accordingly.])], [ +AS_LINENO_PUSH([$[]1]) +ac_header=[$]2 +ac_includes=[$]3 +AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$ac_header])dnl AS_VAR_SET_IF([ac_Header], - [AC_CACHE_CHECK([for $1], [ac_Header], [])], + [AC_CACHE_CHECK([for $ac_header], [ac_Header], [])], [# Is the header compilable? -AC_MSG_CHECKING([$1 usability]) -AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4]) -@%:@include <$1>])], +AC_MSG_CHECKING([$ac_header usability]) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([$ac_includes +@%:@include <$ac_header>])], [ac_header_compiler=yes], [ac_header_compiler=no]) AC_MSG_RESULT([$ac_header_compiler]) # Is the header present? -AC_MSG_CHECKING([$1 presence]) -AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$1>])], +AC_MSG_CHECKING([$ac_header presence]) +AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$ac_header>])], [ac_header_preproc=yes], [ac_header_preproc=no]) AC_MSG_RESULT([$ac_header_preproc]) # So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in +case $ac_header_compiler:$ac_header_preproc:$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in #(( yes:no: ) - AC_MSG_WARN([$1: accepted by the compiler, rejected by the preprocessor!]) - AC_MSG_WARN([$1: proceeding with the compiler's result]) + AC_MSG_WARN([$ac_header: accepted by the compiler, rejected by the preprocessor!]) + AC_MSG_WARN([$ac_header: proceeding with the compiler's result]) ac_header_preproc=yes ;; no:yes:* ) - AC_MSG_WARN([$1: present but cannot be compiled]) - AC_MSG_WARN([$1: check for missing prerequisite headers?]) - AC_MSG_WARN([$1: see the Autoconf documentation]) - AC_MSG_WARN([$1: section "Present But Cannot Be Compiled"]) - AC_MSG_WARN([$1: proceeding with the preprocessor's result]) - AC_MSG_WARN([$1: in the future, the compiler will take precedence]) + AC_MSG_WARN([$ac_header: present but cannot be compiled]) + AC_MSG_WARN([$ac_header: check for missing prerequisite headers?]) + AC_MSG_WARN([$ac_header: see the Autoconf documentation]) + AC_MSG_WARN([$ac_header: section "Present But Cannot Be Compiled"]) + AC_MSG_WARN([$ac_header: proceeding with the preprocessor's result]) + AC_MSG_WARN([$ac_header: in the future, the compiler will take precedence]) m4_ifset([AC_PACKAGE_BUGREPORT], [( AS_BOX([Report this to ]AC_PACKAGE_BUGREPORT) ) | sed "s/^/$as_me: WARNING: /" >&2]) ;; esac -AC_CACHE_CHECK([for $1], [ac_Header], +AC_CACHE_CHECK([for $ac_header], [ac_Header], [AS_VAR_SET([ac_Header], [$ac_header_preproc])]) ])dnl ! set ac_HEADER -AS_VAR_IF([ac_Header], [yes], [$2], [$3])[]dnl +AS_LINENO_POP +])dnl +ac_func_[]_AC_LANG_ABBREV[]_check_header_mongrel "$LINENO" "$1" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4], ["])])" +AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl +AS_VAR_IF([ac_Header], [yes], [$2], [$3])dnl AS_VAR_POPDEF([ac_Header])dnl ])# _AC_CHECK_HEADER_MONGREL @@ -153,13 +165,26 @@ AS_VAR_POPDEF([ac_Header])dnl # [INCLUDES = DEFAULT-INCLUDES]) # -------------------------------------------------------------- # Check the compiler accepts HEADER-FILE. The INCLUDES are defaulted. -m4_define([_AC_CHECK_HEADER_NEW], -[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl -AC_CACHE_CHECK([for $1], [ac_Header], - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4]) -@%:@include <$1>])], +AC_DEFUN([_AC_CHECK_HEADER_NEW], +[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_new], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_header_new], + [LINENO HEADER INCLUDES], + [Tests whether HEADER can be compiled using the include files in INCLUDES, + setting a cache variable accordingly.])], [ +AS_LINENO_PUSH([$[]1]) +ac_header=[$]2 +ac_includes=[$]3 +AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$ac_header])dnl +AC_CACHE_CHECK([for $ac_header], [ac_Header], + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([$ac_includes +@%:@include <$ac_header>])], [AS_VAR_SET([ac_Header], [yes])], [AS_VAR_SET([ac_Header], [no])])]) +AS_VAR_POPDEF([ac_Header]) +AS_LINENO_POP +])dnl +ac_func_[]_AC_LANG_ABBREV[]_check_header_new "$LINENO" "$1" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4], ["])])" +AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl AS_VAR_IF([ac_Header], [yes], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_Header])dnl ])# _AC_CHECK_HEADER_NEW @@ -169,12 +194,23 @@ AS_VAR_POPDEF([ac_Header])dnl # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # -------------------------------------------------------------- # Check the preprocessor accepts HEADER-FILE. -m4_define([_AC_CHECK_HEADER_OLD], -[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl -AC_CACHE_CHECK([for $1], [ac_Header], - [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$1>])], - [AS_VAR_SET([ac_Header], [yes])], - [AS_VAR_SET([ac_Header], [no])])]) +AC_DEFUN([_AC_CHECK_HEADER_OLD], +[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_old], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_header_old], + [LINENO HEADER], + [Tests whether HEADER is present, setting a cache variable accordingly.])], [ +AS_LINENO_PUSH([$[]1]) +ac_header=[$]2 +AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$ac_header])dnl +AC_CACHE_CHECK([for $ac_header], [ac_Header], + [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$ac_header>])], + [AS_VAR_SET([ac_Header], [yes])], + [AS_VAR_SET([ac_Header], [no])])]) +AS_VAR_POPDEF([ac_Header]) +AS_LINENO_POP +])dnl +ac_func_[]_AC_LANG_ABBREV[]_check_header_old "$LINENO" "$1" +AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl AS_VAR_IF([ac_Header], [yes], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_Header])dnl ])# _AC_CHECK_HEADER_OLD diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4 index 0ab85a5..685aa0a 100644 --- a/lib/autoconf/types.m4 +++ b/lib/autoconf/types.m4 @@ -146,20 +146,33 @@ # C++ disallows defining types inside `sizeof ()', but that's OK, # since we don't want to consider unnamed structs to be types for C++, # precisely because they don't work in cases like that. -m4_define([_AC_CHECK_TYPE_NEW], -[AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl -AC_CACHE_CHECK([for $1], [ac_Type], +AC_DEFUN([_AC_CHECK_TYPE_NEW], +[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_type], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_type], + [LINENO TYPE INCLUDES], + [Tests whether TYPE exists after having included INCLUDES, setting a + cache variable accordingly.])], [ +AS_LINENO_PUSH([$[]1]) +ac_type=[$]2 +ac_includes=[$]3 +AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$ac_type])dnl +AC_CACHE_CHECK([for $ac_type], [ac_Type], [AS_VAR_SET([ac_Type], [no]) AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])], - [if (sizeof ($1)) + [AC_LANG_PROGRAM([$ac_includes], + [if (sizeof ($ac_type)) return 0;])], [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])], - [if (sizeof (($1))) + [AC_LANG_PROGRAM([$ac_includes], + [if (sizeof (($ac_type))) return 0;])], [], [AS_VAR_SET([ac_Type], [yes])])])]) +AS_VAR_POPDEF([ac_Type])dnl +AS_LINENO_POP +])dnl +ac_func_[]_AC_LANG_ABBREV[]_check_type "$LINENO" "$1" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4], ["])])" +AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl AS_VAR_IF([ac_Type], [yes], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_Type])dnl ])# _AC_CHECK_TYPE_NEW @@ -628,27 +641,39 @@ AC_DEFUN([AC_TYPE_UINT64_T], [_AC_TYPE_UNSIGNED_INT(64)]) # _AC_TYPE_INT(NBITS) # ------------------- -AC_DEFUN([_AC_TYPE_INT], -[ - AC_CACHE_CHECK([for int$1_t], [ac_cv_c_int$1_t], - [ac_cv_c_int$1_t=no - for ac_type in 'int$1_t' 'int' 'long int' \ +AC_DEFUN([_AC_TYPE_INT_PREPARE], +[AS_REQUIRE_SHELL_FN([ac_func_c_find_intX_t], + [AS_FUNCTION_DESCRIBE([ac_func_c_find_intX_t], [LINENO BITS], + [Finds a signed integer type with width BITS, setting a cache variable + accordingly.])], [ + AS_LINENO_PUSH([$[]1]) + ac_width=[$]2 + AS_VAR_PUSHDEF([ac_Type], [ac_cv_c_int${ac_width}_t])dnl + AC_CACHE_CHECK([for int${ac_width}_t], [ac_Type], + [AS_VAR_SET([ac_Type], [no]) + for ac_type in 'int${ac_width}_t' 'int' 'long int' \ 'long long int' 'short int' 'signed char'; do AC_COMPILE_IFELSE( [AC_LANG_BOOL_COMPILE_TRY( [AC_INCLUDES_DEFAULT], - [[0 < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1)]])], + [[0 < ($ac_type) (((($ac_type) 1 << ($ac_width - 2)) - 1) * 2 + 1)]])], [AC_COMPILE_IFELSE( [AC_LANG_BOOL_COMPILE_TRY( [AC_INCLUDES_DEFAULT], - [[($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1) - < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 2)]])], + [[($ac_type) (((($ac_type) 1 << ($ac_width - 2)) - 1) * 2 + 1) + < ($ac_type) (((($ac_type) 1 << ($ac_width - 2)) - 1) * 2 + 2)]])], [], - [AS_CASE([$ac_type], [int$1_t], - [ac_cv_c_int$1_t=yes], - [ac_cv_c_int$1_t=$ac_type])])]) - test "$ac_cv_c_int$1_t" != no && break + [AS_CASE([$ac_type], [int${ac_width}_t], + [AS_VAR_SET([ac_Type], [yes])], + [AS_VAR_SET([ac_Type], [$ac_type])])])]) + AS_VAR_IF([ac_Type], [no], [], [break]) done]) + AS_LINENO_POP +])]) + +AC_DEFUN([_AC_TYPE_INT], +[AC_REQUIRE([_AC_TYPE_INT_PREPARE]) + ac_func_c_find_intX_t "$LINENO" "$1" case $ac_cv_c_int$1_t in #( no|yes) ;; #( *) @@ -660,21 +685,33 @@ AC_DEFUN([_AC_TYPE_INT], # _AC_TYPE_UNSIGNED_INT(NBITS) # ---------------------------- -AC_DEFUN([_AC_TYPE_UNSIGNED_INT], -[ - AC_CACHE_CHECK([for uint$1_t], [ac_cv_c_uint$1_t], - [ac_cv_c_uint$1_t=no - for ac_type in 'uint$1_t' 'unsigned int' 'unsigned long int' \ +AC_DEFUN([_AC_TYPE_UNSIGNED_INT_PREPARE], +[AS_REQUIRE_SHELL_FN([ac_func_c_find_uintX_t], + [AS_FUNCTION_DESCRIBE([ac_func_c_find_uintX_t], [LINENO BITS], + [Finds an unsigned integer type with width BITS, setting a cache variable + accordingly.])], [ + AS_LINENO_PUSH([$[]1]) + ac_width=[$]2 + AS_VAR_PUSHDEF([ac_Type], [ac_cv_c_uint${ac_width}_t])dnl + AC_CACHE_CHECK([for uint${ac_width}_t], ac_Type, + [AS_VAR_SET([ac_Type], [no]) + for ac_type in 'uint${ac_width}_t' 'unsigned int' 'unsigned long int' \ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do AC_COMPILE_IFELSE( [AC_LANG_BOOL_COMPILE_TRY( [AC_INCLUDES_DEFAULT], - [[($ac_type) -1 >> ($1 - 1) == 1]])], - [AS_CASE([$ac_type], [uint$1_t], - [ac_cv_c_uint$1_t=yes], - [ac_cv_c_uint$1_t=$ac_type])]) - test "$ac_cv_c_uint$1_t" != no && break + [[($ac_type) -1 >> ($ac_width - 1) == 1]])], + [AS_CASE([$ac_type], [uint${ac_width}_t], + [AS_VAR_SET([ac_Type], [yes])], + [AS_VAR_SET([ac_Type], [$ac_type])])]) + AS_VAR_IF([ac_Type], [no], [], [break]) done]) + AS_LINENO_POP +])]) + +AC_DEFUN([_AC_TYPE_UNSIGNED_INT], +[AC_REQUIRE([_AC_TYPE_UNSIGNED_INT_PREPARE]) + ac_func_c_find_uintX_t "$LINENO" "$1" case $ac_cv_c_uint$1_t in #( no|yes) ;; #( *) @@ -812,29 +849,40 @@ you adjust the code.]) # AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell # variables are not a valid argument. AC_DEFUN([AC_CHECK_MEMBER], -[AS_LITERAL_IF([$1], [], - [AC_FATAL([$0: requires literal arguments])])dnl -m4_bmatch([$1], [\.], , - [m4_fatal([$0: Did not see any dot in `$1'])])dnl -AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl +[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_member], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_member], + [LINENO AGGR MEMBER INCLUDES], + [Tries to find the field MEMBER exists in type AGGR, after including + INCLUDES, setting a cache variable accordingly.])], [ +AS_LINENO_PUSH([$[]1]) +ac_aggr=[$]2 +ac_member=[$]3 +ac_includes=[$]4 +AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_${ac_aggr}_${ac_member}])dnl dnl Extract the aggregate name, and the member name -AC_CACHE_CHECK([for $1], [ac_Member], -[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])], -[dnl AGGREGATE ac_aggr; -static m4_bpatsubst([$1], [\..*]) ac_aggr; -dnl ac_aggr.MEMBER; -if (ac_aggr.m4_bpatsubst([$1], [^[^.]*\.])) +AC_CACHE_CHECK([for $ac_aggr.$ac_member], [ac_Member], +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_includes], +[static $ac_aggr ac_aggr; +if (ac_aggr.$ac_member) return 0;])], [AS_VAR_SET([ac_Member], [yes])], -[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])], -[dnl AGGREGATE ac_aggr; -static m4_bpatsubst([$1], [\..*]) ac_aggr; -dnl sizeof ac_aggr.MEMBER; -if (sizeof ac_aggr.m4_bpatsubst([$1], [^[^.]*\.])) +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_includes], +[static $ac_aggr ac_aggr; +if (sizeof ac_aggr.$ac_member) return 0;])], [AS_VAR_SET([ac_Member], [yes])], [AS_VAR_SET([ac_Member], [no])])])]) -AS_VAR_IF([ac_Member], [yes], [$2], [$3])dnl +AS_VAR_POPDEF([ac_Member])dnl +AS_LINENO_POP +])dnl +AS_LITERAL_IF([$1], [], + [AC_FATAL([$0: requires literal arguments])])dnl +m4_bmatch([$1], [\.], , + [m4_fatal([$0: Did not see any dot in `$1'])])dnl +ac_func_[]_AC_LANG_ABBREV[]_check_member "$LINENO" "m4_bpatsubst([$1], [\..*])" \ + "m4_bpatsubst([$1], [^[^.]*\.])" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4], ["])])" +AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl +AS_VAR_IF([ac_Member], [yes], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_Member])dnl ])# AC_CHECK_MEMBER
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf