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.
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.
# 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: $_";
msg 'syntax', "Use AC_DEFINE([$_], [], [Description])";
$suggest_ac_define = 0;
}
-
}
exit 1
if keys %symbol;
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
+
## ------------ ##