]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
autoheader: check templates of all config headers
authorDaniel Elstner <daniel.kitta@gmail.com>
Wed, 21 Dec 2016 16:15:46 +0000 (17:15 +0100)
committerEric Blake <eblake@redhat.com>
Wed, 21 Dec 2016 16:31:54 +0000 (10:31 -0600)
* bin/autoheader.in: When checking for missing templates, take
all config headers into account, not just the one generated by
autoheader.  This makes it possible to use AC_DEFINE() for
secondary headers without duplicating the template into the
first header.
* tests/tools.at: Add a check for autoheader with multiple
config headers.
* NEWS: Document the new behavior.
Message-Id: <1482336946.31331.2.camel@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
NEWS
bin/autoheader.in
tests/tools.at

diff --git a/NEWS b/NEWS
index b82c1e3c3a84f9c825ee7ad642725efef1f78c36..a1f741fc07c79fd2950e49713166aa4922a1eaae 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,11 @@ GNU Autoconf NEWS - User visible changes.
    is now deprecated.  If you really need that behavior use
    AC_PREPROC_IFELSE.
 
+** When checking for missing templates, autoheader now takes any
+   templates defined in the inputs of secondary config headers into
+   account.  This makes it possible to use AC_DEFINE for secondary
+   headers without duplicating the template in the main config header.
+
 ** Macros
 
 - New macro AC_C__GENERIC.
index 528e22cff51db2ebdeb59bb649f7ade344f23981..2d2f94321dcd65433670671a98a2e3a72d936124 100644 (file)
@@ -191,11 +191,21 @@ unless ($config_h)
     exit 1;
   }
 
-# We template only the first CONFIG_HEADER.
-$config_h =~ s/ .*//;
 # Support "outfile[:infile]", defaulting infile="outfile.in".
-($config_h, $config_h_in) = split (':', $config_h, 2);
-$config_h_in ||= "$config_h.in";
+sub templates_for_header
+{
+  my ($spec) = @_;
+  my ($header, @templates) = split(':', $spec);
+
+  return @templates if @templates;
+  return $header . '.in';
+}
+
+my @config_templates = map(templates_for_header($_), split(' ', $config_h));
+
+# We template only the first CONFIG_HEADER.
+$config_h_in = shift(@config_templates);
+$config_h =~ s/[ :].*//;
 
 # %SYMBOL might contain things like 'F77_FUNC(name,NAME)', but we keep
 # only the name of the macro.
@@ -261,14 +271,20 @@ $out->close;
 
 # Check that all the symbols have a template.
 {
-  my $in = new Autom4te::XFile ("$tmp/config.hin", "<");
-  my $suggest_ac_define = 1;
-  while ($_ = $in->getline)
+  foreach my $template ("$tmp/config.hin", @config_templates)
     {
-      my ($symbol) = /^\#\s*\w+\s+(\w+)/
-       or next;
-      delete $symbol{$symbol};
+      my $in = new Autom4te::XFile ($template, "<");
+
+      while ($_ = $in->getline)
+       {
+         my ($sym) = /^\#\s*\w+\s+(\w+)/
+           or next;
+         delete $symbol{$sym};
+       }
     }
+
+  my $suggest_ac_define = 1;
+
   foreach (sort keys %symbol)
     {
       msg 'syntax', "warning: missing template: $_";
@@ -277,7 +293,6 @@ $out->close;
          msg 'syntax',  "Use AC_DEFINE([$_], [], [Description])";
          $suggest_ac_define = 0;
        }
-
     }
   exit 1
     if keys %symbol;
index 4993b3f58acfae7a469b3c31613cf50770e0d8c9..2592a2091bd5ef5193cfbe7f288050b4a16c2c76 100644 (file)
@@ -860,6 +860,31 @@ config.h.in:0
 AT_CLEANUP
 
 
+# autoheader should take all config header inputs into account when
+# checking for missing templates.
+AT_SETUP([autoheader with multiple headers])
+
+AT_DATA([config-extra.h.in],
+[[/* Define this to whatever you want. */
+#undef HANNA
+]])
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_HEADERS([config.h config-extra.h])
+AC_DEFINE([HANNA], ["Hanna"])
+AC_DEFINE([SEAN], ["Sean"], [Sean's name])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK([grep HANNA configure], [0], [ignore], [ignore])
+AT_CHECK([grep HANNA config.h.in], [1], [ignore], [ignore])
+AT_CHECK([grep SEAN configure], [0], [ignore], [ignore])
+AT_CHECK([grep SEAN config.h.in], [0], [ignore], [ignore])
+
+AT_CLEANUP
+
 
 
 ## ------------ ##