[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FYI: 6/ Automake::Variable & Automake::VarDef
From: |
Alexandre Duret-Lutz |
Subject: |
Re: FYI: 6/ Automake::Variable & Automake::VarDef |
Date: |
Wed, 18 Jun 2003 22:19:41 +0200 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) |
>>> "adl" == Alexandre Duret-Lutz <address@hidden> writes:
[...]
Hari> Can we eliminate the use of 'variable_defined' and just
Hari> use 'var' in there?
adl> Yes, that sounds sensible.
adl> Perhaps it would also be a good reason to drop the
adl> "rule-vs-variable" diagnostic (which is currently commented out
adl> in variable_defined). This diagnostics only causes
adl> implementations issues, and I suspect it doesn't help anybody.
Here is my attempt at doing so. I'm not as satisfied as I
thought I would.
First, the old `variable_defined' really did two things:
(1) telling whether a variable exists
(2) marking a variable as examined (in one condition if given,
or all conditions otherwise).
(1) can easily be replaced by `var', but (2) cannot be merged in
Indeed, var/rvar is the main access to all variables; marking FOO
as examined in condition 'C1' should be done with
rvar ('FOO')->rdef ('C1')->set_seen
but that would be meaningless if rvar('FOO') already had marked
'FOO' as examined in all conditions.
What I've done is moving (2) into a separate function, Variable::set_seen,
so you can call
rvar ('FOO')->set_seen
to mark a variable as examined in all conditions.
However, since in many places I had to replace
if (variable_defined ('some_SOURCES'))
...
by
my $var = var 'some_SOURCES';
if ($var)
{
$var->set_seen;
...
I thought life would be easier if set_seen could be called on
undefined variables, so that I would just write
if (set_seen ('some_SOURCES'))
...
Now, it looks like I'm back to the beginning, having just
renamed variable_defined into set_seen. That's partly true, and
that's why I'm baffled by this change. That's partly wrong too:
by replacing variable_defined by either `var' or `set_seen', the
code is now more clear about which variables need to be marked
as examined.
Comments?
The patch also removes a few useless statements, changes two
places to use require_variables_for_variable (I still have to
write a test case for the ALLOCA diagnostic), and reindent a
couple of functions (I'm posting the diff -b though, so you'll
only see weird spacing).
2003-06-18 Alexandre Duret-Lutz <address@hidden>
* lib/Automake/Variable.pm (vardef, rvardef, set_seen): New functions.
(variable_defined, examine_variable): Remove.
(%_ac_macro_for_var): Add an entry for ALLOCA.
(require_variables): Use verdef instead of variable_defined.
* automake.in (generate_makefile): Do not push $(SOURCE) into
@sources. Use define_pretty_variable to define SOURCES.
(handle_LIBOBJS, handle_ALLOCA): Use require_variables_for_variable
to require LIBOBJS, LTLIBOBJS and ALLOCA.
(handle_programs, handle_ltlibraries): Do not define an empty
_DEPENDENCIES or _LDFLAGS variable when none is defined.
(define_configure_variable): Do not check whether the variable
already exists (it's Automake::Variable::define's job).
(require_build_directory): Likewise, do not check
the existence of am__dirstamp.
(generate_makefile, handle_options, handle_languages)
(check_libobjs_sources, handle_single_transform_list)
(traverse_variable_recursively_worker, handle_source_transform)
(handle_lib_objects, handle_LIBOBJS, handle_compile)
(handle_libtool, handle_programs, handle_libraries)
(handle_ltlibraries, check_typos, handle_texinfo_helper)
(handle_man_pages, handle_tags, handle_dist, handle_subdirs)
(scan_aclocal_m4, handle_gettext, handle_footer, handle_install)
(handle_all, do_check_merge_target, handle_clean, lang_c_finish)
(handle_tests, lang_yacc_target_hook, define_pretty_variable)
(define_compiler_variable, define_linker_variable)
(make_paragraphs, am_primary_prefixes, am_install_var): Adjust to
call var, vardef, or set_seen, instead of variable_defined. Use
set_seen only for variables which are actually checked by
check_typos.
* tests/target.test: Delete.
* tests/Makefile.am (TESTS, XFAIL_TESTS): Remove target.test.
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1467
diff -u -b -r1.1467 automake.in
--- automake.in 15 Jun 2003 17:35:50 -0000 1.1467
+++ automake.in 18 Jun 2003 20:15:00 -0000
@@ -1229,7 +1229,7 @@
# Catch some obsolete variables.
msg_var ('obsolete', 'INCLUDES',
"`INCLUDES' is the old name for `AM_CPPFLAGS'")
- if variable_defined ('INCLUDES');
+ if var ('INCLUDES');
# At the toplevel directory, we might need config.guess, config.sub
# or libtool scripts (ltconfig and ltmain.sh).
@@ -1251,9 +1251,6 @@
&push_dist_common ($in_file_name, $am_file_name);
}
- push (@sources, '$(SOURCES)')
- if variable_defined ('SOURCES');
-
# Must do this after reading .am file.
&define_variable ('subdir', $relative_dir, INTERNAL);
@@ -1280,10 +1277,8 @@
# We have to run this after dealing with all the programs.
&handle_libtool;
- # Re-init SOURCES. FIXME: other code shouldn't depend on this
- # (but currently does).
- Automake::Variable::define ('SOURCES', VAR_AUTOMAKE, '', TRUE,
- "@sources", '', INTERNAL, VAR_PRETTY);
+ # Variables used by distdir.am and tags.am.
+ define_pretty_variable ('SOURCES', TRUE, INTERNAL, @sources);
define_pretty_variable ('DIST_SOURCES', TRUE, INTERNAL, @dist_sources);
&handle_multilib;
@@ -1307,8 +1302,7 @@
&handle_all ($output);
# FIXME: Gross!
- if (variable_defined ('lib_LTLIBRARIES') &&
- variable_defined ('bin_PROGRAMS'))
+ if (var ('lib_LTLIBRARIES') && var ('bin_PROGRAMS'))
{
$output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
}
@@ -1455,7 +1449,7 @@
return 1;
}
- if (variable_defined ('AUTOMAKE_OPTIONS'))
+ if (var ('AUTOMAKE_OPTIONS'))
{
if (&process_option_list (0, &variable_value_as_list_recursive
('AUTOMAKE_OPTIONS', TRUE)))
{
@@ -1644,7 +1638,7 @@
{
my $val = "${derived}_$flag";
$obj_compile =~ s/\(AM_$flag\)/\($val\)/
- if variable_defined ($val);
+ if set_seen ($val);
}
my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
@@ -1857,11 +1851,11 @@
'dist_EXTRA_', 'nodist_EXTRA_')
{
my @files;
- if (variable_defined ($prefix . $one_file . '_SOURCES'))
+ my $varname = $prefix . $one_file . '_SOURCES';
+ my $var = var ($varname);
+ if ($var)
{
- @files = &variable_value_as_list_recursive (
- ($prefix . $one_file . '_SOURCES'),
- 'all');
+ @files = &variable_value_as_list_recursive ($varname, 'all');
}
elsif ($prefix eq '')
{
@@ -1988,7 +1982,7 @@
my $have_per_exec_flags = 0;
foreach my $flag (@{$lang->flags})
{
- if (variable_defined ("${derived}_$flag"))
+ if (set_seen ("${derived}_$flag"))
{
$have_per_exec_flags = 1;
last;
@@ -2011,13 +2005,14 @@
# override.
my $dname = $derived;
- if (variable_defined ($derived . '_SHORTNAME'))
+ my $var = var ($derived . '_SHORTNAME');
+ if ($var)
{
# FIXME: should use the same Condition as
# the _SOURCES variable. But this is really
# silly overkill -- nobody should have
# conditional shortnames.
- $dname = &variable_value ($derived . '_SHORTNAME');
+ $dname = $var->variable_value;
}
$object = $dname . '-' . $object;
@@ -2266,9 +2261,11 @@
{
my ($var, $parent, $fun_item, $fun_collect, $cond_filter, $parent_cond) = @_;
- # Don't recurse into undefined variables.
- # This will also mark existing variables as examined.
- return () if ! variable_defined ($var);
+ # Don't recurse into undefined variables and mark
+ # existing variable as examined.
+ my $v = set_seen $var;
+ return ()
+ unless $v;
if (defined $vars_scanned{$var})
{
@@ -2279,7 +2276,6 @@
my @allresults = ();
my $cond_once = 0;
- my $v = rvar $var;
foreach my $cond ($v->conditions->conds)
{
if (ref $cond_filter)
@@ -2532,9 +2528,9 @@
foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
'dist_EXTRA_', 'nodist_EXTRA_')
{
- my $var = $prefix . $one_file . "_SOURCES";
- next
- if !variable_defined ($var);
+ my $varname = $prefix . $one_file . "_SOURCES";
+ my $var = var $varname;
+ next unless $var;
# We are going to define _OBJECTS variables using the prefix.
# Then we glom them all together. So we can't use the null
@@ -2545,29 +2541,29 @@
$used_pfx{$xpfx} = 1
unless $prefix =~ /EXTRA_/;
- push @sources, "\$($var)";
+ push @sources, "\$($varname)";
if ($prefix !~ /^nodist_/)
{
# If the VAR wasn't definined conditionally, we add
# it to DIST_SOURCES as is. Otherwise we create a
# am__VAR_DIST variable which contains all possible values,
# and add this variable to DIST_SOURCES.
- my $distvar = "$var";
- if (variable_conditionally_defined ($var))
+ my $distvar = $varname;
+ if (variable_conditionally_defined ($varname))
{
- $distvar = "am__${var}_DIST";
+ $distvar = "am__${varname}_DIST";
my @files =
- uniq (variable_value_as_list_recursive ($var, 'all'));
+ uniq (variable_value_as_list_recursive ($varname, 'all'));
define_pretty_variable ($distvar, TRUE, $where, @files);
}
push @dist_sources, "\$($distvar)"
}
$needlinker |=
- define_objects_from_sources ($var,
+ define_objects_from_sources ($varname,
$xpfx . $one_file . '_OBJECTS',
$prefix =~ /EXTRA_/,
- $one_file, $obj, $var, $where);
+ $one_file, $obj, $varname, $where);
}
if ($needlinker)
{
@@ -2616,19 +2612,21 @@
# Returns 1 if LIBOBJS seen, 0 otherwise.
sub handle_lib_objects
{
- my ($xname, $var) = @_;
+ my ($xname, $varname) = @_;
- prog_error "handle_lib_objects: `$var' undefined"
- if ! variable_defined ($var);
- prog_error ("handle_lib_objects: unexpected variable name `$var'")
- unless $var =~ /^(.*)(?:LIB|LD)ADD$/;
+ my $var = var ($varname);
+ prog_error "handle_lib_objects: `$varname' undefined"
+ unless $var;
+ prog_error "handle_lib_objects: unexpected variable name `$varname'"
+ unless $varname =~ /^(.*)(?:LIB|LD)ADD$/;
my $prefix = $1 || 'AM_';
my $seen_libobjs = 0;
my $flagvar = 0;
transform_variable_recursively
- ($var, $xname . '_DEPENDENCIES', 'am__DEPENDENCIES', ! $xname, INTERNAL,
+ ($varname, $xname . '_DEPENDENCIES', 'am__DEPENDENCIES',
+ ! $xname, INTERNAL,
# Transformation function, run on each filename.
sub {
my ($subvar, $val, $cond, $full_cond) = @_;
@@ -2692,10 +2690,11 @@
$lt ||= '';
my $myobjext = ($1 ? 'l' : '') . 'o';
- if (! keys %libsources && ! variable_defined ($lt . 'LIBOBJS'))
+ if (! keys %libsources)
{
- err_var ($var, "address@hidden@ seen but never set in "
- . "`$configure_ac'");
+ require_variables_for_variable ($var,
+ "address@hidden@ used",
+ $lt . 'LIBOBJS');
}
foreach my $iter (keys %libsources)
@@ -2717,7 +2716,7 @@
$dep_files{'$(DEPDIR)/' . $rewrite} = 1;
$rewrite = "^" . quotemeta ($iter) . "\$";
# Only require the file if it is not a built source.
- if (! variable_defined ('BUILT_SOURCES')
+ if (! var ('BUILT_SOURCES')
|| ! grep (/$rewrite/,
&variable_value_as_list_recursive ('BUILT_SOURCES',
'all')))
@@ -2733,9 +2732,8 @@
my ($var, $cond, $lt) = @_;
my $myobjext = ($1 ? 'l' : '') . 'o';
- err_var ($var, "address@hidden@ seen but `AC_FUNC_ALLOCA' not in "
- . "`$configure_ac'")
- if ! defined $libsources{'alloca.c'};
+ require_variables_for_variable ($var, "address@hidden@ used",
+ $lt . 'ALLOCA');
$dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
require_file_with_macro ($cond, $var, FOREIGN, 'alloca.c');
&saw_extension ('c');
@@ -2783,9 +2781,10 @@
{
$default_includes = ' -I. -I$(srcdir)';
- if (variable_defined ('CONFIG_HEADER'))
+ my $var = var 'CONFIG_HEADER';
+ if ($var)
{
- foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
+ foreach my $hdr (split (' ', $var->variable_value))
{
$default_includes .= ' -I' . dirname ($hdr);
}
@@ -2855,7 +2854,7 @@
# Handle libtool rules.
sub handle_libtool
{
- return unless variable_defined ('LIBTOOL');
+ return unless var ('LIBTOOL');
# Libtool requires some files, but only at top level.
require_conf_file_with_macro (TRUE, 'LIBTOOL', FOREIGN, @libtool_files)
@@ -2886,7 +2885,7 @@
return if ! @proglist;
my $seen_global_libobjs =
- variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD');
+ var ('LDADD') && &handle_lib_objects ('', 'LDADD');
foreach my $pair (@proglist)
{
@@ -2910,11 +2909,9 @@
my $linker = &handle_source_transform ($xname, $one_file, $obj, $where);
- my $xt = '';
- if (variable_defined ($xname . "_LDADD"))
+ if (var ($xname . "_LDADD"))
{
$seen_libobjs = &handle_lib_objects ($xname, $xname . '_LDADD');
- $xt = '_LDADD';
}
else
{
@@ -2923,29 +2920,21 @@
# This does a bit too much work. But we need it to
# generate _DEPENDENCIES when appropriate.
- if (variable_defined ('LDADD'))
+ if (var ('LDADD'))
{
$seen_libobjs = &handle_lib_objects ($xname, 'LDADD');
}
- elsif (! variable_defined ($xname . '_DEPENDENCIES'))
- {
- &define_variable ($xname . '_DEPENDENCIES', '', $where);
- }
- $xt = '_SOURCES';
}
reject_var ($xname . '_LIBADD',
"use `${xname}_LDADD', not `${xname}_LIBADD'");
- if (! variable_defined ($xname . '_LDFLAGS'))
- {
- # Define the prog_LDFLAGS variable.
- &define_variable ($xname . '_LDFLAGS', '', $where);
- }
+ set_seen ($xname . '_DEPENDENCIES');
+ set_seen ($xname . '_LDFLAGS');
# Determine program to use for link.
my $xlink;
- if (variable_defined ($xname . '_LINK'))
+ if (var ($xname . '_LINK'))
{
$xlink = $xname . '_LINK';
}
@@ -2968,11 +2957,11 @@
if ($seen_libobjs || $seen_global_libobjs)
{
- if (variable_defined ($xname . '_LDADD'))
+ if (var ($xname . '_LDADD'))
{
&check_libobjs_sources ($xname, $xname . '_LDADD');
}
- elsif (variable_defined ('LDADD'))
+ elsif (var ('LDADD'))
{
&check_libobjs_sources ($xname, 'LDADD');
}
@@ -3018,14 +3007,14 @@
'_OBJECTS', '_DEPENDENCIES',
'_AR');
- if (! variable_defined ($xlib . '_AR'))
+ if (! var ($xlib . '_AR'))
{
&define_variable ($xlib . '_AR', '$(AR) $(ARFLAGS)', $where);
}
# Generate support for conditional object inclusion in
# libraries.
- if (variable_defined ($xlib . '_LIBADD'))
+ if (var ($xlib . '_LIBADD'))
{
if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
{
@@ -3041,7 +3030,7 @@
"use `${xlib}_LIBADD', not `${xlib}_LDADD'");
# Make sure we at look at this.
- &examine_variable ($xlib . '_DEPENDENCIES');
+ set_seen ($xlib . '_DEPENDENCIES');
&handle_source_transform ($xlib, $onelib, $obj, $where);
@@ -3057,7 +3046,7 @@
if ($seen_libobjs)
{
- if (variable_defined ($xlib . '_LIBADD'))
+ if (var ($xlib . '_LIBADD'))
{
&check_libobjs_sources ($xlib, $xlib . '_LIBADD');
}
@@ -3139,11 +3128,11 @@
# Check that the library fits the standard naming convention.
my $libname_rx = "^lib.*\.la";
- if ((variable_defined ($xlib . '_LDFLAGS')
+ if ((var ($xlib . '_LDFLAGS')
&& grep (/-module/,
&variable_value_as_list_recursive ($xlib . '_LDFLAGS',
'all')))
- || (variable_defined ('LDFLAGS')
+ || (var ('LDFLAGS')
&& grep (/-module/,
&variable_value_as_list_recursive ('LDFLAGS', 'all'))))
{
@@ -3159,15 +3148,13 @@
$where->push_context ("while processing Libtool library `$onelib'");
$where->set (INTERNAL->get);
- if (! variable_defined ($xlib . '_LDFLAGS'))
- {
- # Define the lib_LDFLAGS variable.
- &define_variable ($xlib . '_LDFLAGS', '', $where);
- }
+ # Make sure we at look at these.
+ set_seen ($xlib . '_LDFLAGS');
+ set_seen ($xlib . '_DEPENDENCIES');
# Generate support for conditional object inclusion in
# libraries.
- if (variable_defined ($xlib . '_LIBADD'))
+ if (var ($xlib . '_LIBADD'))
{
if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
{
@@ -3182,14 +3169,12 @@
reject_var ("${xlib}_LDADD",
"use `${xlib}_LIBADD', not `${xlib}_LDADD'");
- # Make sure we at look at this.
- &examine_variable ($xlib . '_DEPENDENCIES');
my $linker = &handle_source_transform ($xlib, $onelib, $obj, $where);
# Determine program to use for link.
my $xlink;
- if (variable_defined ($xlib . '_LINK'))
+ if (var ($xlib . '_LINK'))
{
$xlink = $xlib . '_LINK';
}
@@ -3232,7 +3217,7 @@
DIRSTAMP => $dirstamp);
if ($seen_libobjs)
{
- if (variable_defined ($xlib . '_LIBADD'))
+ if (var ($xlib . '_LIBADD'))
{
&check_libobjs_sources ($xlib, $xlib . '_LIBADD');
}
@@ -3244,7 +3229,7 @@
sub check_typos ()
{
# It is ok if the user sets this particular variable.
- &examine_variable ('AM_LDFLAGS');
+ set_seen 'AM_LDFLAGS';
foreach my $varname (variables)
{
@@ -3455,7 +3440,7 @@
reject_var 'TEXINFOS', "`TEXINFOS' is an anachronism; use `info_TEXINFOS'";
reject_var 'html_TEXINFOS', "HTML generation not yet supported";
- return (0, '') if ! variable_defined ('info_TEXINFOS');
+ return (0, '') unless var ('info_TEXINFOS');
my @texis = &variable_value_as_list_recursive ('info_TEXINFOS', 'all');
@@ -3499,7 +3484,7 @@
push (@texi_deps, "$outdir$vtexi") if $vtexi;
my $canonical = &canonicalize ($infobase);
- if (variable_defined ($canonical . "_TEXINFOS"))
+ if (var ($canonical . "_TEXINFOS"))
{
push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
&push_dist_common ('$(' . $canonical . '_TEXINFOS)');
@@ -3576,7 +3561,7 @@
&define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL);
$need_texi_file = 2; # so that we require_conf_file later
}
- elsif (variable_defined ('TEXINFO_TEX'))
+ elsif (var ('TEXINFO_TEX'))
{
# The user defined TEXINFO_TEX so assume he knows what he is
# doing.
@@ -3661,20 +3646,22 @@
# Add more sections as needed.
foreach my $section ('0'..'9', 'n', 'l')
{
- if (variable_defined ($pfx . 'man' . $section . '_MANS'))
+ my $varname = $pfx . 'man' . $section . '_MANS';
+ if (var ($varname))
{
$sections{$section} = 1;
- $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
+ $varname = '$(' . $varname . ')';
+ $vlist{$varname} = 1;
- &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
+ &push_dist_common ($varname)
if $pfx eq 'dist_';
}
}
- if (variable_defined ($pfx . 'man_MANS'))
+ my $varname = $pfx . 'man_MANS';
+ if (var ($varname))
{
- $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
- foreach (&variable_value_as_list_recursive ($pfx . 'man_MANS',
'all'))
+ foreach (&variable_value_as_list_recursive ($varname, 'all'))
{
# A page like `foo.1c' goes into man1dir.
if (/\.([0-9a-z])([a-z]*)$/)
@@ -3683,7 +3670,9 @@
}
}
- &push_dist_common ('$(' . $pfx . 'man_MANS)')
+ $varname = '$(' . $varname . ')';
+ $vlist{$varname} = 1;
+ &push_dist_common ($varname)
if $pfx eq 'dist_';
}
}
@@ -3723,7 +3712,7 @@
{
my @tag_deps = ();
my @ctag_deps = ();
- if (variable_defined ('SUBDIRS'))
+ if (var ('SUBDIRS'))
{
$output_rules .= ("tags-recursive:\n"
. "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do
\\\n"
@@ -3747,7 +3736,7 @@
}
if (&saw_sources_p (1)
- || variable_defined ('ETAGS_ARGS')
+ || var ('ETAGS_ARGS')
|| @tag_deps)
{
my @config;
@@ -3767,7 +3756,8 @@
CONFIG => "@config",
TAGSDIRS => "@tag_deps",
CTAGSDIRS => "@ctag_deps");
- &examine_variable ('TAGS_DEPENDENCIES');
+
+ set_seen 'TAGS_DEPENDENCIES';
}
elsif (reject_var ('TAGS_DEPENDENCIES',
"doesn't make sense to define `TAGS_DEPENDENCIES'"
@@ -3898,7 +3888,7 @@
# subdir. If so, add it to the list. I didn't want to do this
# originally, but there were so many requests that I finally
# relented.
- if (variable_defined ('EXTRA_DIST'))
+ if (var ('EXTRA_DIST'))
{
# FIXME: This should be fixed to work with conditions. That
# will require only making the entries in %dist_dirs under the
@@ -3939,7 +3929,7 @@
# If we have SUBDIRS, create all dist subdirectories and do
# recursive build.
- if (variable_defined ('SUBDIRS'))
+ if (var ('SUBDIRS'))
{
# If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
# to all possible directories, and use it. If DIST_SUBDIRS is
@@ -3949,17 +3939,17 @@
# one project uses so many conditional subdirectories that
# calling variable_conditionally_defined on SUBDIRS will cause
# automake to grow to 150Mb. Sigh.
- if (variable_defined ('DIST_SUBDIRS')
- || variable_conditionally_defined ('SUBDIRS'))
+ if (var ('DIST_SUBDIRS'))
{
$dist_subdir_name = 'DIST_SUBDIRS';
- if (! variable_defined ('DIST_SUBDIRS'))
+ }
+ elsif (variable_conditionally_defined ('SUBDIRS'))
{
+ $dist_subdir_name = 'DIST_SUBDIRS';
define_pretty_variable
('DIST_SUBDIRS', TRUE, INTERNAL,
uniq (&variable_value_as_list_recursive ('SUBDIRS', 'all')));
}
- }
else
{
$dist_subdir_name = 'SUBDIRS';
@@ -3989,12 +3979,12 @@
sub handle_subdirs
{
return
- unless variable_defined ('SUBDIRS');
+ unless var ('SUBDIRS');
my @subdirs = &variable_value_as_list_recursive ('SUBDIRS', 'all');
my @dsubdirs = ();
@dsubdirs = &variable_value_as_list_recursive ('DIST_SUBDIRS', 'all')
- if variable_defined ('DIST_SUBDIRS');
+ if var ('DIST_SUBDIRS');
# If an `obj/' directory exists, BSD make will enter it before
# reading `Makefile'. Hence the `Makefile' in the current directory
@@ -4049,8 +4039,8 @@
{
my $regen_aclocal = 0;
- &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
- &examine_variable ('CONFIGURE_DEPENDENCIES');
+ set_seen 'CONFIG_STATUS_DEPENDENCIES';
+ set_seen 'CONFIGURE_DEPENDENCIES';
if (-f 'aclocal.m4')
{
@@ -4065,7 +4055,7 @@
my @ac_deps = ();
- if (variable_defined ('ACLOCAL_M4_SOURCES'))
+ if (set_seen ('ACLOCAL_M4_SOURCES'))
{
push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
msg_var ('obsolete', 'ACLOCAL_M4_SOURCES',
@@ -4377,7 +4367,7 @@
{
return if ! $seen_gettext || $relative_dir ne '.';
- if (! variable_defined ('SUBDIRS'))
+ if (! var ('SUBDIRS'))
{
err_ac "AM_GNU_GETTEXT used but SUBDIRS not defined";
return;
@@ -4440,7 +4430,7 @@
# before .SUFFIXES. So we make sure that .SUFFIXES appears before
# anything else, by sticking it right after the default: target.
$output_header .= ".SUFFIXES:\n";
- if (@suffixes || variable_defined ('SUFFIXES'))
+ if (@suffixes || var ('SUFFIXES'))
{
# Make sure suffixes has unique elements. Sort them to ensure
# the output remains consistent. However, $(SUFFIXES) is
@@ -4449,7 +4439,7 @@
# suffixes, and this lets the user have some control. Push
# actual suffixes, and not $(SUFFIXES). Some versions of make
# do not like variable substitutions on the .SUFFIXES line.
- my @user_suffixes = (variable_defined ('SUFFIXES')
+ my @user_suffixes = (var ('SUFFIXES')
? &variable_value_as_list_recursive ('SUFFIXES',
'all')
: ());
@@ -4472,7 +4462,7 @@
$output_rules .= &file_contents
('install',
new Automake::Location,
- maybe_BUILT_SOURCES => (variable_defined ('BUILT_SOURCES')
+ maybe_BUILT_SOURCES => (set_seen ('BUILT_SOURCES')
? (" \$(BUILT_SOURCES)\n"
. "\t\$(MAKE) \$(AM_MAKEFLAGS)")
: ''),
@@ -4516,7 +4506,7 @@
my @local_headers = ();
push @local_headers, '$(BUILT_SOURCES)'
- if variable_defined ('BUILT_SOURCES');
+ if var ('BUILT_SOURCES');
foreach my $spec (@config_headers)
{
my ($out, @ins) = split_config_file_spec ($spec);
@@ -4535,13 +4525,12 @@
$output_all .= ("all: @local_headers"
. "\n\t"
. '$(MAKE) $(AM_MAKEFLAGS) '
- . (variable_defined ('SUBDIRS')
- ? 'all-recursive' : 'all-am')
+ . (var ('SUBDIRS') ? 'all-recursive' : 'all-am')
. "\n\n");
}
else
{
- $output_all .= "all: " . (variable_defined ('SUBDIRS')
+ $output_all .= "all: " . (var ('SUBDIRS')
? 'all-recursive' : 'all-am') . "\n\n";
}
}
@@ -4580,11 +4569,10 @@
&depend ('.PHONY', 'check', 'check-am');
# Handle recursion. We have to honor BUILT_SOURCES like for `all:'.
$output_rules .= ("check: "
- . (variable_defined ('BUILT_SOURCES')
+ . (var ('BUILT_SOURCES')
? "\$(BUILT_SOURCES)\n\t\$(MAKE) \$(AM_MAKEFLAGS) "
: '')
- . (variable_defined ('SUBDIRS')
- ? 'check-recursive' : 'check-am')
+ . (var ('SUBDIRS') ? 'check-recursive' : 'check-am')
. "\n");
}
@@ -4593,17 +4581,17 @@
{
# Clean the files listed in user variables if they exist.
$clean_files{'$(MOSTLYCLEANFILES)'} = MOSTLY_CLEAN
- if variable_defined ('MOSTLYCLEANFILES');
+ if var ('MOSTLYCLEANFILES');
$clean_files{'$(CLEANFILES)'} = CLEAN
- if variable_defined ('CLEANFILES');
+ if var ('CLEANFILES');
$clean_files{'$(DISTCLEANFILES)'} = DIST_CLEAN
- if variable_defined ('DISTCLEANFILES');
+ if var ('DISTCLEANFILES');
$clean_files{'$(MAINTAINERCLEANFILES)'} = MAINTAINER_CLEAN
- if variable_defined ('MAINTAINERCLEANFILES');
+ if var ('MAINTAINERCLEANFILES');
# Built sources are automatically removed by maintainer-clean.
$clean_files{'$(BUILT_SOURCES)'} = MAINTAINER_CLEAN
- if variable_defined ('BUILT_SOURCES');
+ if var ('BUILT_SOURCES');
# Compute a list of "rm"s to run for each target.
my %rms = (MOSTLY_CLEAN, [],
@@ -4771,7 +4759,7 @@
}
}
- if (variable_defined ('TESTS'))
+ if (var ('TESTS'))
{
push (@check_tests, 'check-TESTS');
$output_rules .= &file_contents ('check', new Automake::Location);
@@ -5394,7 +5382,7 @@
. " || rm -f address@hidden");
push (@objects, $base . '_.$(OBJEXT)');
push (@objects, $base . '_.lo')
- if variable_defined ('LIBTOOL');
+ if var ('LIBTOOL');
}
# Make all _.o (and _.lo) files depend on ansi2knr.
@@ -5410,10 +5398,10 @@
my ($self, $aggregate, $output, $input) = @_;
my $flag = $aggregate . "_YFLAGS";
- if ((variable_defined ($flag)
- && &variable_value ($flag) =~ /$DASH_D_PATTERN/o)
- || (variable_defined ('YFLAGS')
- && &variable_value ('YFLAGS') =~ /$DASH_D_PATTERN/o))
+ my $flagvar = var $flag;
+ my $YFLAGSvar = var 'YFLAGS';
+ if (($flagvar && $flagvar->variable_value =~ /$DASH_D_PATTERN/o)
+ || ($YFLAGSvar && $YFLAGSvar->variable_value =~ /$DASH_D_PATTERN/o))
{
(my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//;
my $header = $output_base . '.h';
@@ -5866,7 +5854,7 @@
{
my ($var, $cond, $where, @value) = @_;
- if (! variable_defined ($var, $cond))
+ if (! vardef ($var, $cond))
{
Automake::Variable::define ($var, VAR_AUTOMAKE, '', $cond, "@value",
'', $where, VAR_PRETTY);
@@ -5890,8 +5878,7 @@
sub define_configure_variable ($)
{
my ($var) = @_;
- if (! variable_defined ($var, TRUE))
- {
+
my $pretty = VAR_ASIS;
my $owner = VAR_CONFIGURE;
@@ -5908,7 +5895,6 @@
Automake::Variable::define ($var, $owner, '', TRUE, subst $var,
'', $configure_vars{$var}, $pretty);
- }
}
@@ -5923,7 +5909,7 @@
my ($var, $value) = ($lang->compiler, $lang->compile);
&define_variable ($var, $value, INTERNAL);
&define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value", INTERNAL)
- if variable_defined ('LIBTOOL');
+ if var ('LIBTOOL');
}
@@ -5939,8 +5925,7 @@
&define_variable ($lang->lder, $lang->ld, INTERNAL);
# CCLINK = $(CCLD) blah blah...
&define_variable ($lang->linker,
- ((variable_defined ('LIBTOOL')
- ? '$(LIBTOOL) --mode=link ' : '')
+ ((var ('LIBTOOL') ? '$(LIBTOOL) --mode=link ' : '')
. $lang->link),
INTERNAL);
}
@@ -6667,7 +6652,7 @@
'INSTALL-MAN' => !$options{'no-installman'},
'CK-NEWS' => $options{'check-news'} || 0,
- 'SUBDIRS' => variable_defined ('SUBDIRS'),
+ 'SUBDIRS' => !! var ('SUBDIRS'),
'TOPDIR' => backname ($relative_dir),
'TOPDIR_P' => $relative_dir eq '.',
'CONFIGURE-AC' => $configure_ac,
@@ -6676,7 +6661,7 @@
'HOST' => $seen_canonical,
'TARGET' => $seen_canonical == AC_CANONICAL_SYSTEM,
- 'LIBTOOL' => variable_defined ('LIBTOOL'))
+ 'LIBTOOL' => !! var ('LIBTOOL'))
# We don't need more than two consecutive new-lines.
. 's/\n{3,}/\n\n/g';
@@ -7063,7 +7048,7 @@
}
# Return only those which are actually defined.
- return sort grep { variable_defined ($_ . '_' . $primary) } keys %valid;
+ return sort grep { var ($_ . '_' . $primary) } keys %valid;
}
@@ -7255,7 +7240,7 @@
err_var ($require_extra,
"`$require_extra' contains configure substitution,\n"
. "but `EXTRA_$primary' not defined")
- if ($require_extra && ! variable_defined ('EXTRA_' . $primary));
+ if ($require_extra && ! var ('EXTRA_' . $primary));
# Push here because PRIMARY might be configure time determined.
push (@all, '$(' . $primary . ')')
@@ -7544,8 +7529,7 @@
# Set a variable for the dirstamp basename.
define_pretty_variable ('am__dirstamp', TRUE, INTERNAL,
- '$(am__leading_dot)dirstamp')
- unless variable_defined ('am__dirstamp');
+ '$(am__leading_dot)dirstamp');
# Directory must be removed by `make distclean'.
$clean_files{$dirstamp} = DIST_CLEAN;
Index: lib/Automake/Variable.pm
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/Variable.pm,v
retrieving revision 1.4
diff -u -b -r1.4 Variable.pm
--- lib/Automake/Variable.pm 2 Jun 2003 23:34:59 -0000 1.4
+++ lib/Automake/Variable.pm 18 Jun 2003 20:15:01 -0000
@@ -31,14 +31,13 @@
use vars '@ISA', '@EXPORT', '@EXPORT_OK';
@ISA = qw/Exporter/;
@EXPORT = qw (err_var msg_var msg_cond_var reject_var
- var rvar
+ var rvar vardef rvardef
variables
scan_variable_expansions check_variable_expansions
condition_ambiguous_p
variable_delete
variable_dump variables_dump
- variable_defined
- examine_variable
+ set_seen
require_variables require_variables_for_variable
variable_value
output_variables);
@@ -117,10 +116,15 @@
return rvar ($name)->rdef ($cond)->value;
-The I<r> variants of the C<var> and C<def> methods add an extra test
-to ensure that the lookup succeeded, and will diagnose failure as
-internal errors (which a message which is much more informative than
-Perl's warning about calling a method on a non-object).
+or even
+
+ return rvardef ($name, $cond)->value;
+
+The I<r> variants of the C<var>, C<def>, and C<vardef> methods add an
+extra test to ensure that the lookup succeeded, and will diagnose
+failures as internal errors (which a message which is much more
+informative than Perl's warning about calling a method on a
+non-object).
=cut
@@ -155,6 +159,7 @@
# Macros shipped with Autoconf.
my %_ac_macro_for_var =
(
+ ALLOCA => 'AC_FUNC_ALLOCA',
CC => 'AC_PROG_CC',
CFLAGS => 'AC_PROG_CC',
CXX => 'AC_PROG_CXX',
@@ -301,8 +306,7 @@
=item C<var ($varname)>
Return the C<Automake::Variable> object for the variable
-named C<$varname> if defined. Return the empty list
-otherwise.
+named C<$varname> if defined. Return 0 otherwise.
=cut
@@ -310,7 +314,22 @@
{
my ($name) = @_;
return $_variable_dict{$name} if exists $_variable_dict{$name};
- return ();
+ return 0;
+}
+
+=item C<vardef ($varname, $cond)>
+
+Return the C<Automake::VarDef> object for the variable named
+C<$varname> if defined in condition C<$cond>. Return the empty list
+if the condition or the variable does not exist.
+
+=cut
+
+sub vardef ($$)
+{
+ my ($name, $cond) = @_;
+ my $var = var $name;
+ return $var && $var->def ($cond);
}
# Create the variable if it does not exist.
@@ -343,6 +362,20 @@
return $v;
}
+=item C<rvardef ($varname, $cond)>
+
+Return the C<Automake::VarDef> object for the variable named
+C<$varname> if defined in condition C<$cond>. Abort with an internal
+error if the variable or the variable does not exist.
+
+=cut
+
+sub rvardef ($$)
+{
+ my ($name, $cond) = @_;
+ return rvar ($name)->rdef ($cond);
+}
+
=back
=head2 Methods
@@ -385,7 +418,7 @@
=item C<$var-E<gt>def ($cond)>
Return the C<Automake::VarDef> definition for this variable in
-condition C<$cond>, if it exists. Return the empty list otherwise.
+condition C<$cond>, if it exists. Return 0 otherwise.
=cut
@@ -393,7 +426,7 @@
{
my ($self, $cond) = @_;
return $self->{'defs'}{$cond} if exists $self->{'defs'}{$cond};
- return ();
+ return 0;
}
=item C<$var-E<gt>rdef ($cond)>
@@ -624,7 +657,7 @@
=cut
-sub value_as_list($$;$$)
+sub value_as_list ($$;$$)
{
my ($self, $cond, $parent, $parent_cond) = @_;
my @result;
@@ -660,7 +693,6 @@
return @result;
}
-
=back
=head2 Utility functions
@@ -1099,94 +1131,35 @@
return $text;
}
-=item C<$bool = variable_defined ($varname, [$cond])>
-See if a variable exists. C<$varname> is the variable name, and
-C<$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.
+=item C<$var = set_seen ($varname)>
-=cut
+=item C<$var = $var->set_seen>
-sub variable_defined ($;$)
-{
- my ($var, $cond) = @_;
+Mark all definitions of this variable as examined, if the variable
+exists. See L<Automake::VarDef::set_seen>.
- my $v = var $var;
- my $def = ($v && $cond) ? ($v->def ($cond)) : 0;
+Return the C<Variable> object if the variable exists, or 0
+otherwise (i.e., as the C<var> function).
- if (!$v || ($cond && !$def))
- {
- # VAR is not defined.
+=cut
- # Check there is no target defined with the name of the
- # variable we check.
+sub set_seen ($)
+{
+ my ($self) = @_;
+ $self = ref $self ? $self : var $self;
- # adl> I'm wondering if this error still makes any sense today. I
- # adl> guess it was because targets and variables used to share
- # adl> the same namespace in older versions of Automake?
- # tom> While what you say is definitely part of it, I think it
- # tom> might also have been due to someone making a "spelling error"
- # tom> -- writing "foo:..." instead of "foo = ...".
- # tom> I'm not sure whether it is really worth diagnosing
- # tom> this sort of problem. In the old days I used to add warnings
- # tom> and errors like this pretty randomly, based on bug reports I
- # tom> got. But there's a plausible argument that I was trying
- # tom> too hard to prevent people from making mistakes.
-
- ### FIXME: Presently we can't do this. Wait until targets are handled
- ### in there own module.
- # if (exists $Automake::targets{$var}
- # && (!$cond || exists $Automake::targets{$var}{$cond}))
- # {
- # for my $tcond ($cond || keys %{$Automake::targets{$var}})
- # {
- # prog_error ("\$Automake::targets{$var}{" . $tcond->human
- # . "} exists but \$target_owner doesn't")
- # unless exists $Automake::target_owner{$var}{$tcond};
- # # Diagnose the first user target encountered, if any.
- # # Restricting this test to user targets allows Automake
- # # to create rules for things like `bin_PROGRAMS = LDADD'.
- # if ($Automake::target_owner{$var}{$tcond}
- # == &Automake::TARGET_USER)
- # {
- # Automake::msg_cond_target ('syntax', $tcond, $var,
- # "`$var' is a target; "
- # . "expected a variable");
- # return 0;
- # }
- # }
- # }
- return 0;
- }
+ return 0 unless $self;
- # VAR is defined. Record we have examined this variable.
- if (!$cond)
- {
- for my $c ($v->conditions->conds)
- {
- $v->rdef ($c)->set_seen;
- }
- }
- else
+ for my $c ($self->conditions->conds)
{
- $def->set_seen;
+ $self->rdef ($c)->set_seen;
}
- return 1;
-}
-=item C<examine_variable ($varname)>
-
-Mark a variable as examined.
-
-=cut
-
-sub examine_variable ($)
-{
- my ($var) = @_;
- variable_defined ($var);
+ return $self;
}
+
=item C<$count = require_variables ($where, $reason, $cond, @variables)>
Make sure that each supplied variable is defined in C<$cond>.
@@ -1208,7 +1181,7 @@
{
# Nothing to do if the variable exists.
next VARIABLE
- if variable_defined ($var, $cond);
+ if vardef ($var, $cond);
my $v = _cvar $var;
my $undef_cond = $v->not_always_defined_in_cond ($cond);
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.498
diff -u -b -r1.498 Makefile.am
--- tests/Makefile.am 15 Jun 2003 17:43:20 -0000 1.498
+++ tests/Makefile.am 18 Jun 2003 20:15:01 -0000
@@ -1,6 +1,6 @@
## Process this file with automake to create Makefile.in
-XFAIL_TESTS = auxdir2.test cond17.test txinfo5.test target.test
+XFAIL_TESTS = auxdir2.test cond17.test txinfo5.test
TESTS = \
aclibobj.test \
@@ -425,7 +425,6 @@
syntax.test \
tags.test \
tagsub.test \
-target.test \
target-cflags.test \
targetclash.test \
txinfo.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.640
diff -u -b -r1.640 Makefile.in
--- tests/Makefile.in 15 Jun 2003 17:43:20 -0000 1.640
+++ tests/Makefile.in 18 Jun 2003 20:15:01 -0000
@@ -112,7 +112,7 @@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
-XFAIL_TESTS = auxdir2.test cond17.test txinfo5.test target.test
+XFAIL_TESTS = auxdir2.test cond17.test txinfo5.test
TESTS = \
aclibobj.test \
aclocal.test \
@@ -536,7 +536,6 @@
syntax.test \
tags.test \
tagsub.test \
-target.test \
target-cflags.test \
targetclash.test \
txinfo.test \
Index: tests/target.test
===================================================================
RCS file: tests/target.test
diff -N tests/target.test
--- tests/target.test 8 Sep 2002 13:07:56 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,38 +0,0 @@
-#! /bin/sh
-# Copyright (C) 1996, 1997, 2001, 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.
-
-# Test for a bug where target names and variable names are treated alike.
-# Bug from François Pinard.
-
-. ./defs || exit 1
-
-echo AC_PROG_CC >> configure.in
-
-cat > Makefile.am << 'END'
-bin_PROGRAMS = consud
-## Note next line is target, not variable.
-consud_SOURCES: consud.c
-END
-
-echo > consud.c
-
-$ACLOCAL || exit 1
-$AUTOMAKE && exit 1
-exit 0
--
Alexandre Duret-Lutz
- Re: FYI: 6/ Automake::Variable & Automake::VarDef,
Alexandre Duret-Lutz <=