automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

64-var-override-rules.patch


From: Akim Demaille
Subject: 64-var-override-rules.patch
Date: Mon, 19 Mar 2001 10:22:03 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * automake.in (&variable_dump): Use %var_type properly.
        (&variable_define): Enforce better overriding rules.
        Handle the special case that used to handle...
        (&define_pretty_variable): this.
        Hence, don't.
        The variables you define are owned by Automake.
        (&generate_makefile): PRE_INSTALL and co must not be defined *by
        the user*.
        (&variable_defined): Now independent from the owner.
        (&variable_output, &variable_pretty_output): Adjust to %var_type.

Index: automake.in
--- automake.in Mon, 12 Mar 2001 22:49:15 +0100 akim (am/f/39_automake.i 1.182 
755)
+++ automake.in Tue, 13 Mar 2001 00:00:30 +0100 akim (am/f/39_automake.i 1.182 
755)
@@ -980,7 +980,7 @@ sub generate_makefile
     # There are a few install-related variables that you should not define.
     foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
     {
-       if (&variable_defined ($var))
+       if (&variable_defined ($var) && !$var_is_am{$var})
        {
            &am_line_error ($var, "`$var' should not be defined");
        }
@@ -5404,9 +5404,7 @@ sub variable_dump ($)
       my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
       my $where = (defined $var_line{$var}
                   ? $var_line{$var} : "undefined");
-      my $pluseq = ((defined $var_type{$var} && $var_type{$var})
-                   ? "+=" : "=");
-      print STDERR "  $var ($var_is_am, where = $where) $pluseq\n";
+      print STDERR "  $var ($var_is_am, where = $where) $var_type{$var}=\n";
       print STDERR "  {\n";
       print STDERR "$var_comment{$var}"
        if defined $var_comment{$var};
@@ -5564,20 +5562,26 @@ sub variable_define ($$$$$$)

   $cond ||= 'TRUE';

-  # A variable which was `+=' must not be `='.
-  if (defined $var_type{$var})
+  # An Automake variable must be consistently defined with the same
+  # sign by Automake.  A user variable must be set by either `=' or
+  # `:=', and later promoted to `+='.
+  if ($var_is_am)
     {
-      if ($var_type{$var} && $type ne '+')
+      if (defined $var_type{$var} && $var_type{$var} ne $type)
        {
          am_line_error ($var,
-                        ("$var was set with `+=' "
+                        ("$var was set with `$var_type{$var}=' "
                          . "and is now set with `$type='"));
        }
     }
   else
     {
-      $var_type{$var} = $type;
+      if (!defined $var_type{$var} && $type eq '+')
+       {
+         am_line_error ($var, "$var must be set with `=' before using `+='");
+       }
     }
+  $var_type{$var} = $type;

   # Differentiate the first assignment (including with `+=').
   if ($type eq '+' && defined $var_value{$var}{$cond})
@@ -5640,10 +5644,10 @@ sub variable_delete ($)
 # $BOOLEAN
 # &variable_defined ($VAR, [$COND])
 # ---------------------------------
-# See if a variable exists, and is a user variable.  $VAR is the
-# variable name, and $COND is the condition which we should check.  If
-# no condition is given, we currently return true if the variable is
-# defined under any condition.
+# See if a variable exists.  $VAR is the variable name, and $COND is
+# the condition which we should check.  If no condition is given, we
+# currently return true if the variable is defined under any
+# condition.
 sub variable_defined ($$)
 {
     my ($var, $cond) = @_;
@@ -5661,8 +5665,7 @@ sub variable_defined ($$)
        return 0;
       }

-    if ($var_is_am{$var}
-       || ($cond && !exists $var_value{$var}{$cond}))
+    if ($cond && !exists $var_value{$var}{$cond})
       {
        # The variable is not defined for the given condition.
        return 0;
@@ -6099,7 +6102,8 @@ sub variable_output ($@)
   foreach my $cond (@conds)
     {
       my $val = $var_value{$var}{$cond};
-      my $output_var = "$var $var_type{$var}= $val";
+      my $equals = $var_type{$var} eq ':' ? ':=' : '=';
+      my $output_var = "$var $equals $val";
       $output_var =~ s/^/&make_condition ($cond)/meg;
       $output_vars .= $output_var . "\n";
     }
@@ -6123,9 +6127,9 @@ sub variable_pretty_output ($@)
   foreach my $cond (@conds)
     {
       my $val = $var_value{$var}{$cond};
+      my $equals = $var_type{$var} eq ':' ? ':=' : '=';
       my $make_condition = make_condition ($cond);
-      $output_vars .= pretty_print_internal ("$make_condition$var"
-                                            . " $var_type{$var}=",
+      $output_vars .= pretty_print_internal ("$make_condition$var $equals",
                                             "$make_condition\t",
                                             split (' ' , $val));
     }
@@ -6159,14 +6163,9 @@ sub define_pretty_variable

     if (! &variable_defined ($var, $cond))
     {
-        variable_define ($var, 0, '', $cond, join (' ', @value), undef);
+        variable_define ($var, 1, '', $cond, join (' ', @value), undef);
        variable_pretty_output ($var, $cond || 'TRUE');
        $content_seen{$var} = 1;
-    }
-    elsif ($var_type{$var})
-    {
-       &am_line_error ($var,
-                       "internally generated variable `$var' was set with 
`+='");
     }
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]