hi peeps
enclosed is a patch which emits targets for
partially specified conditional targets
e.g.
bin_PROGRAMS = do_me
if HAVE_DO_ME
do_me_SOURCES = do_me.c
else
do_me:
echo ok do me
touch do_me
endif
both targets get generated, with the proper test.
nested stuff works too it seems
Index:
automake.in
=================================================================== RCS file: /cvs/automake/automake/automake.in,v retrieving revision 1.975 diff -u -r1.975 automake.in --- automake.in 2001/03/08 13:23:15 1.975 +++ automake.in 2001/03/09 02:33:13 @@ -6750,20 +6750,36 @@ { # Free lance dependency. Output the rule for all the # targets instead of one by one. + # Some hair to avoid spurious trailing blank + # when there are no dependencies. + my $tmp_rules = ""; + $tmp_rules .= "$separator$comment"; + $tmp_rules .= "$targets:"; + $tmp_rules .= " $dependencies" + if $dependencies; + $tmp_rules .= "\n"; + # Only add actions if we found some. Otherwise + # we can end up with a spurious newline. See + # pr87.test. + $tmp_rules .= "$actions\n" + if $actions; + if (!defined $targets{$targets}) + { + $output_rules .= $tmp_rules; + } + else { - # Some hair to avoid spurious trailing blank - # when there are no dependencies. - $result_rules .= "$separator$comment"; - $result_rules .= "$targets:"; - $result_rules .= " $dependencies" - if $dependencies; - $result_rules .= "\n"; - # Only add actions if we found some. Otherwise - # we can end up with a spurious newline. See - # pr87.test. - $result_rules .= "$actions\n" - if $actions; + # Emit a conditional rule if necessary. + my @r = &conditional_target_rule($_); + if (scalar(@r) == 1) + { + my $cond = &make_condition(¬_condition(@r)); + $tmp_rules =~ s/\n$//; + $tmp_rules =~ s/\n/\n$cond/g; + $tmp_rules .= "\n\n"; + $output_rules .= $tmp_rules; + } } $comment = $separator = ''; last; @@ -7669,3 +7685,32 @@ exit 0; } + +# &conditional_target_rule ($TARGET) +# ---------------------------------- +# If TARGET is defined as a conditional target, return the rules that +# satisfy the condition as array, otherwise just return undef. +sub conditional_target_rule ($) +{ + my $target = shift; + my @conds; + foreach my $cond (keys %{$target_conditional{$target}}) + { + push(@conds, $cond) if ($target_conditional{$target}{$cond} == 1); + } + return(@conds); +} + +# ¬_condition (@CONDITIONS) +# --------------------------- +# Returns the logical inverse of each condition. +sub not_condition (@) +{ + return map + { + my $cond = $_; + $cond =~ s/_TRUE$/_FALSE/ unless ($cond =~ s/_FALSE/_TRUE/); + $cond; + } @_; +} + |