summaryrefslogtreecommitdiff
path: root/automake.in
diff options
context:
space:
mode:
authorRichard Boulton <richard@tartarus.org>2001-08-08 16:44:05 +0000
committerRichard Boulton <richard@tartarus.org>2001-08-08 16:44:05 +0000
commit2b74c0b603526c17ce47f3beabe07fa82e52de66 (patch)
treec6a57dee84b51b0bf5f9dd2944f635022d8e63a7 /automake.in
parent4658aae432f631fbf43fadd287b48a926573f908 (diff)
downloadautomake-2b74c0b603526c17ce47f3beabe07fa82e52de66.tar.gz
* 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.
Diffstat (limited to 'automake.in')
-rwxr-xr-xautomake.in65
1 files changed, 59 insertions, 6 deletions
diff --git a/automake.in b/automake.in
index dde18f5c1..a49d9a7a0 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;