We want AUTOMAKE_OPTIONS in Makefile.in to be the combination of configure.ac and Makefile.am options. Define a new variable owner for this, because we need to override the Makefile.am value unconditionally and never emit warnings.
* lib/Automake/VarDef.pm (VAR_COMPUTED): New. (dump): Print it. * lib/Automake/Variable.pm (define): Check that VAR_COMPUTED variables were not conditionally defined, and always allow them to override previous definitions. --- lib/Automake/VarDef.pm | 18 ++++++++++++------ lib/Automake/Variable.pm | 12 +++++++++++- 2 file modificati, 23 inserzioni(+), 7 rimozioni(-) diff --git a/lib/Automake/VarDef.pm b/lib/Automake/VarDef.pm index 6bb9fa6..7d2a321 100644 --- a/lib/Automake/VarDef.pm +++ b/lib/Automake/VarDef.pm @@ -24,7 +24,7 @@ use Automake::ItemDef; require Exporter; use vars '@ISA', '@EXPORT'; @ISA = qw/Automake::ItemDef Exporter/; -@EXPORT = qw (&VAR_AUTOMAKE &VAR_CONFIGURE &VAR_MAKEFILE); +@EXPORT = qw (&VAR_AUTOMAKE &VAR_CONFIGURE &VAR_MAKEFILE &VAR_COMPUTED); =head1 NAME @@ -75,11 +75,12 @@ This class gathers data related to one Makefile-variable definition. =over 4 -=item C<VAR_AUTOMAKE>, C<VAR_CONFIGURE>, C<VAR_MAKEFILE> +=item C<VAR_AUTOMAKE>, C<VAR_CONFIGURE>, C<VAR_MAKEFILE>, C<VAR_COMPUTED> Possible owners for variables. A variable can be defined -by Automake, in F<configure.ac> (using C<AC_SUBST>), or in -the user's F<Makefile.am>. +by Automake (this is also the case for C<VAR_COMPUTED>, which +has highest priority), in F<configure.ac> (using C<AC_SUBST>), +or in the user's F<Makefile.am>. =cut @@ -88,6 +89,7 @@ the user's F<Makefile.am>. use constant VAR_AUTOMAKE => 0; # Variable defined by Automake. use constant VAR_CONFIGURE => 1;# Variable defined in configure.ac. use constant VAR_MAKEFILE => 2; # Variable defined in Makefile.am. +use constant VAR_COMPUTED => 3; # Variable computed by Automake. =back @@ -114,8 +116,8 @@ C<$type> should be C<''> for definitions made with C<=>, and C<':'> for those made with C<:=>. C<$owner> specifies who owns the variables, it can be one of -C<VAR_AUTOMAKE>, C<VAR_CONFIGURE>, or C<VAR_MAKEFILE> (see these -definitions). +C<VAR_AUTOMAKE>, C<VAR_CONFIGURE>, C<VAR_MAKEFILE>, or +C<VAR_COMPUTED> (see these definitions). =cut @@ -279,6 +281,10 @@ sub dump ($) { $owner = 'Makefile'; } + elsif ($owner == VAR_COMPUTED) + { + $owner = 'Automake (computed variable)'; + } else { prog_error ("unexpected owner"); diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index 50a4dad..dbda0a0 100644 --- a/lib/Automake/Variable.pm +++ b/lib/Automake/Variable.pm @@ -782,6 +782,13 @@ sub define ($$$$$$$) } } + # Additional checks for computed variables + if ($owner == VAR_COMPUTED && ! $new_var) + { + # A computed variable must be unconditional. + $self->check_defined_unconditionally; + } + # Differentiate assignment types. # 1. append (+=) to a variable defined for current condition @@ -849,10 +856,13 @@ sub define ($$$$$$$) # There must be no previous value unless the user is redefining # an Automake variable or an AC_SUBST variable for an existing # condition. + # Computed variables (currently only AUTOMAKE_OPTIONS) can always + # override user definitions. _check_ambiguous_condition ($self, $cond, $where) unless (!$new_var && (($def->owner == VAR_AUTOMAKE && $owner != VAR_AUTOMAKE) - || $def->owner == VAR_CONFIGURE)); + || $def->owner == VAR_CONFIGURE + || $owner == VAR_COMPUTED)); # Never decrease an owner. $owner = $def->owner -- 1.7.11.2