From: Richard Boulton Date: Wed, 8 Aug 2001 16:44:05 +0000 (+0000) Subject: * automake.in (file_contents_internal): if a rule is conditionally X-Git-Tag: v1.10.2~1699 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b74c0b603526c17ce47f3beabe07fa82e52de66;p=platform%2Fupstream%2Fautomake.git * 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. (invert_conditions): New function: invert a list of conditionals. * tests/cond14.test: New file. * tests/cond15.test: New file. * tests/Makefile.am (TESTS): Added cond14.test and cond15.test. --- diff --git a/ChangeLog b/ChangeLog index 64049ae..76ae5ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2001-08-08 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. + (invert_conditions): New function: invert 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-05 Tom Tromey * tests/Makefile.am (TESTS): Added dejagnu2.test. diff --git a/automake.in b/automake.in index dde18f5..a49d9a7 100755 --- a/automake.in +++ b/automake.in @@ -5991,6 +5991,31 @@ sub variable_conditions_reduce return @ret; } +# @CONDS +# invert_conditions (@CONDS) +# -------------------------- +# Invert a list of conditionals. Returns a set of conditionals which +# are never true for any of the input conditionals, and when taken +# together with the input conditionals cover all possible cases. +# +# For example: invert_conditions("A_TRUE B_TRUE", "A_FALSE B_FALSE") will +# return ("A_FALSE B_TRUE", "A_TRUE B_FALSE") +sub invert_conditions +{ + my (@conds) = @_; + + my @notconds = (); + foreach my $cond (@conds) + { + foreach my $perm (variable_conditions_permutations (split(' ', $cond))) + { + push @notconds, $perm + if ! conditional_is_redundant ($perm, @conds); + } + } + return variable_conditions_reduce (@notconds); +} + # Return a list of permutations of a conditional string. sub variable_conditions_permutations { @@ -6919,14 +6944,42 @@ sub file_contents_internal ($$%) } 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 = invert_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 --git a/tests/Makefile.am b/tests/Makefile.am index 42234dd..174cf3a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -67,6 +67,8 @@ cond10.test \ cond11.test \ cond12.test \ cond13.test \ +cond14.test \ +cond15.test \ cond16.test \ cond17.test \ condincl.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 78d13b6..11c605d 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -135,6 +135,8 @@ cond10.test \ cond11.test \ cond12.test \ cond13.test \ +cond14.test \ +cond15.test \ cond16.test \ cond17.test \ condincl.test \ @@ -168,6 +170,7 @@ dash.test \ defun.test \ defun2.test \ dejagnu.test \ +dejagnu2.test \ depacl.test \ depacl2.test \ depcomp.test \ diff --git a/tests/cond14.test b/tests/cond14.test new file mode 100755 index 0000000..253874e --- /dev/null +++ b/tests/cond14.test @@ -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 --git a/tests/cond15.test b/tests/cond15.test new file mode 100755 index 0000000..abc764f --- /dev/null +++ b/tests/cond15.test @@ -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@@COND2_TRUE@helldl$(EXEEXT):' Makefile.in | wc -l` +test $num1 -eq 4 || exit 1 +test $num2 -eq 1 || exit 1