[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
no way to redefine variables in automake
From: |
Johan Danielsson |
Subject: |
no way to redefine variables in automake |
Date: |
18 Mar 2002 18:16:56 +0100 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7 |
Hi,
This code fails:
--foo.am
SOMETHING=x
--Makefile.am--
include foo.am
SOMETHING=y
This seems like a silly thing to do, but can be quite handy if you
want to provide a default for some variable. The same thing can be
accomplished with AC_SUBST instead, but I don't think that's very
elegant.
Fix: either just remove the test for multiple definition, or add some
way to make an assignment optional. Crude example follows:
--- automake.save Mon Mar 18 17:32:12 2002
+++ automake Mon Mar 18 18:11:56 2002
@@ -142,7 +142,7 @@
# leading tabs here then we need to make the reader smarter, because
# otherwise it will think rules like `foo=bar; \' are errors.
my $MACRO_PATTERN = 'address@hidden';
-my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)$';
+my $ASSIGNMENT_PATTERN = '^ *([^ \t?=:+]*)\s*([?:+]?)=\s*(.*)$';
# This pattern recognizes a Gnits version id and sets $1 if the
# release is an alpha release. We also allow a suffix which can be
# used to extend the version number with a "fork" identifier.
@@ -5939,12 +5939,18 @@
sub macro_define ($$$$$$)
{
my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
+ my ($old_type);
file_error ($where, "bad macro name `$var'")
if $var !~ /$MACRO_PATTERN/o;
$cond ||= 'TRUE';
+ # If already set, and this is an optional, just ignore
+ if(defined $var_type{$var} && $type eq '?') {
+ return;
+ }
+
# 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 `+='.
@@ -5964,6 +5970,8 @@
file_error ($where, "$var must be set with `=' before using `+='");
}
}
+
+ $old_type = defined $var_type{$var} ? $var_type{$var} : '';
$var_type{$var} = $type;
# When adding, since we rewrite, don't try to preserve the
@@ -5994,7 +6002,7 @@
# the original location. More subs are needed to handle
# properly variables. Once this done, remove this hack.
$var_location{$var} = $where
- unless defined $var_location{$var};
+ unless defined $var_location{$var} and $old_type ne '?';
# If Automake tries to override a value specified by the user,
# just don't let it do.
@@ -6013,6 +6021,7 @@
# an Automake variable or an AC_SUBST variable.
check_ambiguous_conditional ($var, $cond)
unless ($var_is_am{$var} && !$var_is_am
+ || $old_type eq '?'
|| exists $configure_vars{$var});
$var_value{$var}{$cond} = $value;
This allows this syntax:
--foo.am
SOMETHING?=x
--Makefile.am--
include foo.am
SOMETHING=y
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- no way to redefine variables in automake,
Johan Danielsson <=