]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
AC_CHECK_HEADERS_ONCE: hoist CPP name computation to m4 time
authorEric Blake <eblake@redhat.com>
Wed, 21 Dec 2016 14:32:39 +0000 (08:32 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 21 Dec 2016 14:32:39 +0000 (08:32 -0600)
Rather than perform a sed script on each element of the
$ac_header_c_list to compute the corresponding CPP name, we can
make the list store a series of triples of header names, shell-safe
names, and CPP names all computed at m4 time.

The resulting configure script is slightly larger based on
how many headers are checked once, but also performs
slightly faster.

There is still a sed call in AC_CHECK_HEADER for computing the
cache variable name; that will be dealt with next.  That patch
will also be the one that takes advantage of the shell-safe name.

* lib/autoconf/headers.m4 (_AC_CHECK_HEADER_ONCE): Track the shell
and CPP name in the list...
(_AC_HEADERS_EXPANSION): ...and rewrite the list walk to parse off
triples of arguments, for fewer sed calls.

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

index f6264df2a50f59b6c48a1ddc0fb068f876170745..98bfa80927a8824da6b9f201ac4b44560f2d866d 100644 (file)
@@ -195,8 +195,9 @@ AC_DEFUN([AC_CHECK_HEADERS],
 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_]]_AC_LANG_ABBREV[[_list], [" $1"])])
-_AC_HEADERS_EXPANSION(_AC_LANG_ABBREV)])AC_REQUIRE(
+  [AS_VAR_APPEND([ac_header_]]_AC_LANG_ABBREV[[_list],
+  [" $1 ]AS_TR_SH([$1]) AS_TR_CPP([HAVE_$1])["])])]dnl
+[_AC_HEADERS_EXPANSION(_AC_LANG_ABBREV)])AC_REQUIRE(
   [_AC_Header_]m4_translit([[$1]], [./-], [___]))])
 
 
@@ -219,8 +220,19 @@ AC_DEFUN([_AC_CHECK_HEADERS_ONCE],
 # AC_CHECK_HEADERS_ONCE while that language was active.
 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])])])
+[ac_header_$1_list=])ac_header= ac_cache=
+for ac_item in $ac_header_$1_list
+do
+  if test $ac_cache; then
+    AC_CHECK_HEADER([$ac_header], [AC_DEFINE_UNQUOTED([$ac_item])],
+      [], [$ac_includes_default])
+    ac_header= ac_cache=
+  elif test $ac_header; then
+    ac_cache=$ac_item
+  else
+    ac_header=$ac_item
+  fi
+done])])