]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
AC_CHECK_FUNCS_ONCE: honor current AC_LANG
authorEric Blake <eblake@redhat.com>
Thu, 3 Nov 2016 15:28:07 +0000 (10:28 -0500)
committerEric Blake <eblake@redhat.com>
Tue, 20 Dec 2016 19:34:20 +0000 (13:34 -0600)
Previously, AC_CHECK_FUNCS_ONCE collected a list of function 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_FUNCS_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 function name in one language; attempting to add a name again
under AC_CHECK_FUNCS_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_FUNC does not include a language prefix).

* lib/autoconf/functions.m4 (_AC_CHECK_FUNC_ONCE)
(_AC_FUNCS_EXPANSION):
* NEWS: Mention it.

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

diff --git a/NEWS b/NEWS
index a4c53ddf89db9d41c4eae8217a922b6559ca9252..532e15e73f280b56d876afdd7b3c77dc1063e02f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -111,6 +111,10 @@ 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.
+
 ** 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 66abe2946d3617e5d91686ee9c164f004c5850a0..7b98a0664a03ba5730f7ce20509b149dd0bfe198 100644 (file)
@@ -96,9 +96,9 @@ AC_DEFUN([AC_CHECK_FUNCS],
 # -----------------------------
 # Check for a single FUNCTION once.
 m4_define([_AC_CHECK_FUNC_ONCE],
-[_AH_CHECK_FUNC([$1])AC_DEFUN([_AC_Func_$1],
-  [m4_divert_text([INIT_PREPARE], [AS_VAR_APPEND([ac_func_list], [" $1"])])
-_AC_FUNCS_EXPANSION])AC_REQUIRE([_AC_Func_$1])])
+[_AH_CHECK_FUNC([$1])AC_DEFUN([_AC_Func_$1], [m4_divert_text([INIT_PREPARE],
+  [AS_VAR_APPEND([ac_func_]]_AC_LANG_ABBREV[[_list], [" $1"])])
+_AC_FUNCS_EXPANSION(_AC_LANG_ABBREV)])AC_REQUIRE([_AC_Func_$1])])
 
 # AC_CHECK_FUNCS_ONCE(FUNCTION...)
 # --------------------------------
@@ -107,12 +107,13 @@ _AC_FUNCS_EXPANSION])AC_REQUIRE([_AC_Func_$1])])
 AC_DEFUN([AC_CHECK_FUNCS_ONCE],
 [m4_map_args_w([$1], [_AC_CHECK_FUNC_ONCE(], [)])])
 
+# _AC_FUNCS_EXPANSION(LANG)
+# -------------------------
+# One-shot code per language LANG for checking all functions registered by
+# AC_CHECK_FUNCS_ONCE while that language was active.
 m4_define([_AC_FUNCS_EXPANSION],
-[
-  m4_divert_text([DEFAULTS], [ac_func_list=])
-  AC_CHECK_FUNCS([$ac_func_list])
-  m4_define([_AC_FUNCS_EXPANSION], [])
-])
+[m4_ifndef([$0($1)], [m4_define([$0($1)])m4_divert_text([DEFAULTS],
+[ac_func_$1_list=])AC_CHECK_FUNCS([$ac_func_$1_list])])])
 
 
 # _AC_REPLACE_FUNC(FUNCTION)