Index: ChangeLog =================================================================== RCS file: /cvs/automake/automake/ChangeLog,v retrieving revision 1.1514 diff -u -r1.1514 ChangeLog --- ChangeLog 2001/08/01 06:04:15 1.1514 +++ ChangeLog 2001/08/01 11:27:52 @@ -1,3 +1,14 @@ +2001-08-01 Richard Boulton + + * automake.in (file_contents_internal): if a rule is conditionally + defined, define the standard automake definition for it for those + conditions which are not conditionally defined. + (reverse_conditions): New function: reverse a list of conditionals. + + * tests/cond14.test: New file. + * tests/cond15.test: New file. + * tests/Makefile.am (TESTS): Added cond14.test and cond15.test. + 2001-07-31 Richard Boulton Raja R Harinath Index: automake.in =================================================================== RCS file: /cvs/automake/automake/automake.in,v retrieving revision 1.1165 diff -u -r1.1165 automake.in --- automake.in 2001/08/01 06:04:15 1.1165 +++ automake.in 2001/08/01 11:28:07 @@ -6002,6 +6002,28 @@ return @ret; } +# Reverse a list of conditionals +sub reverse_conditions +{ + my (@conds) = @_; + my %conds; + foreach my $cond (@conds) + { + $conds{$cond} = 1; + } + + my %notconds = (); + foreach my $cond (@conds) + { + foreach my $perm (variable_conditions_permutations (split(' ', $cond))) + { + $notconds{$perm} = 1 + if ! defined $conds{$perm}; + } + } + return sort keys %notconds; +} + # Return a list of permutations of a conditional string. sub variable_conditions_permutations { @@ -6930,14 +6952,38 @@ } else { - # Free lance dependency. Output the rule for all the + # Free-lance dependency. Output the rule for all the # targets instead of one by one. - if (!defined $targets{$targets} - && $cond ne 'FALSE') + + # Work out all the conditions for which the target hasn't + # been defined + my @undefined_conds; + if (defined $target_conditional{$targets}) + { + my @defined_conds = keys %{$target_conditional{$targets}}; + @undefined_conds = reverse_conditions(@defined_conds); + } + else + { + if (defined $targets{$targets}) + { + @undefined_conds = (); + } + else + { + @undefined_conds = (""); + } + } + + if ($cond ne 'FALSE') { - $paragraph =~ s/^/make_condition (@cond_stack)/gme; - $result_rules .= "$spacing$comment$paragraph\n" - if rule_define ($targets, $is_am, $cond, $file); + my $undefined_cond; + for $undefined_cond (@undefined_conds) { + my $condparagraph = $paragraph; + $condparagraph =~ s/^/make_condition (@cond_stack, $undefined_cond)/gme; + $result_rules .= "$spacing$comment$condparagraph\n" + if rule_define ($targets, $is_am, "$cond $undefined_cond", $file); + } } $comment = $spacing = ''; last; Index: tests/Makefile.am =================================================================== RCS file: /cvs/automake/automake/tests/Makefile.am,v retrieving revision 1.336 diff -u -r1.336 Makefile.am --- Makefile.am 2001/08/01 06:04:16 1.336 +++ Makefile.am 2001/08/01 11:28:08 @@ -67,6 +67,8 @@ cond11.test \ cond12.test \ cond13.test \ +cond14.test \ +cond15.test \ condincl.test \ condincl2.test \ condlib.test \ Index: tests/Makefile.in =================================================================== RCS file: /cvs/automake/automake/tests/Makefile.in,v retrieving revision 1.438 diff -u -r1.438 Makefile.in --- Makefile.in 2001/08/01 06:04:16 1.438 +++ Makefile.in 2001/08/01 11:28:08 @@ -135,6 +135,8 @@ cond11.test \ cond12.test \ cond13.test \ +cond14.test \ +cond15.test \ condincl.test \ condincl2.test \ condlib.test \ Index: tests/cond14.test =================================================================== RCS file: cond14.test diff -N cond14.test --- /dev/null Tue May 5 13:32:27 1998 +++ cond14.test Wed Aug 1 04:28:09 2001 @@ -0,0 +1,36 @@ +#! /bin/sh + +# Test for bug in conditionals. +# Report from Robert Boehne + +. $srcdir/defs || exit 1 + +cat >> configure.in << 'END' +AC_PROG_CC +AM_CONDITIONAL(COND1, true) +END + +cat > Makefile.am << 'END' + +if COND1 +BUILD_helldl = helldl +helldl_SOURCES = dlmain.c +helldl_DEPENDENCIES = libhello.la +else +BUILD_helldl = +bin_SCRIPTS = helldl +helldl$(EXEEXT): + rm -f $@ + echo '#! /bin/sh' > $@ + echo '-dlopen is unsupported' >> $@ + chmod +x $@ +endif + +bin_PROGRAMS = $(BUILD_helldl) +END + +$ACLOCAL || exit 1 +$AUTOMAKE || exit 1 + +num=`grep 'helldl$(EXEEXT):' Makefile.in | wc -l` +test $num -eq 2 Index: tests/cond15.test =================================================================== RCS file: cond15.test diff -N cond15.test --- /dev/null Tue May 5 13:32:27 1998 +++ cond15.test Wed Aug 1 04:28:09 2001 @@ -0,0 +1,45 @@ +#! /bin/sh + +# Regression test for conditionally defined overriding of automatic rules. + +. $srcdir/defs || exit 1 + +cat >> configure.in << 'END' +AC_PROG_CC +AM_CONDITIONAL(COND1, true) +AM_CONDITIONAL(COND2, true) +END + +cat > Makefile.am << 'END' + +if COND1 +if COND2 +bin_SCRIPTS = helldl +helldl$(EXEEXT): + rm -f $@ + echo '#! /bin/sh' > $@ + echo '-dlopen is unsupported' >> $@ + chmod +x $@ +endif +else +if COND2 +else +bin_SCRIPTS = helldl +helldl$(EXEEXT): + rm -f $@ + echo '#! /bin/sh' > $@ + echo '-dlopen is unsupported' >> $@ + chmod +x $@ +endif +endif + +bin_PROGRAMS = helldl +END + +$ACLOCAL || exit 1 +$AUTOMAKE || exit 1 + +num1=`grep 'helldl$(EXEEXT):' Makefile.in | wc -l` +num2=`grep '@COND1_FALSE@@address@hidden(EXEEXT):' Makefile.in | wc -l` +test $num1 -eq 4 || exit 1 +test $num2 -eq 1 || exit 1