diff -u -r automake/ChangeLog automake_patch1/ChangeLog --- automake/ChangeLog Sat Aug 4 14:25:19 2001 +++ automake_patch1/ChangeLog Sat Aug 4 14:34:16 2001 @@ -1,5 +1,16 @@ 2001-08-04 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-08-04 Richard Boulton + * tests/cond17.test: New file: test for being able to define an object to be generated in different ways according to a conditional. diff -u -r automake/automake.in automake_patch1/automake.in --- automake/automake.in Sat Aug 4 13:47:36 2001 +++ automake_patch1/automake.in Sat Aug 4 15:06:10 2001 @@ -6012,6 +6012,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 { @@ -6940,14 +6962,40 @@ } 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}) { - $paragraph =~ s/^/make_condition (@cond_stack)/gme; - $result_rules .= "$spacing$comment$paragraph\n" - if rule_define ($targets, $is_am, $cond, $file); + my @defined_conds = keys %{$target_conditional{$targets}}; + @undefined_conds = reverse_conditions(@defined_conds); + } + else + { + if (defined $targets{$targets}) + { + # No conditions for which target hasn't been defined + @undefined_conds = (); + } + else + { + # Target hasn't been defined for any conditions + @undefined_conds = (""); + } + } + + if ($cond ne 'FALSE') + { + 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; diff -u -r automake/tests/Makefile.am automake_patch1/tests/Makefile.am --- automake/tests/Makefile.am Sat Aug 4 14:15:20 2001 +++ automake_patch1/tests/Makefile.am Sat Aug 4 14:28:02 2001 @@ -67,6 +67,8 @@ cond11.test \ cond12.test \ cond13.test \ +cond14.test \ +cond15.test \ cond16.test \ cond17.test \ condincl.test \ diff -u -r automake/tests/Makefile.in automake_patch1/tests/Makefile.in --- automake/tests/Makefile.in Sat Aug 4 14:15:20 2001 +++ automake_patch1/tests/Makefile.in Sat Aug 4 14:28:02 2001 @@ -135,6 +135,8 @@ cond11.test \ cond12.test \ cond13.test \ +cond14.test \ +cond15.test \ cond16.test \ cond17.test \ condincl.test \ diff -u -r automake/tests/cond14.test automake_patch1/tests/cond14.test --- automake/tests/cond14.test Thu Jan 1 01:00:00 1970 +++ automake_patch1/tests/cond14.test Thu Aug 2 01:16:58 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 diff -u -r automake/tests/cond15.test automake_patch1/tests/cond15.test --- automake/tests/cond15.test Thu Jan 1 01:00:00 1970 +++ automake_patch1/tests/cond15.test Thu Aug 2 01:16:58 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