[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 06/12] use a shell function for _AC_CHECK_HEADER_MONGREL
From: |
Eric Blake |
Subject: |
Re: [PATCH 06/12] use a shell function for _AC_CHECK_HEADER_MONGREL |
Date: |
Sat, 25 Oct 2008 07:45:10 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Paolo Bonzini on 10/25/2008 6:57 AM:
> I was not sure whether we accepted shells that did not save positional
> parameters, but we actually don't. I will redo patches 7-12 to apply
> the tricks you did (body function, no repeated AS_VAR_PUSHDEF) and not
> save arguments into variables.
You didn't mention 6, but it hadn't been applied yet, so here's what I'm
squashing on top of yours.
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkkDIuYACgkQ84KuGfSFAYCUKACfeTFhYc8nOeyTerXgJjK9JHz9
7LAAmgPsfo7dk5twJABLTpLsx3w+YCjv
=keh/
-----END PGP SIGNATURE-----
>From cd3b8c5be29a233483ee66e74e559df1188d9b75 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Sat, 25 Oct 2008 07:40:00 -0600
Subject: [PATCH] Use a shell function for _AC_CHECK_HEADER_MONGREL.
* lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL_BODY): New
macro.
(_AC_CHECK_HEADER_MONGREL): Use a shell function.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 8 ++++
lib/autoconf/headers.m4 | 99 ++++++++++++++++++++++++-----------------------
2 files changed, 59 insertions(+), 48 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dab6a6e..85088e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-25 Paolo Bonzini <address@hidden>
+ and Eric Blake <address@hidden>
+
+ Use a shell function for _AC_CHECK_HEADER_MONGREL.
+ * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL_BODY): New
+ macro.
+ (_AC_CHECK_HEADER_MONGREL): Use a shell function.
+
2008-10-25 Eric Blake <address@hidden>
Simplify _AS_PREPARE handling of functions.
diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
index 5162fce..4c588ca 100644
--- a/lib/autoconf/headers.m4
+++ b/lib/autoconf/headers.m4
@@ -94,39 +94,24 @@ AC_DEFUN([AC_CHECK_HEADER],
])# AC_CHECK_HEADER
-# _AC_CHECK_HEADER_MONGREL(HEADER-FILE,
-# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
-# [INCLUDES = DEFAULT-INCLUDES])
-# ------------------------------------------------------------------
-# Check using both the compiler and the preprocessor. If they disagree,
-# warn, and the preproc wins.
-#
-# This is not based on _AC_CHECK_HEADER_NEW and _AC_CHECK_HEADER_OLD
-# 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],
-[AC_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 $ac_header], [ac_Header], [])],
- [# Is the header compilable?
-AC_MSG_CHECKING([$ac_header usability])
-AC_COMPILE_IFELSE([AC_LANG_SOURCE([$ac_includes
address@hidden:@include <$ac_header>])],
+# _AC_CHECK_HEADER_MONGREL_BODY
+# -----------------------------
+# Shell function body for _AC_CHECK_HEADER_MONGREL
+m4_define([_AC_CHECK_HEADER_MONGREL_BODY],
+[ AS_LINENO_PUSH([$[]1])
+ AS_VAR_SET_IF([$[]3],
+ [AC_CACHE_CHECK([for $[]2], [$[]3], [])],
+ [# Is the header compilable?
+AC_MSG_CHECKING([$[]2 usability])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([$[]4
address@hidden:@include <$[]2>])],
[ac_header_compiler=yes],
[ac_header_compiler=no])
AC_MSG_RESULT([$ac_header_compiler])
# Is the header present?
-AC_MSG_CHECKING([$ac_header presence])
-AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include <$ac_header>])],
+AC_MSG_CHECKING([$[]2 presence])
+AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include <$[]2>])],
[ac_header_preproc=yes],
[ac_header_preproc=no])
AC_MSG_RESULT([$ac_header_preproc])
@@ -134,32 +119,50 @@ 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 #((
yes:no: )
- 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_MSG_WARN([$[]2: accepted by the compiler, rejected by the
preprocessor!])
+ AC_MSG_WARN([$[]2: proceeding with the compiler's result])
ac_header_preproc=yes
;;
no:yes:* )
- 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])
+ AC_MSG_WARN([$[]2: present but cannot be compiled])
+ AC_MSG_WARN([$[]2: check for missing prerequisite headers?])
+ AC_MSG_WARN([$[]2: see the Autoconf documentation])
+ AC_MSG_WARN([$[]2: section "Present But Cannot Be Compiled"])
+ AC_MSG_WARN([$[]2: proceeding with the preprocessor's result])
+ AC_MSG_WARN([$[]2: in the future, the compiler will take precedence])
+m4_ifset([AC_PACKAGE_BUGREPORT],
+[m4_n([( AS_BOX([Report this to ]AC_PACKAGE_BUGREPORT)
+ ) | sed "s/^/$as_me: WARNING: /" >&2])])dnl
;;
esac
-AC_CACHE_CHECK([for $ac_header], [ac_Header],
- [AS_VAR_SET([ac_Header], [$ac_header_preproc])])[]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
+ AC_CACHE_CHECK([for $[]2], [$[]3],
+ [AS_VAR_SET([$[]3], [$ac_header_preproc])])])
+ AS_LINENO_POP
+])#_AC_CHECK_HEADER_MONGREL_BODY
+
+# _AC_CHECK_HEADER_MONGREL(HEADER-FILE,
+# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+# [INCLUDES = DEFAULT-INCLUDES])
+# ------------------------------------------------------------------
+# Check using both the compiler and the preprocessor. If they disagree,
+# warn, and the preproc wins.
+#
+# This is not based on _AC_CHECK_HEADER_NEW and _AC_CHECK_HEADER_OLD
+# 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],
+[AC_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_mongrel],
+ [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_header_mongrel],
+ [LINENO FUNC VAR INCLUDES],
+ [Tests whether HEADER exists, giving a warning if it cannot be compiled
+ using the include files in INCLUDES and setting the cache variable VAR
+ accordingly.])],
+ [$0_BODY])]dnl
+[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])]dnl
+[ac_func_[]_AC_LANG_ABBREV[]_check_header_mongrel ]dnl
+["$LINENO" "$1" "ac_Header" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4], [""])])"
AS_VAR_IF([ac_Header], [yes], [$2], [$3])
-AS_VAR_POPDEF([ac_Header])dnl
-])# _AC_CHECK_HEADER_MONGREL
+AS_VAR_POPDEF([ac_Header])])# _AC_CHECK_HEADER_MONGREL
# _AC_CHECK_HEADER_NEW(HEADER-FILE,
--
1.6.0.2