]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
AC_CHECK_HEADERS_ONCE: honor current AC_LANG
authorEric Blake <eblake@redhat.com>
Wed, 21 Dec 2016 14:32:29 +0000 (08:32 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 21 Dec 2016 14:32:29 +0000 (08:32 -0600)
Previously, AC_CHECK_HEADERS_ONCE collected a list of header names
to check, but ran the checks using the AC_LANG that was active
during the first encounter of the macro.  In practice, this is
usually the C language, and we haven't had actual reports of projects
attempting to use AC_CHECK_HEADERS_ONCE across multiple languages,
rather this was discovered by code inspection.

With this patch, the code now tracks a separate per-language list of
names to check.  Note, however, that it is only possible to check for
a given header name in one language; attempting to add a name again
under AC_CHECK_HEADERS_ONCE while a different language is active is a
no-op (this still makes sense because the side-effect of defining
the CPP macro HAVE_HEADER does not include a language prefix).

* lib/autoconf/headers.m4 (_AC_CHECK_HEADER_ONCE)
(_AC_HEADERS_EXPANSION):
* NEWS: Mention it.

Signed-off-by: Eric Blake <eblake@redhat.com>
NEWS
lib/autoconf/headers.m4

diff --git a/NEWS b/NEWS
index 532e15e73f280b56d876afdd7b3c77dc1063e02f..b82c1e3c3a84f9c825ee7ad642725efef1f78c36 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -111,9 +111,9 @@ GNU Autoconf NEWS - User visible changes.
   useful effect is to trigger those checks, with this macro.  It is
   unlikely to be useful otherwise.
 
-- The AC_CHECK_FUNCS_ONCE macro now supports use with multiple
-  languages, rather than forcing all checks in the language used by
-  the first encounter of the macro.
+- The AC_CHECK_FUNCS_ONCE and AC_CHECK_HEADERS_ONCE macros now support
+  use with multiple languages, rather than forcing all checks in the
+  language used by the first encounter of the macro.
 
 ** Man pages for config.guess and config.sub are no longer provided.
 They were moved to the master source tree for config.guess and config.sub.
index 72262c1eb18f1581c74ccf707c931d15044e0f3f..f6264df2a50f59b6c48a1ddc0fb068f876170745 100644 (file)
@@ -194,10 +194,10 @@ AC_DEFUN([AC_CHECK_HEADERS],
 # Check for a single HEADER-FILE once.
 m4_define([_AC_CHECK_HEADER_ONCE],
 [_AH_CHECK_HEADER([$1])AC_DEFUN([_AC_Header_]m4_translit([[$1]],
-    [./-], [___]),
-  [m4_divert_text([INIT_PREPARE], [AS_VAR_APPEND([ac_header_list], [" $1"])])
-_AC_HEADERS_EXPANSION])AC_REQUIRE([_AC_Header_]m4_translit([[$1]],
-    [./-], [___]))])
+    [./-], [___]), [m4_divert_text([INIT_PREPARE],
+  [AS_VAR_APPEND([ac_header_]]_AC_LANG_ABBREV[[_list], [" $1"])])
+_AC_HEADERS_EXPANSION(_AC_LANG_ABBREV)])AC_REQUIRE(
+  [_AC_Header_]m4_translit([[$1]], [./-], [___]))])
 
 
 # AC_CHECK_HEADERS_ONCE(HEADER-FILE...)
@@ -213,11 +213,14 @@ AC_DEFUN([AC_CHECK_HEADERS_ONCE],
 AC_DEFUN([_AC_CHECK_HEADERS_ONCE],
   [m4_map_args_w([$1], [_AC_CHECK_HEADER_ONCE(], [)])])
 
+# _AC_HEADERS_EXPANSION(LANG)
+# ---------------------------
+# One-shot code per language LANG for checking all headers registered by
+# AC_CHECK_HEADERS_ONCE while that language was active.
 m4_define([_AC_HEADERS_EXPANSION],
-  [m4_divert_text([DEFAULTS], [ac_header_list=])]dnl
-  [AC_CHECK_HEADERS([$ac_header_list], [], [], [$ac_includes_default])]dnl
-  [m4_define([_AC_HEADERS_EXPANSION], [])])
-
+[m4_ifndef([$0($1)], [m4_define([$0($1)])m4_divert_text([DEFAULTS],
+[ac_header_$1_list=])AC_CHECK_HEADERS([$ac_header_$1_list], [], [],
+ [$ac_includes_default])])])