From: Alexandre Duret-Lutz Date: Sun, 19 Jan 2003 23:01:03 +0000 (+0000) Subject: Rename more files to accomodate 8+3 file systems, and adjust the X-Git-Tag: Release-1-7-2b~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29af0999aee3c857a5f7602656e11ebd7cdee610;p=thirdparty%2Fautomake.git Rename more files to accomodate 8+3 file systems, and adjust the vocabulary at the same time: AM_CONDITIONAL defines "conditionals", and we call "condition" a conjunction of "conditionals". * lib/am/Conditional.pm: Rename to lib/am/Condition.pm. * lib/am/tests/Conditional.pl: Rename to lib/am/tests/Condition.pl. * lib/am/ConditionalSet.pm: Rename to lib/am/DisjConditions.pm. * lib/am/tests/ConditionalSet.pl: Rename to lib/am/tests/DisjConditions.pl * lib/am/Conditional.pm (condition_negate): Rename to ... * lib/am/Condition.pm (conditional_negate): ... this. * automake.in: Adjust references to Condition and DisjConditions. (check_ambiguous_conditional, conditional_ambiguous_p): Rename to ... (check_ambiguous_condition, condition_ambiguous_p): ... these. --- diff --git a/ChangeLog b/ChangeLog index 8548c4b7a..5b5e76650 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2003-01-19 Alexandre Duret-Lutz + Rename more files to accomodate 8+3 file systems, and adjust the + vocabulary at the same time: AM_CONDITIONAL defines "conditionals", + and we call "condition" a conjunction of "conditionals". + * lib/am/Conditional.pm: Rename to lib/am/Condition.pm. + * lib/am/tests/Conditional.pl: Rename to lib/am/tests/Condition.pl. + * lib/am/ConditionalSet.pm: Rename to lib/am/DisjConditions.pm. + * lib/am/tests/ConditionalSet.pl: Rename to + lib/am/tests/DisjConditions.pl + * lib/am/Conditional.pm (condition_negate): Rename to ... + * lib/am/Condition.pm (conditional_negate): ... this. + * automake.in: Adjust references to Condition and DisjConditions. + (check_ambiguous_conditional, conditional_ambiguous_p): Rename to ... + (check_ambiguous_condition, condition_ambiguous_p): ... these. + * tests/README: New file. * automake.texi (Conditional Programs): Show a sample Makefile.am. diff --git a/automake.in b/automake.in index 64f088b51..f5995965b 100755 --- a/automake.in +++ b/automake.in @@ -117,8 +117,8 @@ use Automake::XFile; use Automake::Channels; use Automake::ChannelDefs; use Automake::Location; -use Automake::Conditional qw/TRUE FALSE/; -use Automake::ConditionalSet; +use Automake::Condition qw/TRUE FALSE/; +use Automake::DisjConditions; use File::Basename; use Tie::RefHash; use Carp; @@ -546,7 +546,8 @@ my %target_owner; tie %target_owner, 'Tie::RefHash::Nestable'; use constant TARGET_AUTOMAKE => 0; # Target defined by Automake. use constant TARGET_USER => 1; # Target defined in the user's Makefile.am. -# This is the conditional stack. +# This is the conditional stack, updated on if/else/endif, and +# used to build Condition objects. my @cond_stack; # This holds the set of included files. @@ -700,7 +701,7 @@ my @substtos; # are the values of the variable for condition COND1 and COND2. my %subobjvar = (); -# This hash records helper variables used to implement '+=' in conditionals. +# This hash records helper variables used to implement conditional '+='. # Keys have the form "VAR:CONDITIONS". The value associated to a key is # the named of the helper variable used to append to VAR in CONDITIONS. my %appendvar = (); @@ -1860,7 +1861,7 @@ sub handle_languages # make can't handle backslashes for continuing comments on # the following line. define_pretty_variable ('DEP_FILES', - new Automake::Conditional ('AMDEP_TRUE'), + new Automake::Condition ('AMDEP_TRUE'), INTERNAL, @deplist); # Generate each `include' individually. Irix 6 make will @@ -2354,7 +2355,7 @@ sub handle_single_transform_list ($$$$@) my $dname = $derived; if (variable_defined ($derived . '_SHORTNAME')) { - # FIXME: should use the same conditional as + # FIXME: should use the same Condition as # the _SOURCES variable. But this is really # silly overkill -- nobody should have # conditional shortnames. @@ -2951,7 +2952,7 @@ sub handle_lib_objects_cond if ($xname ne '') { my $depvar = $xname . '_DEPENDENCIES'; - if ((conditional_ambiguous_p ($depvar, $cond, + if ((condition_ambiguous_p ($depvar, $cond, variable_conditions ($depvar)))[0] ne '') { # Note that we've examined this. @@ -4097,7 +4098,7 @@ sub handle_dist # relented. if (variable_defined ('EXTRA_DIST')) { - # FIXME: This should be fixed to work with conditionals. That + # FIXME: This should be fixed to work with conditions. That # will require only making the entries in %dist_dirs under the # appropriate condition. This is meaningful if the nature of # the distribution should depend upon the configure options @@ -5867,9 +5868,9 @@ sub pretty_print_rule ################################################################ -## ------------------------------ ## -## Handling the condition stack. ## -## ------------------------------ ## +## -------------------------------- ## +## Handling the conditional stack. ## +## -------------------------------- ## # $STRING @@ -5880,7 +5881,7 @@ sub make_conditional_string ($$) my ($negate, $cond) = @_; $cond = "${cond}_TRUE" unless $cond =~ /^TRUE|FALSE$/; - $cond = Automake::Conditional::condition_negate ($cond) + $cond = Automake::Condition::conditional_negate ($cond) if $negate; return $cond; } @@ -5898,7 +5899,7 @@ sub cond_stack_if ($$$) push (@cond_stack, make_conditional_string ($negate, $cond)); - return new Automake::Conditional (@cond_stack); + return new Automake::Condition (@cond_stack); } @@ -5916,7 +5917,7 @@ sub cond_stack_else ($$$) } $cond_stack[$#cond_stack] = - Automake::Conditional::condition_negate ($cond_stack[$#cond_stack]); + Automake::Condition::conditional_negate ($cond_stack[$#cond_stack]); # If $COND is given, check against it. if (defined $cond) @@ -5928,7 +5929,7 @@ sub cond_stack_else ($$$) if $cond_stack[$#cond_stack] ne $cond; } - return new Automake::Conditional (@cond_stack); + return new Automake::Condition (@cond_stack); } @@ -5958,7 +5959,7 @@ sub cond_stack_endif ($$$) pop @cond_stack; - return new Automake::Conditional (@cond_stack); + return new Automake::Condition (@cond_stack); } @@ -5970,17 +5971,17 @@ sub cond_stack_endif ($$$) ## ------------------------ ## -# check_ambiguous_conditional ($VAR, $COND, $WHERE) +# check_ambiguous_condition ($VAR, $COND, $WHERE) # ------------------------------------------------- # Check for an ambiguous conditional. This is called when a variable # is being defined conditionally. If we already know about a # definition that is true under the same conditions, then we have an # ambiguity. -sub check_ambiguous_conditional ($$$) +sub check_ambiguous_condition ($$$) { my ($var, $cond, $where) = @_; my ($message, $ambig_cond) = - conditional_ambiguous_p ($var, $cond, variable_conditions ($var)); + condition_ambiguous_p ($var, $cond, variable_conditions ($var)); if ($message) { msg 'syntax', $where, "$message ...", partial => 1; @@ -5990,14 +5991,14 @@ sub check_ambiguous_conditional ($$$) } # $STRING, $AMBIG_COND -# conditional_ambiguous_p ($WHAT, $COND, $CONDSET) +# condition_ambiguous_p ($WHAT, $COND, $CONDSET) # ---------------------------------------------- -# Check for an ambiguous conditional. Return an error message and +# Check for an ambiguous condition. Return an error message and # the other condition involved if we have one, two empty strings otherwise. # WHAT: the thing being defined -# COND: the Conditional under which it is being defined -# CONDSET: the ConditionalSet under which it had already been defined -sub conditional_ambiguous_p ($$$) +# COND: the Condition under which it is being defined +# CONDSET: the DisjConditions under which it had already been defined +sub condition_ambiguous_p ($$$) { my ($var, $cond, $condset) = @_; @@ -6062,7 +6063,7 @@ sub conditional_ambiguous_p ($$$) # C = mumble # # we should have (we display result as conditional strings in this -# illustration, but we really return ConditionalSet objects): +# illustration, but we really return DisjConditions objects): # variable_not_always_defined_in_cond ('A', 'COND1_TRUE COND2_TRUE') # => () # variable_not_always_defined_in_cond ('A', 'COND1_TRUE') @@ -6265,7 +6266,7 @@ sub macro_define ($$$$$$) # There must be no previous value unless the user is redefining # an Automake variable or an AC_SUBST variable for an existing # condition. - check_ambiguous_conditional ($var, $cond, $where) + check_ambiguous_condition ($var, $cond, $where) unless (exists $var_owner{$var}{$cond} && (($var_owner{$var}{$cond} == VAR_AUTOMAKE && $owner != VAR_AUTOMAKE) @@ -6486,7 +6487,8 @@ sub examine_variable # &variable_conditions_recursive ($VAR) # ------------------------------------- -# Return the set of conditions for which a variable is defined. +# Return the set of conditions (as a DisjConditions) +# for which a variable is defined. # If the variable is not defined conditionally, and is not defined in # terms of any variables which are defined conditionally, then this @@ -6512,7 +6514,7 @@ sub variable_conditions_recursive ($) # Now we want to return all permutations of the subvariable # conditions. - return (new Automake::ConditionalSet @new_conds)->permutations; + return (new Automake::DisjConditions @new_conds)->permutations; } @@ -6527,7 +6529,7 @@ sub variable_conditions ($) { my ($var) = @_; my @conds = keys %{$var_value{$var}}; - return new Automake::ConditionalSet @conds; + return new Automake::DisjConditions @conds; } @@ -6539,7 +6541,7 @@ sub target_conditions ($) { my ($target) = @_; my @conds = keys %{$targets{$target}}; - return new Automake::ConditionalSet @conds; + return new Automake::DisjConditions @conds; } # $BOOLEAN @@ -6659,7 +6661,7 @@ sub variable_conditions_recursive_sub } else { - push (@new_conds, Automake::Conditional::reduce (@subvar_conds)); + push (@new_conds, Automake::Condition::reduce (@subvar_conds)); } } @@ -6675,7 +6677,7 @@ sub variable_conditions_recursive_sub foreach my $this_cond (@this_conds) { my @perms = - (new Automake::ConditionalSet $this_cond)->permutations->conds; + (new Automake::DisjConditions $this_cond)->permutations->conds; foreach my $perm (@perms) { my $ok = 1; @@ -6829,7 +6831,6 @@ sub value_to_list ($$$$$) # "TRUE" condition will be returned. # $PARENT is the variable in which the variable is used: this is used # only for error messages. -# Returns the list of conditions. # For example, if A is defined as "foo $(B) bar", and B is defined as # "baz", this will return ("foo", "$(B)", "bar") sub variable_value_as_list @@ -6879,12 +6880,11 @@ sub variable_value_as_list # recursively follow $(...) and ${...} inclusions. It preserves @...@ # substitutions. If COND is 'all', then all values under all # conditions should be returned; if COND is a particular condition -# (all conditions are surrounded by @...@) then only the value for -# that condition should be returned; otherwise, warn if VAR is -# conditionally defined. If PARENT is specified, it is the name of -# the including variable; this is only used for error reports. -# If $LOC_WANTED is set, return a list of [$location, @values] instead -# of a list of @values. +# then only the value for that condition should be returned; +# otherwise, warn if VAR is conditionally defined. If PARENT is +# specified, it is the name of the including variable; this is only +# used for error reports. If $LOC_WANTED is set, return a list of +# [$location, @values] instead of a list of @values. sub variable_value_as_list_recursive_worker ($$$$) { my ($var, $cond, $parent, $loc_wanted) = @_; @@ -7037,7 +7037,7 @@ sub variable_loc_and_value_as_list_recursive ($$;$) # &define_pretty_variable ($VAR, $COND, $WHERE, @VALUE) # ----------------------------------------------------- # Like define_variable, but the value is a list, and the variable may -# be defined conditionally. The second argument is the conditional +# be defined conditionally. The second argument is the Condition # under which the value should be defined; this should be the empty # string to define the variable unconditionally. The third argument # is a list holding the values to use for the variable. The value is @@ -7201,9 +7201,9 @@ sub register_suffix_rule ($$$) # Define a new rule. $TARGET is the rule name. $SOURCE # is the filename the rule comes from. $OWNER is the # owner of the rule (TARGET_AUTOMAKE or TARGET_USER). -# $COND is the condition string under which the rule is defined. -# $WHERE is the location where the rule is defined. -# Returns a (possibly empty) list of conditions where the rule +# $COND is the Condition under which the rule is defined. +# $WHERE is the Location where the rule is defined. +# Returns a (possibly empty) list of Conditions where the rule # should be defined. sub rule_define ($$$$$) { @@ -7290,7 +7290,7 @@ sub rule_define ($$$$$) # "... `$target' previously defined here"); } # Return so we don't redefine the rule in our tables, - # don't check for ambiguous conditional, etc. The rule + # don't check for ambiguous condition, etc. The rule # will be output anyway beauce &read_am_file ignore the # return code. return (); @@ -7340,7 +7340,7 @@ sub rule_define ($$$$$) # Check ambiguous conditional definitions. my ($message, $ambig_cond) = - conditional_ambiguous_p ($target, $cond, target_conditions ($target)); + condition_ambiguous_p ($target, $cond, target_conditions ($target)); if ($message) # We have an ambiguty. { if ($owner == TARGET_USER) @@ -7354,7 +7354,7 @@ sub rule_define ($$$$$) else { # FIXME: for Automake rules, we can't diagnose ambiguities yet. - # The point is that Automake doesn't propagate conditionals + # The point is that Automake doesn't propagate conditions # everywhere. For instance &handle_PROGRAMS doesn't care if # bin_PROGRAMS was defined conditionally or not. # On the following input @@ -7368,7 +7368,7 @@ sub rule_define ($$$$$) # in condition TRUE (which conflicts with COND1). Fixing # this in &handle_PROGRAMS and siblings seems hard: you'd # have to explain &file_contents what to do with a - # conditional. So for now we do our best *here*. If `foo:' + # condition. So for now we do our best *here*. If `foo:' # was already defined in condition COND1 and we want to define # it in condition TRUE, then define it only in condition !COND1. # (See cond14.test and cond15.test for some test cases.) @@ -7522,7 +7522,7 @@ sub read_am_file ($$) # sure it is the same on exit. This lets us conditonally include # other files. my @saved_cond_stack = @cond_stack; - my $cond = new Automake::Conditional (@cond_stack); + my $cond = new Automake::Condition (@cond_stack); my $last_var_name = ''; my $last_var_type = ''; @@ -7568,7 +7568,7 @@ sub read_am_file ($$) { if ($prev_state == IN_RULE_DEF) { - my $cond = new Automake::Conditional @cond_stack; + my $cond = new Automake::Condition @cond_stack; $output_trailer .= $cond->subst_string; $output_trailer .= $_; } @@ -7629,7 +7629,7 @@ sub read_am_file ($$) check_variable_expansions ($_, $where); $output_trailer .= $comment . $spacing; - my $cond = new Automake::Conditional @cond_stack; + my $cond = new Automake::Condition @cond_stack; $output_trailer .= $cond->subst_string; $output_trailer .= $_; $comment = $spacing = ''; @@ -7702,7 +7702,7 @@ sub read_am_file ($$) $prev_state = IN_RULE_DEF; check_variable_expansions ($_, $where); $output_trailer .= $comment . $spacing; - my $cond = new Automake::Conditional @cond_stack; + my $cond = new Automake::Condition @cond_stack; $output_trailer .= $cond->subst_string; $output_trailer .= $_; $comment = $spacing = ''; @@ -7931,7 +7931,7 @@ sub file_contents_internal ($$$%) # sure it is the same on exit. This lets us conditonally include # other files. my @saved_cond_stack = @cond_stack; - my $cond = new Automake::Conditional (@cond_stack); + my $cond = new Automake::Condition (@cond_stack); foreach (make_paragraphs ($file, %transform)) { @@ -8019,7 +8019,7 @@ sub file_contents_internal ($$$%) # in %dependencies and $targets will have two rules). # FIXME: 2. The logic here is not able to output a - # multi-paragraph rule several time (e.g. for each conditional + # multi-paragraph rule several time (e.g. for each condition # it is defined for) because it only knows the first paragraph. # FIXME: 3. We are not robust to people defining a subset diff --git a/lib/Automake/Conditional.pm b/lib/Automake/Condition.pm similarity index 72% rename from lib/Automake/Conditional.pm rename to lib/Automake/Condition.pm index df36938f2..b2a561bbc 100644 --- a/lib/Automake/Conditional.pm +++ b/lib/Automake/Condition.pm @@ -1,4 +1,4 @@ -# Copyright (C) 1997, 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 1997, 2001, 2002, 2003 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. -package Automake::Conditional; +package Automake::Condition; use strict; use Carp; @@ -26,22 +26,22 @@ use vars '@ISA', '@EXPORT_OK'; =head1 NAME -Automake::Conditional - record a conjunction of conditions +Automake::Condition - record a conjunction of conditionals =head1 SYNOPSIS - use Automake::Conditional; + use Automake::Condition; - # Create a conditional to represent "COND1 and not COND2". - my $cond = new Automake::Conditional "COND1_TRUE", "COND2_FALSE"; - # Create a conditional to represent "not COND3". - my $other = new Automake::Conditional "COND3_FALSE"; + # Create a condition to represent "COND1 and not COND2". + my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE"; + # Create a condition to represent "not COND3". + my $other = new Automake::Condition "COND3_FALSE"; - # Create a conditional to represent + # Create a condition to represent # "COND1 and not COND2 and not COND3". my $both = $cond->merge ($other); - # Likewise, but using a list of atomic conditional strings + # Likewise, but using a list of conditional strings my $both2 = $cond->merge_conds ("COND3_FALSE"); # Strip from $both any subconditions which are in $other. @@ -57,15 +57,15 @@ Automake::Conditional - record a conjunction of conditions # Is $cond always false? (Not in this example) if ($cond->false) { ... } - # Return the list of conditions as a string: + # Return the list of conditionals as a string: # "COND1_TRUE COND2_FALSE" my $str = $cond->string; - # Return the list of conditions as a human readable string: + # Return the list of conditionals as a human readable string: # "COND1 and !COND2" my $str = $cond->human; - # Return the list of conditions as a AC_SUBST-style string: + # Return the list of conditionals as a AC_SUBST-style string: # "@COND1_TRUE@@COND2_FALSE@" my $subst = $cond->subst_string; @@ -80,19 +80,20 @@ Automake::Conditional - record a conjunction of conditions # (Not in this example) if ($cond->implies_any ($other, $both)) { ... } - # Remove superfluous conditions. + # Remove superfluous conditionals. # (Returns @cons = ($both) in this example, because # $other and $cond are implied by $both.) - @conds = Automake::Conditional::reduce ($other, $both, $cond); + @conds = Automake::Condition::reduce ($other, $both, $cond); - # Invert a Conditional. This returns a list of Conditionals. + # Invert a Condition. This returns a list of Conditions. @conds = $both->not; =head1 DESCRIPTION -A C is a conjunction of atomic conditions. In Automake they -are used to represent the conditions into which Makefile variables and -Makefile rules are defined. +A C is a conjunction of conditionals (i.e., atomic conditions +defined in F by C. In Automake they +are used to represent the conditions into which F variables and +F rules are defined. If the variable C is defined as @@ -102,67 +103,67 @@ If the variable C is defined as endif endif -then it will be associated a C created with +then it will be associated a C created with the following statement. - new Automake::Conditional "COND1_TRUE", "COND2_TRUE"; + new Automake::Condition "COND1_TRUE", "COND2_TRUE"; -Remember that a C is a I of conditions, so -the above C means C is defined when C is true +Remember that a C is a I of conditionals, so +the above C means C is defined when C B C are true. There is no way to express disjunctions -(i.e., Is) with this class (see L). +(i.e., Is) with this class (but see L). -Another point worth to mention is that each C object is -unique with respect to its conditions. Two C objects -created for the same set of conditions will have the same adress. -This makes it easy to compare Cs, just compare the +Another point worth to mention is that each C object is +unique with respect to its conditionals. Two C objects +created for the same set of conditionals will have the same adress. +This makes it easy to compare Cs, just compare the references. - my $c1 = new Automake::Conditional "COND1_TRUE", "COND2_TRUE"; - my $c2 = new Automake::Conditional "COND1_TRUE", "COND2_TRUE"; + my $c1 = new Automake::Condition "COND1_TRUE", "COND2_TRUE"; + my $c2 = new Automake::Condition "COND1_TRUE", "COND2_TRUE"; $c1 == $c2; # True! =head2 Methods =over 4 -=item C<$cond = new Automake::Conditional [@conds]> +=item C<$cond = new Automake::Condition [@conds]> -Return a C objects for the conjunctions of conditions +Return a C objects for the conjunctions of conditionals listed in C<@conds> as strings. An item in C<@conds> should be either C<"FALSE">, C<"TRUE">, or have the form C<"NAME_FALSE"> or C<"NAME_TRUE"> where C can be anything (in practice C should be the name of a conditional declared in F with C, but it's not -C's responsability to ensure this). +C's responsability to ensure this). An empty C<@conds> means C<"TRUE">. As explained previously, the reference (object) returned is unique with respect to C<@conds>. For this purpose, duplicate elements are ignored, and C<@conds> is rewriten as C<("FALSE")> if it contains -C<"FALSE"> or two contradictory conditions (such as C<"NAME_FALSE"> +C<"FALSE"> or two contradictory conditionals (such as C<"NAME_FALSE"> and C<"NAME_TRUE">.) Therefore the following two statements create the same object (they -both create the C<"FALSE"> conditional). +both create the C<"FALSE"> condition). - my $c3 = new Automake::Conditional "COND1_TRUE", "COND1_FALSE"; - my $c4 = new Automake::Conditional "COND2_TRUE", "FALSE"; + my $c3 = new Automake::Condition "COND1_TRUE", "COND1_FALSE"; + my $c4 = new Automake::Condition "COND2_TRUE", "FALSE"; $c3 == $c4; # True! $c3 == FALSE; # True! =cut -# Keys in this hash are conditionnal strings. Values are the +# Keys in this hash are conditional strings. Values are the # associated object conditions. This is used by `new' to reuse -# Conditional objects with identical conditions. -use vars '%_conditional_singletons'; +# Condition objects with identical conditionals. +use vars '%_condition_singletons'; # Do NOT reset this hash here. It's already empty by default, -# and any reset would otherwise occur AFTER the `TRUE' and `FALSE' +# and any setting would otherwise occur AFTER the `TRUE' and `FALSE' # constants definitions. -# %_conditional_singletons = (); +# %_condition_singletons = (); sub new ($;@) { @@ -180,10 +181,10 @@ sub new ($;@) next if $cond eq 'TRUE'; # Catch some common programming errors: - # - A conditional passed to new + # - A Condition passed to new confess "`$cond' is a reference, expected a string" if ref $cond; - # - A conditional passed as a string to new - confess "`$cond' doesn't look like a condition" if $cond =~ /::/; + # - A Condition passed as a string to new + confess "`$cond' does not look like a condition" if $cond =~ /::/; # Detect cases when @conds can be simplified to FALSE. if (($cond eq 'FALSE' && $#conds > 0) @@ -197,11 +198,11 @@ sub new ($;@) } my $key = $self->string; - if (exists $_conditional_singletons{$key}) + if (exists $_condition_singletons{$key}) { - return $_conditional_singletons{$key}; + return $_condition_singletons{$key}; } - $_conditional_singletons{$key} = $self; + $_condition_singletons{$key} = $self; return $self; } @@ -215,13 +216,13 @@ C<$cond> and C<$othercond>. sub merge ($$) { my ($self, $other) = @_; - new Automake::Conditional $self->conds, $other->conds; + new Automake::Condition $self->conds, $other->conds; } =item C<$newcond = $cond-Emerge_conds (@conds)> Return a new condition which is the conjunction of C<$cond> and -C<@conds>, where C<@conds> is a list of atomic condition strings, as +C<@conds>, where C<@conds> is a list of conditional strings, as passed to C. =cut @@ -229,12 +230,12 @@ passed to C. sub merge_conds ($@) { my ($self, @conds) = @_; - new Automake::Conditional $self->conds, @conds; + new Automake::Condition $self->conds, @conds; } =item C<$newcond = $cond-Estrip ($minuscond)> -Return a new condition which has all the subconditions of C<$cond> +Return a new condition which has all the conditionals of C<$cond> except those of C<$minuscond>. This is the opposite of C. =cut @@ -247,12 +248,12 @@ sub strip ($$) { push @res, $cond unless $minus->has ($cond); } - return new Automake::Conditional @res; + return new Automake::Condition @res; } =item C<@list = $cond-Econds> -Return the set of conditions defining C<$cond>, as strings. Note that +Return the set of conditionals defining C<$cond>, as strings. Note that this might not be exactly the list passed to C (or a concatenation of such lists if C was used), because of the cleanup mentioned in C's description. @@ -302,7 +303,7 @@ sub true ($ ) =item C<$cond-Estring> -Build a string which denotes the conditional. +Build a string which denotes the condition. For instance using the C<$cond> definition from L, C<$cond-Estring> will return C<"COND1_TRUE COND2_FALSE">. @@ -330,7 +331,7 @@ sub string ($ ) =item C<$cond-Ehuman> -Build a human readable string which denotes the conditional. +Build a human readable string which denotes the condition. For instance using the C<$cond> definition from L, C<$cond-Estring> will return C<"COND1 and !COND2">. @@ -466,9 +467,9 @@ sub implies_any ($@) =item C<$cond-Enot> -Return a negation of @<$cond> as a list of Cs. -This list should be used to construct a C -(we cannot return a C from C, +Return a negation of @<$cond> as a list of Cs. +This list should be used to construct a C +(we cannot return a C from C, because that would make these two packages interdependent). =cut @@ -480,7 +481,7 @@ sub not ($ ) my @res; for my $cond ($self->conds) { - push @res, new Automake::Conditional &condition_negate ($cond); + push @res, new Automake::Condition &conditional_negate ($cond); } $self->{'not'} = [@res]; return @res; @@ -500,12 +501,12 @@ The C<"FALSE"> conditional. =cut -use constant TRUE => new Automake::Conditional "TRUE"; -use constant FALSE => new Automake::Conditional "FALSE"; +use constant TRUE => new Automake::Condition "TRUE"; +use constant FALSE => new Automake::Condition "FALSE"; =item C -Filter a list of conditionals so that only the exclusive ones are +Filter a list of conditions so that only the exclusive ones are retained. For example, if both C and C are in the list, discard the latter. If the input list is empty, return C<(TRUE)>. @@ -535,13 +536,13 @@ sub reduce (@) return @ret; } -=item C +=item C -Negate a condition string. +Negate a conditional string. =cut -sub condition_negate ($) +sub conditional_negate ($) { my ($cond) = @_; @@ -554,16 +555,15 @@ sub condition_negate ($) =head1 SEE ALSO -L. +L. =head1 HISTORY Cs and supporting code were added to Automake 1.1o by Ian Lance Taylor in 1997. Since then it has been improved by Tom Tromey , Richard Boulton -, Raja R Harinath , and -Akim Demaille . Alexandre Duret-Lutz -extracted the code out of Automake to create this package in 2002. +, Raja R Harinath , +Akim Demaille , and Alexandre Duret-Lutz . =cut diff --git a/lib/Automake/ConditionalSet.pm b/lib/Automake/DisjConditions.pm similarity index 65% rename from lib/Automake/ConditionalSet.pm rename to lib/Automake/DisjConditions.pm index b9fdb487d..305dbc9ed 100644 --- a/lib/Automake/ConditionalSet.pm +++ b/lib/Automake/DisjConditions.pm @@ -1,31 +1,48 @@ -package Automake::ConditionalSet; +# Copyright (C) 1997, 2001, 2002, 2003 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +package Automake::DisjConditions; use Carp; use strict; -use Automake::Conditional qw/TRUE FALSE/; +use Automake::Condition qw/TRUE FALSE/; =head1 NAME -Automake::ConditionalSet - record a disjunction of conditions +Automake::DisjConditions - record a disjunction of Conditions =head1 SYNOPSIS - use Automake::Conditional; - use Automake::ConditionalSet; + use Automake::Condition; + use Automake::DisjConditions; - # Create a conditional to represent "COND1 and not COND2". - my $cond = new Automake::Conditional "COND1_TRUE", "COND2_FALSE"; - # Create a conditional to represent "not COND3". - my $other = new Automake::Conditional "COND3_FALSE"; + # Create a Condition to represent "COND1 and not COND2". + my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE"; + # Create a Condition to represent "not COND3". + my $other = new Automake::Condition "COND3_FALSE"; - # Create a ConditionalSet to represent + # Create a DisjConditions to represent # "(COND1 and not COND2) or (not COND3)" - my $set = new Automake::ConditionalSet $cond, $other; + my $set = new Automake::DisjConditions $cond, $other; - # Return the list of Conditionals involved in $set. + # Return the list of Conditions involved in $set. my @conds = $set->conds; - # Return one of the Conditional involved in $set. + # Return one of the Condition involved in $set. my $cond = $set->one_cond; # Return true iff $set is always true (i.e. its subconditions @@ -36,33 +53,33 @@ Automake::ConditionalSet - record a disjunction of conditions # only false conditions). if ($set->false) { ... } - # Return a string representing the ConditionalSet. + # Return a string representing the DisjConditions. # "COND1_TRUE COND2_FALSE | COND3_FALSE" my $str = $set->string; - # Return a human readable string representing the ConditionalSet. + # Return a human readable string representing the DisjConditions. # "(COND1 and !COND2) or (!COND3)" my $str = $set->human; - # Build a new ConditionalSet from the permuation of all - # subconditions appearing in $set. + # Build a new DisjConditions from the permuation of all + # Conditions appearing in $set. my $perm = $set->permutations; - # Invert a ConditionalSet, i.e., create a new ConditionalSet + # Invert a DisjConditions, i.e., create a new DisjConditions # that complements $set. my $inv = $set->invert; - # Multiply two ConditionalSets. + # Multiply two DisjConditions. my $prod = $set1->multiply ($set2) - # Return the subconditions of a ConditionalSet with respect to - # a Conditional. See the description for a real example. + # Return the subconditions of a DisjConditions with respect to + # a Condition. See the description for a real example. my $subconds = $set->sub_conditions ($cond) =head1 DESCRIPTION -A C is a disjunction of atomic conditions. In -Automake they are used to represent the conditions into which Makefile +A C is a disjunction of Cs. In Automake +they are used to represent the conditions into which Makefile variables and Makefile rules are defined. If the variable C is defined as @@ -78,35 +95,37 @@ If the variable C is defined as endif endif -then it will be associated a C created with +then it will be associated a C created with the following statement. - new Automake::ConditionalSet - (new Automake::Conditional ("COND1_TRUE", "COND2_TRUE"), - new Automake::Conditional ("COND3_FALSE", "COND4_TRUE")); + new Automake::DisjConditions + (new Automake::Condition ("COND1_TRUE", "COND2_TRUE"), + new Automake::Condition ("COND3_FALSE", "COND4_TRUE")); -As you can see, a C is made from a list of -Cs. Since C is a disjunction, and -C is a conjunction, the above can be read as +As you can see, a C is made from a list of +Cs. Since C is a disjunction, and +C is a conjunction, the above can be read as follows. (COND1 and COND2) or ((not COND3) and COND4) -Like C objects, a C object is unisque -with respect to its conditions. Two C objects created +That's indeed the condition into which C has a value. + +Like C objects, a C object is unique +with respect to its conditions. Two C objects created for the same set of conditions will have the same adress. This makes -it easy to compare Cs: just compare the references. +it easy to compare Cs: just compare the references. =head2 Methods =over 4 -=item C<$set = new Automake::ConditionalSet [@conds]> +=item C<$set = new Automake::DisjConditions [@conds]> -Create a C object from the list of C +Create a C object from the list of C objects passed in arguments. -If the C<@conds> list is empty, the C is assumed to be +If the C<@conds> list is empty, the C is assumed to be false. As explained previously, the reference (object) returned is unique @@ -115,10 +134,10 @@ ignored. =cut -# Keys in this hash are ConditionalSet strings. Values are the -# associated object ConditionalSet. This is used by `new' to reuse -# ConditionalSet objects with identical conditions. -use vars '%_conditional_set_singletons'; +# Keys in this hash are DisjConditions strings. Values are the +# associated object DisjConditions. This is used by `new' to reuse +# DisjConditions objects with identical conditions. +use vars '%_disjcondition_singletons'; sub new ($;@) { @@ -131,12 +150,12 @@ sub new ($;@) for my $cond (@conds) { confess "`$cond' isn't a reference" unless ref $cond; - confess "`$cond' isn't an Automake::Conditional" - unless $cond->isa ("Automake::Conditional"); + confess "`$cond' isn't an Automake::Condition" + unless $cond->isa ("Automake::Condition"); # This is a disjunction of conditions, so we drop # false conditions. We'll always treat an "empty" - # ConditionalSet as false for this reason. + # DisjConditions as false for this reason. next if $cond->false; # Store conditions as keys AND as values, because blessed @@ -147,17 +166,17 @@ sub new ($;@) } my $key = $self->string; - if (exists $_conditional_set_singletons{$key}) + if (exists $_disjcondition_singletons{$key}) { - return $_conditional_set_singletons{$key}; + return $_disjcondition_singletons{$key}; } - $_conditional_set_singletons{$key} = $self; + $_disjcondition_singletons{$key} = $self; return $self; } =item C<@conds = $set-Econds> -Return the list of C objects involved in C<$set>. +Return the list of C objects involved in C<$set>. =cut @@ -173,7 +192,7 @@ sub conds ($ ) =item C<$cond = $set-Eone_cond> -Return one C object involved in C<$set>. +Return one C object involved in C<$set>. =cut @@ -185,8 +204,8 @@ sub one_cond ($) =item C<$et = $set-Efalse> -Return 1 iff the C object is always false (i.e., if it -is empty, or if it contains only false Cs). Return 0 +Return 1 iff the C object is always false (i.e., if it +is empty, or if it contains only false Cs). Return 0 otherwise. =cut @@ -199,7 +218,7 @@ sub false ($ ) =item C<$et = $set-Etrue> -Return 1 iff the C object is always true (i.e. covers all +Return 1 iff the C object is always true (i.e. covers all conditions). Return 0 otherwise. =cut @@ -216,7 +235,7 @@ sub true ($ ) =item C<$str = $set-Estring> -Build a string which denotes the C. +Build a string which denotes the C. =cut @@ -242,7 +261,7 @@ sub string ($ ) =item C<$cond-Ehuman> -Build a human readable string which denotes the C. +Build a human readable string which denotes the C. =cut @@ -295,8 +314,8 @@ sub _permutations_worker (@) } if (! @ret) { - push (@ret, new Automake::Conditional $cond); - push (@ret, new Automake::Conditional $neg); + push (@ret, new Automake::Condition $cond); + push (@ret, new Automake::Condition $neg); } return @ret; @@ -304,25 +323,25 @@ sub _permutations_worker (@) =item C<$perm = $set-Epermutations> -Return a permutations of the subconditions involved in a C. +Return a permutations of the conditions involved in a C. -For instance consider this initial C. +For instance consider this initial C. - my $set = new Automake::ConditionalSet - (new Automake::Conditional ("COND1_TRUE", "COND2_TRUE"), - new Automake::Conditional ("COND3_FALSE", "COND2_TRUE")); + my $set = new Automake::DisjConditions + (new Automake::Condition ("COND1_TRUE", "COND2_TRUE"), + new Automake::Condition ("COND3_FALSE", "COND2_TRUE")); -Calling C<$set-Epermutations> will return the following Conditional set. +Calling C<$set-Epermutations> will return the following DisjConditions. - new Automake::ConditionalSet - (new Automake::Conditional ("COND1_TRUE", "COND2_TRUE", "COND3_TRUE"), - new Automake::Conditional ("COND1_FALSE","COND2_TRUE", "COND3_TRUE"), - new Automake::Conditional ("COND1_TRUE", "COND2_FALSE","COND3_TRUE"), - new Automake::Conditional ("COND1_FALSE","COND2_FALSE","COND3_TRUE"), - new Automake::Conditional ("COND1_TRUE", "COND2_TRUE", "COND3_FALSE"), - new Automake::Conditional ("COND1_FALSE","COND2_TRUE", "COND3_FALSE"), - new Automake::Conditional ("COND1_TRUE", "COND2_FALSE","COND3_FALSE"), - new Automake::Conditional ("COND1_FALSE","COND2_FALSE","COND3_FALSE")); + new Automake::DisjConditions + (new Automake::Condition ("COND1_TRUE", "COND2_TRUE", "COND3_TRUE"), + new Automake::Condition ("COND1_FALSE","COND2_TRUE", "COND3_TRUE"), + new Automake::Condition ("COND1_TRUE", "COND2_FALSE","COND3_TRUE"), + new Automake::Condition ("COND1_FALSE","COND2_FALSE","COND3_TRUE"), + new Automake::Condition ("COND1_TRUE", "COND2_TRUE", "COND3_FALSE"), + new Automake::Condition ("COND1_FALSE","COND2_TRUE", "COND3_FALSE"), + new Automake::Condition ("COND1_TRUE", "COND2_FALSE","COND3_FALSE"), + new Automake::Condition ("COND1_FALSE","COND2_FALSE","COND3_FALSE")); =cut @@ -347,7 +366,7 @@ sub permutations ($ ) # An empty permutation is TRUE, because we ignore TRUE conditions # in the recursions. @res = (TRUE) unless @res; - my $res = new Automake::ConditionalSet @res; + my $res = new Automake::DisjConditions @res; $self->{'permutations'} = $res; @@ -358,26 +377,26 @@ sub permutations ($ ) Multiply two conditional sets. - my $set1 = new Automake::ConditionalSet - (new Automake::Conditional ("A_TRUE"), - new Automake::Conditional ("B_TRUE")); - my $set2 = new Automake::ConditionalSet - (new Automake::Conditional ("C_FALSE"), - new Automake::Conditional ("D_FALSE")); + my $set1 = new Automake::DisjConditions + (new Automake::Condition ("A_TRUE"), + new Automake::Condition ("B_TRUE")); + my $set2 = new Automake::DisjConditions + (new Automake::Condition ("C_FALSE"), + new Automake::Condition ("D_FALSE")); C<$set1-Emultiply ($set2)> will return - new Automake::ConditionalSet - (new Automake::Conditional ("A_TRUE", "C_FALSE"), - new Automake::Conditional ("B_TRUE", "C_FALSE"),; - new Automake::Conditional ("A_TRUE", "D_FALSE"), - new Automake::Conditional ("B_TRUE", "D_FALSE")); + new Automake::DisjConditions + (new Automake::Condition ("A_TRUE", "C_FALSE"), + new Automake::Condition ("B_TRUE", "C_FALSE"),; + new Automake::Condition ("A_TRUE", "D_FALSE"), + new Automake::Condition ("B_TRUE", "D_FALSE")); -The argument can also be a C. +The argument can also be a C. =cut -# Same as multiply() but take a list of Conditonal as second argument. +# Same as multiply() but take a list of Conditonals as second argument. # We use this in invert(). sub _multiply ($@) { @@ -390,30 +409,30 @@ sub _multiply ($@) push @res, $selfcond->merge ($setcond); } } - return new Automake::ConditionalSet @res; + return new Automake::DisjConditions @res; } sub multiply ($$) { my ($self, $set) = @_; - return $self->_multiply ($set) if $set->isa('Automake::Conditional'); + return $self->_multiply ($set) if $set->isa('Automake::Condition'); return $self->_multiply ($set->conds); } =item C<$inv = $set-Einvert> -Invert a C. Return a C which is true +Invert a C. Return a C which is true when C<$set> is false, and vice-versa. - my $set = new Automake::ConditionalSet - (new Automake::Conditional ("A_TRUE", "B_TRUE"), - new Automake::Conditional ("A_FALSE", "B_FALSE")); + my $set = new Automake::DisjConditions + (new Automake::Condition ("A_TRUE", "B_TRUE"), + new Automake::Condition ("A_FALSE", "B_FALSE")); -Calling C<$set-Einvert> will return the following C. +Calling C<$set-Einvert> will return the following C. - new Automake::ConditionalSet - (new Automake::Conditional ("A_TRUE", "B_FALSE"), - new Automake::Conditional ("A_FALSE", "B_TRUE")); + new Automake::DisjConditions + (new Automake::Condition ("A_TRUE", "B_FALSE"), + new Automake::Condition ("A_FALSE", "B_TRUE")); =cut @@ -423,8 +442,8 @@ sub invert($ ) return $self->{'invert'} if defined $self->{'invert'}; - # The invert of an empty ConditionalSet is TRUE. - my $res = new Automake::ConditionalSet TRUE; + # The invert of an empty DisjConditions is TRUE. + my $res = new Automake::DisjConditions TRUE; # !((a.b)+(c.d)+(e.f)) # = (!a+!b).(!c+!d).(!e+!f) @@ -449,7 +468,7 @@ sub invert($ ) =item C<$simp = $set->simplify> -Find prime implicants and return a simplified C. +Find prime implicants and return a simplified C. =cut @@ -457,10 +476,10 @@ sub _simplify ($) # Based on Quine-McCluskey's algorithm. { my ($self) = @_; - # If we know this ConditionalSet is always true, we have nothing to do. + # If we know this DisjConditions is always true, we have nothing to do. # Use the cached value if true if available. Never call true() # as this would call invert() which can be slow. - return new Automake::ConditionalSet TRUE + return new Automake::DisjConditions TRUE if $self->{'hash'}{&TRUE} || $self->{'true'}; my $nvars = 0; @@ -491,7 +510,7 @@ sub _simplify ($) # Based on Quine-McCluskey's algorithm. my @conds = $and_conds->conds; for my $cond (@conds) { - # Which variable is this condition about? + # Which variable is this conditional about? confess "can't parse `$cond'" unless $cond =~ /^(.*_)(FALSE|TRUE)$/; @@ -587,11 +606,11 @@ sub _simplify ($) # Based on Quine-McCluskey's algorithm. } } - # Finally merge bit strings back into a Automake::ConditionalSet. + # Finally merge bit strings back into a Automake::DisjConditions. # If level 0 has been filled, we've found `TRUE'. No need to translate # anything. - return new Automake::ConditionalSet TRUE if $#{$subcubes[0]} >= 0; + return new Automake::DisjConditions TRUE if $#{$subcubes[0]} >= 0; # Otherwise, translate uncombined terms in other levels. @@ -676,11 +695,11 @@ sub _simplify ($) # Based on Quine-McCluskey's algorithm. ++$rank; } - push @or_conds, new Automake::Conditional @and_conds if @and_conds; + push @or_conds, new Automake::Condition @and_conds if @and_conds; } } - return new Automake::ConditionalSet @or_conds; + return new Automake::DisjConditions @or_conds; } sub simplify ($) @@ -699,20 +718,20 @@ C<$cond> stripped. For instance, consider: - my $a = new Automake::ConditionalSet - (new Automake::Conditional ("A_TRUE", "B_TRUE"), - new Automake::Conditional ("A_TRUE", "C_FALSE"), - new Automake::Conditional ("A_TRUE", "B_FALSE", "C_TRUE"), - new Automake::Conditional ("A_FALSE")); - my $b = new Automake::ConditionalSet - (new Automake::Conditional ("A_TRUE", "B_FALSE")); + my $a = new Automake::DisjConditions + (new Automake::Condition ("A_TRUE", "B_TRUE"), + new Automake::Condition ("A_TRUE", "C_FALSE"), + new Automake::Condition ("A_TRUE", "B_FALSE", "C_TRUE"), + new Automake::Condition ("A_FALSE")); + my $b = new Automake::DisjConditions + (new Automake::Condition ("A_TRUE", "B_FALSE")); Calling C<$a-Esub_conditions ($b)> will return the following -C. +C. - new Automake::ConditionalSet - (new Automake::Conditional ("C_FALSE"), # From A_TRUE C_FALSE - new Automake::Conditional ("C_TRUE")); # From A_TRUE B_FALSE C_TRUE" + new Automake::DisjConditions + (new Automake::Condition ("C_FALSE"), # From A_TRUE C_FALSE + new Automake::Condition ("C_TRUE")); # From A_TRUE B_FALSE C_TRUE" =cut @@ -720,27 +739,27 @@ sub sub_conditions ($$) { my ($self, $subcond) = @_; - # Make $subcond blindingly apparent in the ConditionalSet. + # Make $subcond blindingly apparent in the DisjConditions. # For instance `$a->_multiply($b)' (from the POD example) is: - # new Automake::ConditionalSet - # (new Automake::Conditional ("FALSE"), - # new Automake::Conditional ("A_TRUE", "B_FALSE", "C_FALSE"), - # new Automake::Conditional ("A_TRUE", "B_FALSE", "C_TRUE"), - # new Automake::Conditional ("FALSE")); + # new Automake::DisjConditions + # (new Automake::Condition ("FALSE"), + # new Automake::Condition ("A_TRUE", "B_FALSE", "C_FALSE"), + # new Automake::Condition ("A_TRUE", "B_FALSE", "C_TRUE"), + # new Automake::Condition ("FALSE")); my $prod = $self->_multiply ($subcond); - # Now, strip $subcond from the remaining (i.e., non-false) Conditionals. + # Now, strip $subcond from the remaining (i.e., non-false) Conditions. my @res; foreach my $c ($prod->conds) { push @res, $c->strip ($subcond) unless $c->false; } - return new Automake::ConditionalSet @res; + return new Automake::DisjConditions @res; } =head1 SEE ALSO -L. +L. =head1 HISTORY @@ -748,9 +767,8 @@ Cs and supporting code were added to Automake 1.1o by Ian Lance Taylor in 1997. Since then it has been improved by Tom Tromey , Richard Boulton , Raja R Harinath , Akim -Demaille , and Pavel Roskin . -Alexandre Duret-Lutz extracted the code out of Automake -to create this package in 2002. +Demaille , Pavel Roskin , and +Alexandre Duret-Lutz . =cut diff --git a/lib/Automake/Makefile.am b/lib/Automake/Makefile.am index 33f4e9711..c724c874e 100644 --- a/lib/Automake/Makefile.am +++ b/lib/Automake/Makefile.am @@ -1,13 +1,30 @@ ## Process this file with automake to create Makefile.in +## Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. + +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. + +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +## 02111-1307, USA. + SUBDIRS = tests perllibdir = $(pkgvdatadir)/Automake dist_perllib_DATA = \ ChannelDefs.pm \ Channels.pm \ - Conditional.pm \ - ConditionalSet.pm \ + Condition.pm \ + DisjConditions.pm \ General.pm \ Location.pm \ Struct.pm \ diff --git a/lib/Automake/Makefile.in b/lib/Automake/Makefile.in index 4210aa091..52cb47177 100644 --- a/lib/Automake/Makefile.in +++ b/lib/Automake/Makefile.in @@ -99,8 +99,8 @@ perllibdir = $(pkgvdatadir)/Automake dist_perllib_DATA = \ ChannelDefs.pm \ Channels.pm \ - Conditional.pm \ - ConditionalSet.pm \ + Condition.pm \ + DisjConditions.pm \ General.pm \ Location.pm \ Struct.pm \ diff --git a/lib/Automake/tests/Conditional.pl b/lib/Automake/tests/Condition.pl similarity index 88% rename from lib/Automake/tests/Conditional.pl rename to lib/Automake/tests/Condition.pl index b969e6479..ea7bd6a67 100644 --- a/lib/Automake/tests/Conditional.pl +++ b/lib/Automake/tests/Condition.pl @@ -1,4 +1,4 @@ -# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -17,7 +17,7 @@ # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. -use Automake::Conditional qw/TRUE FALSE/; +use Automake::Condition qw/TRUE FALSE/; sub test_basics () { @@ -33,7 +33,7 @@ sub test_basics () for (@tests) { - my $a = new Automake::Conditional @{$_->[0]}; + my $a = new Automake::Condition @{$_->[0]}; return 1 if $_->[1] != $a->true; return 1 if $_->[1] != ($a == TRUE); return 1 if $_->[2] != $a->false; @@ -49,8 +49,8 @@ sub test_true_when () my $failed = 0; my @tests = (# [When, - # [Implied-Conditionals], - # [Not-Implied-Conditionals]] + # [Implied-Conditions], + # [Not-Implied-Conditions]] [['TRUE'], [['TRUE']], [['A_TRUE'], ['A_TRUE', 'B_FALSE'], ['FALSE']]], @@ -63,10 +63,10 @@ sub test_true_when () for my $t (@tests) { - my $a = new Automake::Conditional @{$t->[0]}; + my $a = new Automake::Condition @{$t->[0]}; for my $u (@{$t->[1]}) { - my $b = new Automake::Conditional @$u; + my $b = new Automake::Condition @$u; if (! $b->true_when ($a)) { print "`" . $b->string . @@ -76,7 +76,7 @@ sub test_true_when () } for my $u (@{$t->[2]}) { - my $b = new Automake::Conditional @$u; + my $b = new Automake::Condition @$u; if ($b->true_when ($a)) { print "`" . $b->string . @@ -127,7 +127,7 @@ sub test_reduce () [["BAR FOO", "BAR", "TRUE"], ["BAR FOO"]], # Check that reduction happens even when there are - # two conditionals to remove. + # two conditions to remove. [["FOO", "FOO BAR", "BAR"], ["FOO BAR"]], [["FOO", "FOO BAR", "BAZ", "FOO BAZ"], ["FOO BAR", "FOO BAZ"]], [["FOO", "FOO BAR", "BAZ", "FOO BAZ", "FOO BAZ BAR"], @@ -136,7 +136,7 @@ sub test_reduce () # Duplicated condionals should be removed [["FOO", "BAR", "BAR"], ["BAR,FOO"]], - # Equivalent conditionals in different forms should be + # Equivalent conditions in different forms should be # reduced: which one is left is unfortunately order # dependent. [["BAR FOO", "FOO BAR"], ["FOO BAR"]], @@ -146,10 +146,10 @@ sub test_reduce () foreach (@tests) { my ($inref, $outref) = @$_; - my @inconds = map { new Automake::Conditional $_ } @$inref; - my @outconds = map { (new Automake::Conditional $_)->string } @$outref; + my @inconds = map { new Automake::Condition $_ } @$inref; + my @outconds = map { (new Automake::Condition $_)->string } @$outref; my @res = - map { $_->string } (Automake::Conditional::reduce (@inconds)); + map { $_->string } (Automake::Condition::reduce (@inconds)); my $result = join (",", sort @res); my $exresult = join (",", @outconds); diff --git a/lib/Automake/tests/ConditionalSet.pl b/lib/Automake/tests/DisjConditions.pl similarity index 94% rename from lib/Automake/tests/ConditionalSet.pl rename to lib/Automake/tests/DisjConditions.pl index c484014f0..6d76e66a1 100644 --- a/lib/Automake/tests/ConditionalSet.pl +++ b/lib/Automake/tests/DisjConditions.pl @@ -1,4 +1,4 @@ -# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -17,20 +17,20 @@ # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. -use Automake::Conditional qw/TRUE FALSE/; -use Automake::ConditionalSet; +use Automake::Condition qw/TRUE FALSE/; +use Automake::DisjConditions; sub test_basics () { - my $cond = new Automake::Conditional "COND1_TRUE", "COND2_FALSE"; - my $other = new Automake::Conditional "COND3_FALSE"; - my $set1 = new Automake::ConditionalSet $cond, $other; - my $set2 = new Automake::ConditionalSet $other, $cond; + my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE"; + my $other = new Automake::Condition "COND3_FALSE"; + my $set1 = new Automake::DisjConditions $cond, $other; + my $set2 = new Automake::DisjConditions $other, $cond; return 1 unless $set1 == $set2; return 1 if $set1->false; return 1 if $set1->true; - return 1 unless (new Automake::ConditionalSet)->false; - return 1 if (new Automake::ConditionalSet)->true; + return 1 unless (new Automake::DisjConditions)->false; + return 1 if (new Automake::DisjConditions)->true; } sub build_set (@) @@ -39,9 +39,9 @@ sub build_set (@) my @set = (); for my $cond (@conds) { - push @set, new Automake::Conditional @$cond; + push @set, new Automake::Condition @$cond; } - return new Automake::ConditionalSet @set; + return new Automake::DisjConditions @set; } sub test_permutations () @@ -302,7 +302,7 @@ sub test_simplify () # Also exercize invert() while we are at it. - # FIXME: Don't run invert() with too much conditionals, this is too slow. + # FIXME: Don't run invert() with too much conditions, this is too slow. next if $#{$t->[0][0]} > 8; my $inv1 = $set->invert->simplify; @@ -366,7 +366,7 @@ sub test_sub_conditions () for my $t (@tests) { my $t1 = build_set @{$t->[0]}; - my $t2 = new Automake::Conditional @{$t->[1]}; + my $t2 = new Automake::Condition @{$t->[1]}; my $t3 = build_set @{$t->[2]}; # Make sure simplify() yields the expected result. diff --git a/lib/Automake/tests/Makefile.am b/lib/Automake/tests/Makefile.am index ad1a19d32..1fefa7157 100644 --- a/lib/Automake/tests/Makefile.am +++ b/lib/Automake/tests/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to create Makefile.in -## Copyright (C) 2002 Free Software Foundation, Inc. +## Copyright (C) 2002, 2003 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ TESTS_ENVIRONMENT = $(PERL) -Mstrict -I $(top_srcdir)/lib -w TESTS = \ -Conditional.pl \ -ConditionalSet.pl +Condition.pl \ +DisjConditions.pl EXTRA_DIST = $(TESTS) diff --git a/lib/Automake/tests/Makefile.in b/lib/Automake/tests/Makefile.in index 95cf5d7b7..812017c76 100644 --- a/lib/Automake/tests/Makefile.in +++ b/lib/Automake/tests/Makefile.in @@ -95,8 +95,8 @@ target_alias = @target_alias@ TESTS_ENVIRONMENT = $(PERL) -Mstrict -I $(top_srcdir)/lib -w TESTS = \ -Conditional.pl \ -ConditionalSet.pl +Condition.pl \ +DisjConditions.pl EXTRA_DIST = $(TESTS)