* lib/Automake/DisjConditions.pm (ambiguous_p): ... here.
* automake.in (rule_define): Adjust usage.
* lib/Automake/Variable.pm (_check_ambiguous_condition): Likewise.
2003-08-07 Alexandre Duret-Lutz <adl@gnu.org>
+ * lib/Automake/Variable.pm (condition_ambiguous_p): Move ...
+ * lib/Automake/DisjConditions.pm (ambiguous_p): ... here.
+ * automake.in (rule_define): Adjust usage.
+ * lib/Automake/Variable.pm (_check_ambiguous_condition): Likewise.
+
* lib/Automake/Options.pm: New file.
* lib/Automake/Makefile.am (dist_perllib_DATA): Add Options.pm.
* automake.in (FOREIGN, GNU, GNITS, $default_strictness)
# Check ambiguous conditional definitions.
my ($message, $ambig_cond) =
- condition_ambiguous_p ($target, $cond, target_conditions ($target));
+ target_conditions ($target)->ambiguous_p ($target, $cond);
if ($message) # We have an ambiguty.
{
if ($owner == TARGET_USER)
my $inv = $set->invert;
# Multiply two DisjConditions.
- my $prod = $set1->multiply ($set2)
+ my $prod = $set1->multiply ($set2);
# Return the subconditions of a DisjConditions with respect to
# a Condition. See the description for a real example.
- my $subconds = $set->sub_conditions ($cond)
+ my $subconds = $set->sub_conditions ($cond);
+
+ # Check whether a new definition in condition $cond would be
+ # ambiguous w.r.t. existing definitions in $set.
+ ($msg, $ambig_cond) = $set->ambiguous_p ($what, $cond);
=head1 DESCRIPTION
return new Automake::DisjConditions @res;
}
+=item C<($string, $ambig_cond) = $condset-E<gt>ambiguous_p ($what, $cond)>
+
+Check for an ambiguous condition. Return an error message and the
+other condition involved if we have an ambiguity. Return two empty
+strings otherwise.
+
+C<$what> is the name of the thing being defined, to use in the error
+message. C<$cond> is the C<Condition> under which it is being
+defined. C<$condset> is the C<DisjConditions> under which it had
+already been defined.
+
+=cut
+
+sub ambiguous_p ($$$)
+{
+ my ($condset, $var, $cond) = @_;
+
+ foreach my $vcond ($condset->conds)
+ {
+ # Note that these rules doesn't consider the following
+ # example as ambiguous.
+ #
+ # if COND1
+ # FOO = foo
+ # endif
+ # if COND2
+ # FOO = bar
+ # endif
+ #
+ # It's up to the user to not define COND1 and COND2
+ # simultaneously.
+ my $message;
+ if ($vcond eq $cond)
+ {
+ return ("$var multiply defined in condition " . $cond->human,
+ $vcond);
+ }
+ elsif ($vcond->true_when ($cond))
+ {
+ return ("$var was already defined in condition " . $vcond->human
+ . ", which implies condition ". $cond->human, $vcond);
+ }
+ elsif ($cond->true_when ($vcond))
+ {
+ return ("$var was already defined in condition "
+ . $vcond->human . ", which is implied by condition "
+ . $cond->human, $vcond);
+ }
+ }
+ return ('', '');
+}
+
=head1 SEE ALSO
L<Automake::Condition>.
var rvar vardef rvardef
variables
scan_variable_expansions check_variable_expansions
- condition_ambiguous_p
variable_delete
variables_dump
set_seen
{
my ($self, $cond, $where) = @_;
my $var = $self->name;
- my ($message, $ambig_cond) =
- condition_ambiguous_p ($var, $cond, $self->conditions);
+ my ($message, $ambig_cond) = $self->conditions->ambiguous_p ($var, $cond);
# We allow silent variables to be overridden silently.
my $def = $self->def ($cond);
}
-=item C<($string, $ambig_cond) = condition_ambiguous_p ($what, $cond, $condset)>
-
-Check for an ambiguous condition. Return an error message and
-the other condition involved if we have one, two empty strings otherwise.
-
-C<$what> is the name of the thing being defined, to use in the error
-message. C<$cond> is the C<Condition> under which it is being
-defined. C<$condset> is the C<DisjConditions> under which it had
-already been defined.
-
-=cut
-
-sub condition_ambiguous_p ($$$)
-{
- my ($var, $cond, $condset) = @_;
-
- foreach my $vcond ($condset->conds)
- {
- # Note that these rules doesn't consider the following
- # example as ambiguous.
- #
- # if COND1
- # FOO = foo
- # endif
- # if COND2
- # FOO = bar
- # endif
- #
- # It's up to the user to not define COND1 and COND2
- # simultaneously.
- my $message;
- if ($vcond eq $cond)
- {
- return ("$var multiply defined in condition " . $cond->human,
- $vcond);
- }
- elsif ($vcond->true_when ($cond))
- {
- return ("$var was already defined in condition " . $vcond->human
- . ", which implies condition ". $cond->human, $vcond);
- }
- elsif ($cond->true_when ($vcond))
- {
- return ("$var was already defined in condition "
- . $vcond->human . ", which is implied by condition "
- . $cond->human, $vcond);
- }
- }
- return ('', '');
-}
=item C<Automake::Variable::define($varname, $owner, $type, $cond, $value, $comment, $where, $pretty)>