+2001-03-23 Akim Demaille <akim@epita.fr>
+
+ * automake.in (&variable_conditionally_defined): Rename as...
+ (&check_variable_unconditionally_defined): this.
+ (&variable_dump): Fix the output.
+ (&variable_defined, ¯o_define): Since conditions are
+ canonicalized, don't use a loop to look for a condition: read the
+ hash.
+ (¯o_define, &rule_define, &read_am_file, &file_contents):
+ Rename $cond_string as $cond.
+ * distdir.am (PACKAGE, VERSION): Remove; since they are already
+ discovered via AC_SUBST, they now trigger a `defined twice' error.
+
2001-03-23 Akim Demaille <akim@epita.fr>
* automake.in (&handle_footer, &handle_installdirs)
(&read_main_am_file): Don't read %contents directly, use
&variable_value.
-
2001-03-23 Akim Demaille <akim@epita.fr>
* automake.in (&read_am_file): Define the variables in a single
shot.
Factor the $saw_bk code.
-
2001-03-23 Akim Demaille <akim@epita.fr>
* automake.in (&read_am_file): Keep $cond_string up to date.
-
2001-03-23 Akim Demaille <akim@epita.fr>
* automake.in (&define_variable): Use ¯o_define.
-
2001-03-23 Akim Demaille <akim@epita.fr>
* automake.in (¯o_define): Don't lose the location if we
(&variables_dump): this. Use...
(&variable_dump): this new sub.
-
2001-03-23 Akim Demaille <akim@epita.fr>
* automake.in (&file_contents): Maintain $cond_string sync with
variables.
(&file_contents): Use macro_define.
-
2001-03-23 Akim Demaille <akim@epita.fr>
* automake.in (&rule_define): Extract from...
(&read_am_file): here.
-
2001-03-23 Akim Demaille <akim@epita.fr>
* automake.in (¯o_define, &read_am_file): More work for the
exit $exit_status;
+# FIXME: This should be `my'ed next to its subs.
+# use vars '%require_file_found';
################################################################
print STDERR " $var ($var_is_am, where = $where) $pluseq\n";
print STDERR " {\n";
print STDERR " (TRUE) => $contents{$var}\n";
- foreach my $var (sort keys %conditional)
+ foreach my $vcond (sort by_condition keys %{$conditional{$var}})
{
- foreach my $vcond (sort by_condition keys %{$conditional{$var}})
- {
- print STDERR " $vcond => $conditional{$var}{$vcond}\n";
- }
+ print STDERR " $vcond => $conditional{$var}{$vcond}\n";
}
print STDERR " }\n";
}
## ------------------------ ##
-# ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND_STRING, $VALUE, $WHERE)
-# -----------------------------------------------------------------------
+# ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
+# ----------------------------------------------------------------
# The $VAR can go from Automake to user, but not the converse.
sub macro_define ($$$$$$)
{
- my ($var, $var_is_am, $type, $cond_string, $value, $where) = @_;
+ my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
if (defined $contents{$var}
- && ($cond_string
+ && ($cond
? ! defined $conditional{$var}
: defined $conditional{$var}))
{
}
# Handle conditionalized macros.
- if ($cond_string)
+ if ($cond)
{
- my $done = 0;
- if ($conditional{$var})
+ if ($type eq '+' && exists $conditional{$var}{$cond})
{
- if ($type eq '+')
- {
- # If we're adding to the conditional, and it
- # exists, then we might want to simply replace the old
- # value with the new one.
- foreach my $vcond (keys %{$conditional{$var}})
- {
- if ($vcond eq $cond_string)
- {
- $done = 1;
- ${$conditional{$var}}{$vcond} .= ' ' . $value;
- }
- }
- }
- }
- if (! $done)
+ $conditional{$var}{$cond} .= ' ' . $value;
+ }
+ else
{
- &check_ambiguous_conditional ($var, $cond_string);
- ${$conditional{$var}}{$cond_string} = $value;
+ &check_ambiguous_conditional ($var, $cond);
+ $conditional{$var}{$cond} = $value;
}
}
{
if ($cond && $conditional{$var})
{
- # We have been asked to check for a particular condition,
- # and the variable is defined conditionally. We need to
- # look through the conditions under which the variable is
- # defined, and see if any of them match the conditional we
- # have been asked to check.
- foreach my $vcond (keys %{$conditional{$var}})
+ if (exists $conditional{$var}{$cond})
{
- if ($cond eq $vcond)
- {
- # Even a conditional examination is good enough
- # for us. FIXME: really should maintain examined
- # status on a per-condition basis.
- $content_seen{$var} = 1;
- return 1;
- }
+ # Even a conditional examination is good enough for us.
+ # FIXME: really should maintain examined status on a
+ # per-condition basis.
+ $content_seen{$var} = 1;
+ return 1;
}
# The variable is not defined for the given condition.
return @ret;
}
+
+# $BOOL
+# &check_variable_defined_unconditionally($VAR, $PARENT)
+# ------------------------------------------------------
# Warn if a variable is conditionally defined. This is called if we
# are using the value of a variable.
-sub variable_conditionally_defined
+sub check_variable_defined_unconditionally ($$)
{
my ($var, $parent) = @_;
if ($conditional{$var})
}
}
+
# Get the value of a variable. This just returns $contents, but warns
# if the variable is conditionally defined.
sub variable_value
{
my ($var) = @_;
- &variable_conditionally_defined ($var);
+ &check_variable_defined_unconditionally ($var);
return $contents{$var};
}
{
# Warn if we have an ambiguity. It's hard to know how
# to handle this case correctly.
- &variable_conditionally_defined ($var, $parent)
+ &check_variable_defined_unconditionally ($var, $parent)
if $onceflag;
$onceflag = 1;
push (@result, &value_to_list ($var, $val, $cond));
else
{
$vars_scanned{$var} = 1;
- &variable_conditionally_defined ($var, $parent);
+ &check_variable_defined_unconditionally ($var, $parent);
$content_seen{$var} = 1;
push (@result, &value_to_list ($var, $contents{$var}, $cond));
}
sub define_variable
{
my ($var, $value) = @_;
-
if (! defined $contents{$var})
{
$output_vars .= $var . ' = ' . $value . "\n";
sub rule_define ($$$$)
{
- my ($target, $rule_is_am, $cond_string, $where) = @_;
+ my ($target, $rule_is_am, $cond, $where) = @_;
if (defined $targets{$target}
- && ($cond_string
+ && ($cond
? ! defined $target_conditional{$target}
: defined $target_conditional{$target}))
{
# Value here doesn't matter; for targets we only note existence.
$targets{$target} = $where;
- if ($cond_string)
+ if ($cond)
{
if ($target_conditional{$target})
{
- &check_ambiguous_conditional ($target, $cond_string);
+ &check_ambiguous_conditional ($target, $cond);
}
- ${$target_conditional{$target}}{$cond_string} = $where;
+ ${$target_conditional{$target}}{$cond} = $where;
}
# sure it is the same on exit. This lets us conditonally include
# other files.
my @saved_cond_stack = @conditional_stack;
- my $cond_string = conditional_string (@conditional_stack);
+ my $cond = conditional_string (@conditional_stack);
my $saw_bk = 0;
my $was_rule = 0;
if (!/\\$/)
{
macro_define ($last_var_name, 0,
- $last_var_type, $cond_string,
+ $last_var_type, $cond,
$last_var_value, $.);
push (@var_list, $last_var_name);
}
if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
push (@conditional_stack,
($cond =~ /^TRUE|FALSE$/) ? "$cond" : "${cond}_TRUE");
- $cond_string = conditional_string (@conditional_stack);
+ $cond = conditional_string (@conditional_stack);
}
elsif (/$ELSE_PATTERN/o)
{
{
$conditional_stack[$#conditional_stack]
=~ s/TRUE$/FALSE/;
- $cond_string = conditional_string (@conditional_stack);
+ $cond = conditional_string (@conditional_stack);
}
}
elsif (/$ENDIF_PATTERN/o)
else
{
pop @conditional_stack;
- $cond_string = conditional_string (@conditional_stack);
+ $cond = conditional_string (@conditional_stack);
}
}
elsif (/$RULE_PATTERN/o)
# Found a rule.
$was_rule = 1;
- rule_define ($1, 0, $cond_string, $.);
+ rule_define ($1, 0, $cond, $.);
$content_lines{$1} = $.;
$output_trailer .= $comment . $spacing;
if (!/\\$/)
{
macro_define ($last_var_name, 0,
- $last_var_type, $cond_string,
+ $last_var_type, $cond,
$last_var_value, $.);
push (@var_list, $last_var_name);
}
my $comment = '';
my $separator = '';
my @cond_stack = ();
- my $cond_string = '';
+ my $cond = '';
foreach (split (/(?<!\\)\n(?![\t#])/, $contents))
{
# Strip leading new lines. This can happen for comments:
if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
push (@cond_stack,
($cond =~ /^TRUE|FALSE$/) ? "$cond" : "${cond}_TRUE");
- $cond_string = conditional_string (@cond_stack);
+ $cond = conditional_string (@cond_stack);
}
elsif (/$ELSE_PATTERN/o)
{
else
{
$cond_stack[$#cond_stack] =~ s/TRUE$/FALSE/;
- $cond_string = conditional_string (@cond_stack);
+ $cond = conditional_string (@cond_stack);
}
}
elsif (/$ENDIF_PATTERN/o)
else
{
pop @cond_stack;
- $cond_string = conditional_string (@cond_stack);
+ $cond = conditional_string (@cond_stack);
}
}
# Output only if not in FALSE.
if (defined $dependencies{$_}
- && $cond_string ne "#")
+ && $cond ne "#")
{
&depend ($_, @deps);
$actions{$_} .= $actions;
# Free lance dependency. Output the rule for all the
# targets instead of one by one.
if (!defined $targets{$targets}
- && $cond_string ne "#")
+ && $cond ne "#")
{
$result_rules .= "$separator$comment$paragraph\n";
- rule_define ($targets, 1, $cond_string, $.);
+ rule_define ($targets, 1, $cond, $.);
}
$comment = $separator = '';
last;
if /\\$/;;
# Accumulating variables must not be output.
- macro_define ($var, 1, $type, $cond_string, $val, $.);
+ macro_define ($var, 1, $type, $cond, $val, $.);
push (@var_list, $var);
# If the user has set some variables we were in charge