]> sourceware.org Git - automake.git/commitdiff
* automake.in (&variable_defined, &define_pretty_variable):
authorAkim Demaille <akim@epita.fr>
Mon, 9 Apr 2001 09:00:57 +0000 (09:00 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 9 Apr 2001 09:00:57 +0000 (09:00 +0000)
Simplify code which used to handle the cases where not all
variables were in %conditional.
(&define_variable): Use &define_pretty_variable.
(&variable_conditions_sub, &variable_value_as_list_worker)
(&variable_value_as_list, &rule_define): Simplify syntax.
(&read_main_am_file): Dump the guilty predefined variables.

ChangeLog
automake.in

index bda0ffcb47025ca64d966340ec3ab47aa5014151..f9cfaaced5e6e21defd99b401a6101b2c97b4935 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2001-04-09  Akim Demaille  <akim@epita.fr>
+
+       * automake.in (&variable_defined, &define_pretty_variable):
+       Simplify code which used to handle the cases where not all
+       variables were in %conditional.
+       (&define_variable): Use &define_pretty_variable.
+       (&variable_conditions_sub, &variable_value_as_list_worker)
+       (&variable_value_as_list, &rule_define): Simplify syntax.
+       (&read_main_am_file): Dump the guilty predefined variables.
+
 2001-04-09  Akim Demaille  <akim@epita.fr>
 
        * automake.in (&variable_conditions_sub)
index 7241cd88679767f22a57f8e483ff93c70a2e3655..153401e914c619f254e6065ce75970621878b47a 100755 (executable)
@@ -5692,25 +5692,21 @@ sub variable_defined ($$)
 {
     my ($var, $cond) = @_;
 
-    if (exists $conditional{$var} && !$var_is_am{$var})
+    $cond ||= 'TRUE';
+
+    if (!$var_is_am{$var})
     {
-       if ($cond && $conditional{$var})
+      if (!exists $conditional{$var}{$cond})
        {
-         if (exists $conditional{$var}{$cond})
-           {
-             # 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 0;
+         # The variable is not defined for the given condition.
+         return 0;
        }
 
-       $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;
     }
 
     &am_line_error ($var, "`$var' is a target; expected a variable")
@@ -5804,7 +5800,7 @@ sub variable_conditions_sub
 
        push (@parent_conds, $vcond);
        my @subvar_conds = ();
-       foreach (split (' ', ${$conditional{$var}}{$vcond}))
+       foreach (split (' ', $conditional{$var}{$vcond}))
        {
            # If a comment seen, just leave.
            last if /^#/;
@@ -6073,7 +6069,7 @@ sub variable_value_as_list_worker
        $vars_scanned{$var} = 1;
        foreach my $vcond (keys %{$conditional{$var}})
        {
-           my $val = ${$conditional{$var}}{$vcond};
+           my $val = $conditional{$var}{$vcond};
            push (@result, &value_to_list ($var, $val, $cond));
        }
     }
@@ -6084,7 +6080,7 @@ sub variable_value_as_list_worker
        my $onceflag;
        foreach my $vcond (keys %{$conditional{$var}})
        {
-           my $val = ${$conditional{$var}}{$vcond};
+           my $val = $conditional{$var}{$vcond};
            if (&conditional_true_when ($vcond, $cond))
            {
                # Warn if we have an ambiguity.  It's hard to know how
@@ -6115,25 +6111,6 @@ sub variable_value_as_list
 }
 
 
-# define_variable ($VAR, $VALUE)
-# ------------------------------
-# Define a new user variable VAR to VALUE, but only if not already defined.
-sub define_variable
-{
-    my ($var, $value) = @_;
-    if (! defined $conditional{$var}{'TRUE'})
-    {
-       $output_vars .= $var . ' = ' . $value . "\n";
-       macro_define ($var, 0, '', '', $value, undef);
-       $content_seen{$var} = 1;
-    }
-    elsif ($var_was_plus_eq{$var})
-    {
-       &am_line_error ($var,
-                       "internally generated variable `$var' was set with `+='");
-    }
-}
-
 # Like define_variable, but the value is a list, and the variable may
 # be defined conditionally.  The second argument is the conditional
 # under which the value should be defined; this should be the empty
@@ -6144,8 +6121,7 @@ sub define_pretty_variable
 {
     my ($var, $cond, @value) = @_;
 
-    if (! defined $conditional{$var}{'TRUE'}
-       || ($cond && ! &variable_defined ($var, $cond)))
+    if (! &variable_defined ($var, $cond))
     {
         macro_define ($var, 0, '', $cond, join (' ', @value), undef);
         my $make_condition = &make_condition ($cond);
@@ -6153,8 +6129,25 @@ sub define_pretty_variable
                       $make_condition, @value);
        $content_seen{$var} = 1;
     }
+    elsif ($var_was_plus_eq{$var})
+    {
+       &am_line_error ($var,
+                       "internally generated variable `$var' was set with `+='");
+    }
 }
 
+
+# define_variable ($VAR, $VALUE)
+# ------------------------------
+# Define a new user variable VAR to VALUE, but only if not already defined.
+sub define_variable
+{
+    my ($var, $value) = @_;
+
+    define_pretty_variable ($var, 'TRUE', $value);
+}
+
+
 # Like define_variable, but define a variable to be the configure
 # substitution by the same name.
 sub define_configure_variable
@@ -6236,7 +6229,7 @@ sub rule_define ($$$$)
        {
          &check_ambiguous_conditional ($target, $cond);
        }
-      ${$target_conditional{$target}}{$cond} = $where;
+      $target_conditional{$target}{$cond} = $where;
     }
 
 
@@ -6531,8 +6524,11 @@ sub read_main_am_file
     my ($amfile) = @_;
 
     # This supports the strange variable tricks we are about to play.
-    &prog_error ("variable defined before read_main_am_file")
-        if scalar keys %conditional > 0;
+    if (scalar keys %conditional > 0)
+      {
+       variables_dump ();
+       &prog_error ("variable defined before read_main_am_file");
+      }
 
     # We want to predefine as many variables as possible.  This lets
     # the user set them with `+=' in Makefile.am.  However, we don't
This page took 0.039138 seconds and 5 git commands to generate.