mirror of
git://git.sv.gnu.org/autoconf
synced 2025-02-11 13:51:04 +08:00
Use a shell function for _AC_PREPROC_IFELSE.
* lib/autoconf/general.m4 (_AC_PREPROC_IFELSE_BODY): New macro. (_AC_PREPROC_IFELSE): Use a shell function. * lib/m4sugar/m4sh.m4 (AS_REQUIRE): Factor for faster execution. (AS_REQUIRE_SHELL_FN): Bypass AS_REQUIRE if function has already been provided. Signed-off-by: Eric Blake <ebb9@byu.net>
This commit is contained in:
parent
91fd5ef60a
commit
89839f42af
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2008-10-21 Paolo Bonzini <bonzini@gnu.org>
|
||||
and Eric Blake <ebb9@byu.net>
|
||||
|
||||
Use a shell function for _AC_PREPROC_IFELSE.
|
||||
* lib/autoconf/general.m4 (_AC_PREPROC_IFELSE_BODY): New macro.
|
||||
(_AC_PREPROC_IFELSE): Use a shell function.
|
||||
* lib/m4sugar/m4sh.m4 (AS_REQUIRE): Factor for faster execution.
|
||||
(AS_REQUIRE_SHELL_FN): Bypass AS_REQUIRE if function has already
|
||||
been provided.
|
||||
|
||||
2008-10-21 Eric Blake <ebb9@byu.net>
|
||||
|
||||
Add banners to generated files.
|
||||
|
@ -2377,6 +2377,23 @@ AC_DEFUN([AC_RUN_LOG],
|
||||
## ------------------------ ##
|
||||
|
||||
|
||||
# _AC_PREPROC_IFELSE_BODY
|
||||
# -----------------------
|
||||
# Shell function body for _AC_PREPROC_IFELSE.
|
||||
m4_define([_AC_PREPROC_IFELSE_BODY],
|
||||
[ 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
|
||||
}],
|
||||
[ac_retval=0],
|
||||
[_AC_MSG_LOG_CONFTEST
|
||||
ac_retval=1])
|
||||
rm -f conftest.err
|
||||
AS_LINENO_POP
|
||||
return $ac_retval
|
||||
])
|
||||
|
||||
|
||||
# _AC_PREPROC_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
|
||||
# ----------------------------------------------------------------
|
||||
@ -2385,18 +2402,15 @@ 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 && {
|
||||
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_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.])],
|
||||
[$0_BODY])]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])dnl
|
||||
])# _AC_PREPROC_IFELSE
|
||||
|
||||
|
||||
# AC_PREPROC_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
|
||||
# ---------------------------------------------------------------
|
||||
# Try to preprocess PROGRAM. Requires that the preprocessor for the
|
||||
|
@ -317,11 +317,14 @@ m4_divert_pop[]dnl
|
||||
# Note: we expand _m4_divert_desired before passing it to m4_divert_require,
|
||||
# otherwise we would need to use m4_pushdef and m4_popdef instead of
|
||||
# simply m4_define.
|
||||
#
|
||||
# Since $2 can be quite large, this is factored for faster execution, giving
|
||||
# either m4_require([$1], [$2]) or m4_divert_require(desired, [$1], [$2]).
|
||||
m4_defun([AS_REQUIRE],
|
||||
[m4_define([_m4_divert_desired], [m4_default_quoted([$3], [M4SH-INIT])])dnl
|
||||
m4_if(m4_eval(_m4_divert(_m4_divert_dump) <= _m4_divert(_m4_divert_desired)), 1,
|
||||
[m4_require([$1], [$2])],
|
||||
[m4_divert_require(_m4_divert(_m4_divert_desired), [$1], [$2])])])
|
||||
[m4_define([_m4_divert_desired], [m4_default_quoted([$3], [M4SH-INIT])])]dnl
|
||||
[m4_if(m4_eval(_m4_divert(_m4_divert_dump) <= _m4_divert(_m4_divert_desired)),
|
||||
1, [m4_require(],
|
||||
[m4_divert_require(_m4_divert(_m4_divert_desired),]) [$1], [$2])])
|
||||
|
||||
|
||||
# AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND,
|
||||
@ -333,12 +336,14 @@ m4_if(m4_eval(_m4_divert(_m4_divert_dump) <= _m4_divert(_m4_divert_desired)), 1,
|
||||
# provided (often via AS_FUNCTION_DESCRIBE), it is listed with a
|
||||
# newline before the function name.
|
||||
m4_define([AS_REQUIRE_SHELL_FN],
|
||||
[m4_provide_if([AS_SHELL_FN_$1], [],
|
||||
[AS_REQUIRE([AS_SHELL_FN_$1],
|
||||
[m4_provide([AS_SHELL_FN_$1])m4_n([$2])$1 ()
|
||||
[m4_provide([AS_SHELL_FN_$1])
|
||||
m4_n([$2])$1 ()
|
||||
{
|
||||
$3
|
||||
} [#] $1
|
||||
], m4_default_quoted([$4], [M4SH-INIT-FN]))])
|
||||
], m4_default_quoted([$4], [M4SH-INIT-FN]))])])
|
||||
|
||||
|
||||
# _AS_RUN(TEST, [SHELL])
|
||||
|
Loading…
Reference in New Issue
Block a user