summaryrefslogtreecommitdiff
path: root/automake.in
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2011-01-10 15:50:35 +0100
committerStefano Lattarini <stefano.lattarini@gmail.com>2011-01-11 00:51:15 +0100
commit834dc3a98272e7eb1869e2a1972ac14ea45e0ec0 (patch)
tree05d8e1223452c45267bba5f123bf557cc82d454e /automake.in
parent3544a43c4923f767467536d02abb511d7e04ab2c (diff)
downloadautomake-834dc3a98272e7eb1869e2a1972ac14ea45e0ec0.tar.gz
yacc: warn about conditional content in *YFLAGS variables
This commit fixes automake bug#7804. * automake.in (lang_yacc_target_hook): Warn if any of the relevant *YFLAGS variables has conditional contents (not only a conditional definition). Related refactoring. * NEWS: Updated. * tests/yflags-conditional.test: Updated and extended. * tests/yflags-conditional-force.test: New test. * tests/Makefile.am (TESTS): Updated.
Diffstat (limited to 'automake.in')
-rwxr-xr-xautomake.in34
1 files changed, 24 insertions, 10 deletions
diff --git a/automake.in b/automake.in
index 2bffe4814..fa458d6f0 100755
--- a/automake.in
+++ b/automake.in
@@ -6061,15 +6061,29 @@ sub lang_yacc_target_hook
{
my ($self, $aggregate, $output, $input, %transform) = @_;
- my $flagvar = var ($aggregate . "_YFLAGS");
- my $YFLAGSvar = var ('YFLAGS');
- # We cannot work reliably with conditionally-defined YFLAGS.
- $flagvar->check_defined_unconditionally if $flagvar;
- $YFLAGSvar->check_defined_unconditionally if $YFLAGSvar;
- my @flags = $flagvar ? $flagvar->value_as_list_recursive : ();
- my @YFLAGS = $YFLAGSvar ? $YFLAGSvar->value_as_list_recursive : ();
- if (grep (/^-d$/, @flags) || grep (/^-d$/, @YFLAGS))
- {
+ # If some relevant *YFLAGS variable contains the `-d' flag, we'll
+ # have to to generate special code.
+ my $yflags_contains_minus_d = 0;
+
+ foreach my $pfx ("", "${aggregate}_")
+ {
+ my $yflagsvar = var ("${pfx}YFLAGS");
+ next unless $yflagsvar;
+ # We cannot work reliably with conditionally-defined YFLAGS.
+ if ($yflagsvar->has_conditional_contents)
+ {
+ msg_var ('unsupported', $yflagsvar,
+ "`${pfx}YFLAGS' cannot have conditional contents");
+ }
+ else
+ {
+ $yflags_contains_minus_d = 1
+ if grep (/^-d$/, $yflagsvar->value_as_list_recursive);
+ }
+ }
+
+ if ($yflags_contains_minus_d)
+ {
(my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//;
my $header = $output_base . '.h';
@@ -6098,7 +6112,7 @@ sub lang_yacc_target_hook
# then we want to remove them with "make clean"; otherwise,
# "make distcheck" will fail.
$clean_files{$header} = $transform{'DIST_SOURCE'} ? MAINTAINER_CLEAN : CLEAN;
- }
+ }
# See the comment above for $HEADER.
$clean_files{$output} = $transform{'DIST_SOURCE'} ? MAINTAINER_CLEAN : CLEAN;
}