+2001-08-08 Richard Boulton <richard@tartarus.org>
+
+ * 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 <tromey@redhat.com>
* tests/Makefile.am (TESTS): Added dejagnu2.test.
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
{
}
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;
--- /dev/null
+#! /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
--- /dev/null
+#! /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