diff --git a/bin/automake.in b/bin/automake.in index f19cac7..9198724 100644 --- a/bin/automake.in +++ b/bin/automake.in @@ -1208,10 +1208,48 @@ sub handle_languages () $output_rules .= (subst ('AMDEP_TRUE') . subst ('am__include') . ' ' - . subst ('am__quote') - . $iter - . subst ('am__quote') - . "\n"); + . subst ('am__quote')); + + # Expand any variables used to specify the source file. + my $i = 0; + while (my @vars = scan_variable_expansions ($iter)) { + # The code in m4/depout.m4 depends on DEPDIR + # being unexpanded. + if (@vars == 1) { + last if ("DEPDIR" eq $vars[0]); + } + + # Don't repeat indefinitely if a variable is defined + # in terms of itself. + $i++; + if ($i == 10) { + fatal "Source file specified with too deep" + . "a level of of variable expansion"; + } + foreach my $varname (@vars) { + # The code in m4/depout.m4 depends on DEPDIR + # being unexpanded. + next if $varname eq "DEPDIR"; + my $var = var $varname; + my ($vardef, $varval); + + if ($var) { + $vardef = $var->def (new Automake::Condition); + # Check that the variable is defined unconditionally. + if (! $vardef) { + fatal "Variable '$varname' defined conditionally" + . " in specification of source file.\n"; + } + } + + $varval = $vardef->value; + $iter =~ s/\$\($varname\)/$varval/g; + $iter =~ s/\${$varname}/$varval/g; + } + } + + $output_rules .= $iter; + $output_rules .= (subst ('am__quote') . "\n"); } # Compute the set of directories to remove in distclean-depend.