[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: Remaining of PR/353 (Was: Re: why do we keep the *initial* location
From: |
Alexandre Duret-Lutz |
Subject: |
FYI: Remaining of PR/353 (Was: Re: why do we keep the *initial* location of each variable?) |
Date: |
18 Sep 2002 20:42:28 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
>>> "adl" == Alexandre Duret-Lutz <address@hidden> writes:
adl> - # The first assignment to a macro sets its location. Ideally I
adl> - # suppose we would associate line numbers with random bits of text.
adl> - # FIXME: We sometimes redefine some variables, but we want to keep
adl> - # the original location. More subs are needed to handle
adl> - # properly variables. Once this done, remove this hack.
adl> - $var_location{$var} = $where
adl> The comment says "we want the original location" but without
adl> justification. Any idea why?
I think this was because Automake didn't record locations on a
per-condition basis. For instance in
if COND
VAR = 1
else
VAR = 2
endif
we would keep only the first location.
I'm installing the following patch and closing PR/353.
The first chunk says it all:
-# - $var_location{$VAR} is where it was defined,
-# - $var_comment{$VAR} are the comments associated to it.
-# - $var_type{$VAR} is how it has been defined (`', `+', or `:'),
-# - $var_owner{$VAR} tells who owns the variable (VAR_AUTOMAKE,
+# - $var_location{$VAR}{$COND} is where it was defined,
+# - $var_comment{$VAR}{$COND} are the comments associated to it.
+# - $var_type{$VAR}{$COND} is how it has been defined (`', `+', or `:'),
+# - $var_owner{$VAR}{$COND} tells who owns the variable (VAR_AUTOMAKE,
2002-09-18 Alexandre Duret-Lutz <address@hidden>
For PR automake/353: fill %var_location, %var_comment,
%var_type, %var_owner for each condition.
* automake.in (msg_cond_var): New function.
(msg_var): Use it.
(generate_makefile, process_option_list, handle_languages,
handle_lib_objects_cond, handle_compile, handle_libtool,
handle_ltlibraries, handle_texinfo_helper, handle_tests,
handle_emacs_lisp, handle_python, macro_define, macro_delete,
macro_dump, variable_assert, variable_output,
variable_pretty_output, read_am_file, read_main_am_file,
file_contents_internal, am_primary_prefixes,
require_variables_for_macro): Adjust accesses to %var_location,
%var_comment, %var_type, %var_owner.
(append_comments, require_file_with_macro,
require_conf_file_with_macro, require_variables): Add the
$cond argument.
* tests/comment7.test: New file.
* tests/Makefile.am (TESTS): Add comment7.test.
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1355
diff -u -r1.1355 automake.in
--- automake.in 17 Sep 2002 21:33:35 -0000 1.1355
+++ automake.in 18 Sep 2002 18:37:53 -0000
@@ -494,10 +494,10 @@
#
# For a $VAR:
# - $var_value{$VAR}{$COND} is its value associated to $COND,
-# - $var_location{$VAR} is where it was defined,
-# - $var_comment{$VAR} are the comments associated to it.
-# - $var_type{$VAR} is how it has been defined (`', `+', or `:'),
-# - $var_owner{$VAR} tells who owns the variable (VAR_AUTOMAKE,
+# - $var_location{$VAR}{$COND} is where it was defined,
+# - $var_comment{$VAR}{$COND} are the comments associated to it.
+# - $var_type{$VAR}{$COND} is how it has been defined (`', `+', or `:'),
+# - $var_owner{$VAR}{$COND} tells who owns the variable (VAR_AUTOMAKE,
# VAR_CONFIGURE, or VAR_MAKEFILE).
my %var_value;
my %var_location;
@@ -1216,13 +1216,24 @@
msg_ac ('error', @_);
}
+# msg_cond_var ($CHANNEL, $COND, $VARNAME, $MESSAGE, [%OPTIONS])
+# --------------------------------------------------------------
+# Messages about conditional variable.
+sub msg_cond_var ($$$$;%)
+{
+ my ($channel, $cond, $var, $msg, %opts) = @_;
+ msg $channel, $var_location{$var}{$cond}, $msg, %opts;
+}
+
# msg_var ($CHANNEL, $VARNAME, $MESSAGE, [%OPTIONS])
# --------------------------------------------------
# Messages about variables.
sub msg_var ($$$;%)
{
- my ($channel, $macro, $msg, %opts) = @_;
- msg $channel, $var_location{$macro}, $msg, %opts;
+ my ($channel, $var, $msg, %opts) = @_;
+ # Don't know which condition is concerned. Pick any.
+ my $cond = (keys %{$var_value{$var}})[0];
+ msg_cond_var $channel, $cond, $var, $msg, %opts;
}
# msg_cond_target ($CHANNEL, $COND, $TARGETNAME, $MESSAGE, [%OPTIONS])
@@ -1265,7 +1276,7 @@
# $BOOL
# reject_var ($VAR, $ERROR_MSG)
-# ----------------------------------
+# -----------------------------
sub reject_var ($$)
{
my ($var, $msg) = @_;
@@ -1590,8 +1601,13 @@
# There are a few install-related variables that you should not define.
foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
{
- reject_var $var, "`$var' should not be defined"
- if $var_owner{$var} != VAR_AUTOMAKE;
+ if (exists $var_owner{$var})
+ {
+ prog_error "\$var_owner{$var}{TRUE} doesn't exist"
+ unless exists $var_owner{$var}{'TRUE'};
+ reject_var $var, "`$var' should not be defined"
+ if $var_owner{$var}{'TRUE'} != VAR_AUTOMAKE;
+ }
}
# Catch some obsolete variables.
@@ -1829,9 +1845,10 @@
{
my ($config, @list) = @_;
+ # FIXME: We should disallow conditional deffinitions of AUTOMAKE_OPTIONS.
my $where = ($config ?
$seen_init_automake :
- $var_location{'AUTOMAKE_OPTIONS'});
+ $var_location{'AUTOMAKE_OPTIONS'}{'TRUE'});
foreach (@list)
{
@@ -2157,7 +2174,7 @@
if ($lang->link);
require_variables ("$am_file.am", $lang->Name . " source seen",
- @{$lang->config_vars});
+ 'TRUE', @{$lang->config_vars});
# Call the finisher.
$lang->finish;
@@ -2170,12 +2187,18 @@
foreach my $flag (@dont_override)
{
- if (exists $var_owner{$flag} &&
- $var_owner{$flag} == VAR_MAKEFILE)
+ if (exists $var_owner{$flag})
{
- msg ('gnu', $var_location{$flag},
- "`$flag' is a user variable, you should not "
- . "override it;\nuse `AM_$flag' instead.");
+ for my $cond (keys %{$var_owner{$flag}})
+ {
+ if ($var_owner{$flag}{$cond} == VAR_MAKEFILE)
+ {
+ msg_cond_var ('gnu', $cond, $flag,
+ "`$flag' is a user variable, "
+ . "you should not override it;\n"
+ . "use `AM_$flag' instead.");
+ }
+ }
}
}
}
@@ -2904,7 +2927,7 @@
if ($iter =~ /\.h$/)
{
- require_file_with_macro ($var, FOREIGN, $iter);
+ require_file_with_macro ($cond, $var, FOREIGN, $iter);
}
elsif ($iter ne 'alloca.c')
{
@@ -2918,7 +2941,7 @@
&variable_value_as_list_recursive (
'BUILT_SOURCES', 'all')))
{
- require_file_with_macro ($var, FOREIGN, $iter);
+ require_file_with_macro ($cond, $var, FOREIGN, $iter);
}
}
}
@@ -2933,7 +2956,7 @@
. "`$configure_ac'")
if ! defined $libsources{'alloca.c'};
$dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
- require_file_with_macro ($var, FOREIGN, 'alloca.c');
+ require_file_with_macro ($cond, $var, FOREIGN, 'alloca.c');
&saw_extension ('c');
}
}
@@ -3044,7 +3067,7 @@
{
# Only require ansi2knr files if they should appear in
# this directory.
- require_file_with_macro ('AUTOMAKE_OPTIONS', FOREIGN,
+ require_file_with_macro ('TRUE', 'AUTOMAKE_OPTIONS', FOREIGN,
'ansi2knr.c', 'ansi2knr.1');
# ansi2knr needs to be built before subdirs, so unshift it.
@@ -3069,7 +3092,7 @@
return unless variable_defined ('LIBTOOL');
# Libtool requires some files, but only at top level.
- require_conf_file_with_macro ('LIBTOOL', FOREIGN, @libtool_files)
+ require_conf_file_with_macro ('TRUE', 'LIBTOOL', FOREIGN, @libtool_files)
if $relative_dir eq '.';
my @libtool_rms;
@@ -3279,7 +3302,7 @@
my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
'noinst', 'check');
- require_variables_for_macro ($prefix[0] . '_KTLIBRARIES',
+ require_variables_for_macro ($prefix[0] . '_LTLIBRARIES',
'Libtool library used', 'LIBTOOL')
if (@prefix);
@@ -3679,13 +3702,13 @@
# This is ugly, but it is our historical practice.
if ($config_aux_dir_set_in_configure_in)
{
- require_conf_file_with_macro ('info_TEXINFOS', FOREIGN,
+ require_conf_file_with_macro ('TRUE', 'info_TEXINFOS', FOREIGN,
'mdate-sh');
}
else
{
- require_file_with_macro ('info_TEXINFOS', FOREIGN,
- 'mdate-sh');
+ require_file_with_macro ('TRUE', 'info_TEXINFOS',
+ FOREIGN, 'mdate-sh');
}
my $conf_dir;
@@ -3765,12 +3788,13 @@
{
if ($need_texi_file > 1)
{
- require_conf_file_with_macro ('info_TEXINFOS', FOREIGN,
+ require_conf_file_with_macro ('TRUE', 'info_TEXINFOS', FOREIGN,
'texinfo.tex');
}
else
{
- require_file_with_macro ('info_TEXINFOS', FOREIGN, 'texinfo.tex');
+ require_file_with_macro ('TRUE', 'info_TEXINFOS', FOREIGN,
+ 'texinfo.tex');
}
}
@@ -4894,7 +4918,7 @@
push (@all, '$(ELCFILES)');
- require_variables ("$am_file.am", "Emacs Lisp sources seen",
+ require_variables ("$am_file.am", "Emacs Lisp sources seen", 'TRUE',
'EMACS', 'lispdir');
require_conf_file ("$am_file.am", FOREIGN, 'elisp-comp');
&define_variable ('elisp_comp', $config_aux_dir . '/elisp-comp');
@@ -4907,7 +4931,8 @@
'noinst');
return if ! @pyfiles;
- require_variables ("$am_file.am", "Python sources seen", 'PYTHON');
+ require_variables ("$am_file.am", "Python sources seen", 'TRUE',
+ 'PYTHON');
require_conf_file ("$am_file.am", FOREIGN, 'py-compile');
&define_variable ('py_compile', $config_aux_dir . '/py-compile');
}
@@ -4956,7 +4981,7 @@
{
# This means we have an alpha release. See
# GNITS_VERSION_PATTERN for details.
- require_file_with_macro ('AUTOMAKE_OPTIONS',
+ require_file_with_macro ('TRUE', 'AUTOMAKE_OPTIONS',
FOREIGN, 'README-alpha');
}
}
@@ -6204,16 +6229,22 @@
# `:=', and later promoted to `+='.
if ($owner == VAR_AUTOMAKE)
{
- err ($where, "$var was set with `$var_type{$var}=' "
- . "and is now set with `$type='")
- if defined $var_type{$var} && $var_type{$var} ne $type;
+ if (exists $var_type{$var}
+ && exists $var_type{$var}{$cond}
+ && $var_type{$var}{$cond} ne $type)
+ {
+ err ($where, "$var was set with `$var_type{$var}=' "
+ . "and is now set with `$type='");
+ }
}
else
{
- err $where, "$var must be set with `=' before using `+='"
- if !defined $var_type{$var} && $type eq '+';
+ if (!exists $var_type{$var} && $type eq '+')
+ {
+ err $where, "$var must be set with `=' before using `+='";
+ }
}
- $var_type{$var} = $type;
+ $var_type{$var}{$cond} = $type;
# When adding, since we rewrite, don't try to preserve the
# Automake continuation backslashes.
@@ -6319,14 +6350,6 @@
# 3. first assignment (=, :=, or +=)
else
{
- # The first assignment to a macro sets its location. Ideally I
- # suppose we would associate line numbers with random bits of text.
- # FIXME: We sometimes redefine some variables, but we want to keep
- # 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};
-
# If Automake tries to override a value specified by the user,
# just don't let it do.
if (defined $var_value{$var}{$cond}
@@ -6344,19 +6367,24 @@
# condition.
check_ambiguous_conditional ($var, $cond, $where)
unless (exists $var_value{$var}{$cond}
- && (($var_owner{$var} == VAR_AUTOMAKE
+ && (($var_owner{$var}{$cond} == VAR_AUTOMAKE
&& $owner != VAR_AUTOMAKE)
- || $var_owner{$var} == VAR_CONFIGURE));
+ || $var_owner{$var}{$cond} == VAR_CONFIGURE));
$var_value{$var}{$cond} = $value;
+ # Assignments to a macro set its location. We don't adjust
+ # locations for `+='. Ideally I suppose we would associate
+ # line numbers with random bits of text.
+ $var_location{$var}{$cond} = $where;
}
}
# The owner of a variable can only increase, because an Automake
# variable can be given to the user, but not the converse.
- if (! defined $var_owner{$var} || $owner > $var_owner{$var})
+ if (! exists $var_owner{$var}{$cond}
+ || $owner > $var_owner{$var}{$cond})
{
- $var_owner{$var} = $owner;
+ $var_owner{$var}{$cond} = $owner;
}
# Call var_VAR_trigger if it's defined.
@@ -6389,6 +6417,10 @@
foreach my $cond (@conds)
{
delete $var_value{$var}{$cond};
+ delete $var_location{$var}{$cond};
+ delete $var_owner{$var}{$cond};
+ delete $var_comment{$var}{$cond};
+ delete $var_type{$var}{$cond};
}
}
}
@@ -6407,34 +6439,37 @@
}
else
{
- prog_error ("`$var' is a key in \$var_value, but not in \$var_owner\n")
- unless exists $var_owner{$var};
- my $var_owner;
- if ($var_owner{$var} == VAR_AUTOMAKE)
- {
- $var_owner = 'Automake';
- }
- elsif ($var_owner{$var} == VAR_CONFIGURE)
- {
- $var_owner = 'Configure';
- }
- elsif ($var_owner{$var} == VAR_MAKEFILE)
- {
- $var_owner = 'Makefile';
- }
- else
- {
- prog_error ("unexpected value for `\$var_owner{$var}': "
- . $var_owner{$var})
- unless defined $var_owner;
- }
- my $where = (defined $var_location{$var}
- ? $var_location{$var} : "undefined");
- $text .= "$var_comment{$var}"
- if defined $var_comment{$var};
- $text .= " $var ($var_owner, where = $where) $var_type{$var}=\n {\n";
+ $text .= " $var $var_type{$var}=\n {\n";
foreach my $vcond (sort by_condition keys %{$var_value{$var}})
{
+ prog_error ("`$var' is a key in \$var_value, "
+ . "but not in \$var_owner\n")
+ unless exists $var_owner{$var}{$vcond};
+
+ my $var_owner;
+ if ($var_owner{$var}{$vcond} == VAR_AUTOMAKE)
+ {
+ $var_owner = 'Automake';
+ }
+ elsif ($var_owner{$var}{$vcond} == VAR_CONFIGURE)
+ {
+ $var_owner = 'Configure';
+ }
+ elsif ($var_owner{$var}{$vcond} == VAR_MAKEFILE)
+ {
+ $var_owner = 'Makefile';
+ }
+ else
+ {
+ prog_error ("unexpected value for `\$var_owner{$var}{$vcond}': "
+ . $var_owner{$var}{$vcond})
+ unless defined $var_owner;
+ }
+
+ my $where = (defined $var_location{$var}{$vcond}
+ ? $var_location{$var}{$vcond} : "undefined");
+ $text .= "$var_comment{$var}{$vcond}"
+ if exists $var_comment{$var}{$vcond};
$text .= " $vcond => $var_value{$var}{$vcond}\n";
}
$text .= " }\n";
@@ -6531,7 +6566,7 @@
return 1
if variable_defined $var;
- require_variables ($where, "variable `$var' is used", $var);
+ require_variables ($where, "variable `$var' is used", 'TRUE', $var);
return 0;
}
@@ -7109,13 +7144,16 @@
@conds = keys %{$var_value{$var}}
unless @conds;
- $output_vars .= $var_comment{$var}
- if defined $var_comment{$var};
foreach my $cond (sort by_condition @conds)
{
+ if (exists $var_comment{$var} && exists $var_comment{$var}{$cond})
+ {
+ $output_vars .= $var_comment{$var}{$cond};
+ }
+
my $val = $var_value{$var}{$cond};
- my $equals = $var_type{$var} eq ':' ? ':=' : '=';
+ my $equals = $var_type{$var}{$cond} eq ':' ? ':=' : '=';
my $output_var = "$var $equals $val";
$output_var =~ s/^/make_condition ($cond)/meg;
$output_vars .= $output_var . "\n";
@@ -7134,13 +7172,15 @@
@conds = keys %{$var_value{$var}}
unless @conds;
- $output_vars .= $var_comment{$var}
- if defined $var_comment{$var};
-
foreach my $cond (sort by_condition @conds)
{
+ if (exists $var_comment{$var} && exists $var_comment{$var}{$cond})
+ {
+ $output_vars .= $var_comment{$var}{$cond};
+ }
+
my $val = $var_value{$var}{$cond};
- my $equals = $var_type{$var} eq ':' ? ':=' : '=';
+ my $equals = $var_type{$var}{$cond} eq ':' ? ':=' : '=';
my $make_condition = make_condition ($cond);
$output_vars .= pretty_print_internal ("$make_condition$var $equals",
"$make_condition\t",
@@ -7527,12 +7567,13 @@
# ------------------------------------------------
# Apped $COMMENT to the other comments for $VARIABLE, using
# $SPACING as separator.
-sub append_comments ($$$)
+sub append_comments ($$$$)
{
- my ($var, $spacing, $comment) = @_;
- $var_comment{$var} .= $spacing
- if (!defined $var_comment{$var} || $var_comment{$var} !~ /\n$/o);
- $var_comment{$var} .= $comment;
+ my ($cond, $var, $spacing, $comment) = @_;
+ $var_comment{$var}{$cond} .= $spacing
+ if (!defined $var_comment{$var}{$cond}
+ || $var_comment{$var}{$cond} !~ /\n$/o);
+ $var_comment{$var}{$cond} .= $comment;
}
@@ -7668,7 +7709,8 @@
if (!/\\$/)
{
- append_comments $last_var_name, $spacing, $comment;
+ append_comments ($cond || 'TRUE',
+ $last_var_name, $spacing, $comment);
$comment = $spacing = '';
macro_define ($last_var_name, VAR_MAKEFILE,
$last_var_type, $cond,
@@ -7726,11 +7768,9 @@
if (!/\\$/)
{
- # FIXME: this doesn't always work correctly; it will
- # group all comments for a given variable, no matter
- # where defined.
# Accumulating variables must not be output.
- append_comments $last_var_name, $spacing, $comment;
+ append_comments ($cond || 'TRUE',
+ $last_var_name, $spacing, $comment);
$comment = $spacing = '';
macro_define ($last_var_name, VAR_MAKEFILE,
@@ -7837,16 +7877,25 @@
# then it is now marked as VAR_CONFIGURE or VAR_MAKEFILE.
foreach my $var (uniq @var_list)
{
- variable_output ($var)
- if exists $var_owner{$var} && $var_owner{$var} == VAR_AUTOMAKE;
+ # Some variables, like AMDEPBACKSLASH are in @var_list
+ # but don't have a owner. This is good, because we don't want
+ # to output them.
+ foreach my $cond (keys %{$var_owner{$var}})
+ {
+ variable_output ($var, $cond)
+ if $var_owner{$var}{$cond} == VAR_AUTOMAKE;
+ }
}
# Now dump the user variables that were defined. We do it in the same
# order in which they were defined (skipping duplicates).
foreach my $var (uniq @var_list)
{
- variable_output ($var)
- if exists $var_owner{$var} && $var_owner{$var} != VAR_AUTOMAKE;
+ foreach my $cond (keys %{$var_owner{$var}})
+ {
+ variable_output ($var, $cond)
+ if $var_owner{$var}{$cond} != VAR_AUTOMAKE;
+ }
}
}
@@ -8117,7 +8166,7 @@
$is_rule = 0;
# Accumulating variables must not be output.
- append_comments $var, $spacing, $comment;
+ append_comments ($cond || 'TRUE', $var, $spacing, $comment);
macro_define ($var, $is_am ? VAR_AUTOMAKE : VAR_MAKEFILE,
$type, $cond, $val, $file)
if $cond ne 'FALSE';
@@ -8127,8 +8176,9 @@
# of (which is detected by the first reading of
# `header-vars.am'), we must not output them.
$result_vars .= "$spacing$comment$_\n"
- if ($type ne '+' && exists $var_owner{$var}
- && $var_owner{$var} == VAR_AUTOMAKE && $cond ne 'FALSE');
+ if ($cond ne 'FALSE' && $type ne '+'
+ && exists $var_owner{$var}{$cond || 'TRUE'}
+ && $var_owner{$var}{$cond || 'TRUE'} == VAR_AUTOMAKE);
$comment = $spacing = '';
}
@@ -8277,9 +8327,12 @@
# Autoconf can also define variables like INSTALL_DATA, so
# ignore all configure variables (at least those which are not
# redefined in Makefile.am).
+ # FIXME: We should make sure that these variables are not
+ # conditionally defined (or else adjust the condition below).
next
if (exists $var_owner{$varname}
- && $var_owner{$varname} != VAR_MAKEFILE);
+ && exists $var_owner{$varname}{'TRUE'}
+ && $var_owner{$varname}{'TRUE'} != VAR_MAKEFILE);
if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
{
@@ -8711,12 +8764,12 @@
require_file_internal ($where, $mystrict, @files);
}
-# &require_file_with_macro ($MACRO, $MYSTRICT, @FILES)
-# ----------------------------------------------------
-sub require_file_with_macro ($$@)
+# &require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
+# -----------------------------------------------------------
+sub require_file_with_macro ($$$@)
{
- my ($macro, $mystrict, @files) = @_;
- require_file ($var_location{$macro}, $mystrict, @files);
+ my ($cond, $macro, $mystrict, @files) = @_;
+ require_file ($var_location{$macro}{$cond}, $mystrict, @files);
}
@@ -8735,12 +8788,12 @@
}
-# &require_conf_file_with_macro ($MACRO, $MYSTRICT, @FILES)
-# ---------------------------------------------------------
-sub require_conf_file_with_macro ($$@)
+# &require_conf_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
+# ----------------------------------------------------------------
+sub require_conf_file_with_macro ($$$@)
{
- my ($macro, $mystrict, @files) = @_;
- require_conf_file ($var_location{$macro}, $mystrict, @files);
+ my ($cond, $macro, $mystrict, @files) = @_;
+ require_conf_file ($var_location{$macro}{$cond}, $mystrict, @files);
}
################################################################
@@ -8870,15 +8923,15 @@
################################################################
# INTEGER
-# require_variables ($WHERE, $REASON, @VARIABLES)
-# -----------------------------------------------
-# Make sure that each supplied variable is defined.
+# require_variables ($WHERE, $REASON, $COND, @VARIABLES)
+# ------------------------------------------------------
+# Make sure that each supplied variable is defined in $COND.
# Otherwise, issue a warning. If we know which macro can
# define this variable, hint the user.
# Return the number of undefined variables.
-sub require_variables ($$@)
+sub require_variables ($$$@)
{
- my ($where, $reason, @vars) = @_;
+ my ($where, $reason, $cond, @vars) = @_;
my $res = 0;
$reason .= ' but ' unless $reason eq '';
@@ -8887,7 +8940,8 @@
# Nothing to do if the variable exists. The $configure_vars test
# needed for strange variables like AMDEPBACKSLASH or ANSI2KNR
# that are AC_SUBST'ed but never macro_define'd.
- next if (exists $var_value{$var} || exists $configure_vars{$var});
+ next if ((exists $var_value{$var} && exists $var_value{$var}{$cond})
+ || exists $configure_vars{$var});
++$res;
@@ -8917,7 +8971,11 @@
sub require_variables_for_macro ($$@)
{
my ($macro, $reason, @args) = @_;
- return require_variables ($var_location{$macro}, $reason, @args);
+ for my $cond (keys %{$var_value{$macro}})
+ {
+ return require_variables ($var_location{$macro}{$cond}, $reason,
+ $cond, @args);
+ }
}
# Print usage information.
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.439
diff -u -r1.439 Makefile.am
--- tests/Makefile.am 17 Sep 2002 20:53:09 -0000 1.439
+++ tests/Makefile.am 18 Sep 2002 18:38:01 -0000
@@ -64,6 +64,7 @@
comment4.test \
comment5.test \
comment6.test \
+comment7.test \
compile_f_c_cxx.test \
cond.test \
cond2.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.566
diff -u -r1.566 Makefile.in
--- tests/Makefile.in 17 Sep 2002 20:53:09 -0000 1.566
+++ tests/Makefile.in 18 Sep 2002 18:38:03 -0000
@@ -155,6 +155,7 @@
comment4.test \
comment5.test \
comment6.test \
+comment7.test \
compile_f_c_cxx.test \
cond.test \
cond2.test \
Index: tests/comment7.test
===================================================================
RCS file: tests/comment7.test
diff -N tests/comment7.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/comment7.test 18 Sep 2002 18:38:03 -0000
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2002 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with autoconf; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Make sure comment for conditional variables are output near the
+# corresponding conditional definitions.
+
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in <<'EOF'
+AM_CONDITIONAL([COND], [true])
+EOF
+
+cat > Makefile.am << 'EOF'
+if COND
+# Comment for VAR in COND_TRUE.
+VAR = foo
+else
+# Comment for VAR in COND_FALSE.
+VAR = bar
+endif
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+
+# The VAR definition appears once for each condition.
+test `grep '@address@hidden' Makefile.in | wc -l` = 1
+test `grep '@address@hidden' Makefile.in | wc -l` = 1
+
+# Make sure the right definition follows each comment.
+sed -n '/^#.*VAR.*COND_TRUE/ { n; p; }' Makefile.in |
+ grep '@address@hidden = foo'
+sed -n '/^#.*VAR.*COND_FALSE/ { n; p; }' Makefile.in |
+ grep '@address@hidden = bar'
--
Alexandre Duret-Lutz