Akim Demaille <[EMAIL PROTECTED]> writes:
> As a first step, I can apply this patch *but* with this part and the
> --Werror part in defs. Then we have -w in automake, the bad uses are
> fixed (at least those triggered by the test suite and the fileutils),
> the only thing is that the test suite does not check that we don't
> diverge.
This is what I mean:
Index: ChangeLog
from Akim Demaille <[EMAIL PROTECTED]>
* automake.in: Use -w.
Normalize all use of `$lang . '-foo'' into `"$lang-foo"'.
(&parse_arguments): Support --Werror and --Wno-error as a
temporary hack until --warning/-W is properly implemented.
(&handle_single_transform_list): Prototype.
Be sure to define $directory.
Use `exists' instead of testing the value of a maybe undefined
hash value.
(&add_depend2, &handle_configure, &handle_footer, &file_contents)
(&handle_factored_dependencies): Use defined values.
(&scan_one_autoconf_file): Save $_.
* tests/lex2.test, tests/sinclude.test, tests/suffix3.test:
Run automake with --Wno-error.
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.973
diff -u -u -r1.973 automake.in
--- automake.in 2001/03/07 18:39:10 1.973
+++ automake.in 2001/03/07 18:58:40
@@ -1,4 +1,4 @@
-#!@PERL@
+#!@PERL@ -w
# -*- perl -*-
# @configure_input@
@@ -92,7 +92,7 @@
my @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
# ltconfig appears here for compatibility with old versions of libtool.
my @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
- 'ltcf-gcj.sh');
+ 'ltcf-gcj.sh');
# Commonly found files we look for and automatically include in
# DISTFILES.
@@ -939,7 +939,9 @@
'o|output-dir:s' => \$output_directory,
'a|add-missing' => \$add_missing,
'c|copy' => \$copy_missing,
- 'v|verbose' => \$verbose
+ 'v|verbose' => \$verbose,
+ 'Werror' => sub { $SIG{"__WARN__"} = sub { die $_[0] } },
+ 'Wno-error' => sub { $SIG{"__WARN__"} = 'DEFAULT' }
)
or exit 1;
@@ -1395,20 +1397,20 @@
# supports it, then we don't generate the rule here.
my $comp = '';
- if ($use_dependencies && $language_map{$lang . '-autodep'} ne 'no')
+ if ($use_dependencies && $language_map{"$lang-autodep"} ne 'no')
{
# Don't generate the rule, but still generate the variables.
- if (defined $language_map{$lang . '-compile'})
+ if (exists $language_map{"$lang-compile"})
{
- $comp = $language_map{$lang . '-compile'};
+ $comp = $language_map{"$lang-compile"};
}
}
- elsif (defined $language_map{$lang . '-compile'})
+ elsif (exists $language_map{"$lang-compile"})
{
- $comp = $language_map{$lang . '-compile'};
+ $comp = $language_map{"$lang-compile"};
- my $outarg = $language_map{$lang . '-output-arg'};
- if ($language_map{$lang . '-flags'} eq 'CFLAGS')
+ my $outarg = $language_map{"$lang-output-arg"};
+ if ($language_map{"$lang-flags"} eq 'CFLAGS')
{
# C compilers don't always support -c -o.
if (defined $options{'subdir-objects'})
@@ -1418,7 +1420,7 @@
}
my $full = ("\t\$("
- . $language_map{$lang . '-compiler-name'}
+ . $language_map{"$lang-compiler-name"}
. ") "
. $outarg);
$output_rules .= (".$ext.o:\n"
@@ -1430,11 +1432,11 @@
. " `cygpath -w \$<`\n");
$output_rules .= (".$ext.lo:\n"
. "\t\$(LT"
- . $language_map{$lang . '-compiler-name'}
+ . $language_map{"$lang-compiler-name"}
. ") "
- . $language_map{$lang . '-output-arg'}
+ . $language_map{"$lang-output-arg"}
# We can always use -c -o with libtool.
- . ($language_map{$lang . '-flags'} eq 'CFLAGS'
+ . ($language_map{"$lang-flags"} eq 'CFLAGS'
? ' -o $@' : '')
. " \$<\n")
if $seen_libtool;
@@ -1453,17 +1455,17 @@
# probably corner cases here that do not work properly.
# People linking Java code to Fortran code deserve pain.
$non_c = 0
- if $language_map{$lang . '-pure'} eq 'no';
+ if $language_map{"$lang-pure"} eq 'no';
if ($comp ne '')
{
- &define_compiler_variable ($language_map{$lang . '-compiler-name'},
+ &define_compiler_variable ($language_map{"$lang-compiler-name"},
$ltcompile, $comp);
}
# The compiler's flag must be a configure variable.
- if (defined $language_map{$lang . '-flags'})
+ if (exists $language_map{"$lang-flags"})
{
- &define_configure_variable ($language_map{$lang . '-flags'});
+ &define_configure_variable ($language_map{"$lang-flags"});
}
# Compute the function name of the finisher and then call it.
@@ -1595,7 +1597,7 @@
# Result is a list
# $LINKER is name of linker to use (empty string for default linker)
# @OBJECTS are names of objects
-sub handle_single_transform_list
+sub handle_single_transform_list ($$$@)
{
my ($var, $derived, $obj, @files) = @_;
my @result = ();
@@ -1617,12 +1619,11 @@
# put into the current directory.
# Split file name into base and extension.
- my ($linker, $object);
- next if ! /^((.*)\/)?([^\/]*)\.(.*)$/;
+ next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
my $full = $_;
- my $directory = $2;
- my $base = $3;
- my $extension = $4;
+ my $directory = $1 || '';
+ my $base = $2;
+ my $extension = $3;
my $xbase = $base;
@@ -1630,6 +1631,7 @@
# its own flags.
my $rule = '';
my $renamed = 0;
+ my ($linker, $object);
$extension = &derive_suffix ($extension);
my $lang = $extension_map{$extension};
@@ -1644,10 +1646,10 @@
next if $r == $LANG_IGNORE;
# Now extract linker and other info.
- $linker = $language_map{$lang . '-linker'};
+ $linker = $language_map{"$lang-linker"};
my $this_obj_ext;
- if ($language_map{$lang . '-ansi-p'})
+ if ($language_map{"$lang-ansi-p"})
{
$object = $base . $obj;
$this_obj_ext = $obj;
@@ -1658,9 +1660,9 @@
$this_obj_ext = $nonansi_obj;
}
- if ($language_map{$lang . '-flags'} ne ''
+ if (exists $language_map{"$lang-flags"}
&& &variable_defined ($derived . '_'
- . $language_map{$lang . '-flags'}))
+ . $language_map{"$lang-flags"}))
{
# We have a per-executable flag in effect for this
# object. In this case we rewrite the object's
@@ -1690,18 +1692,18 @@
if $lang eq 'c';
&prog_error ("$lang flags defined without compiler")
- if ! defined $language_map{$lang . '-compile'};
+ if ! defined $language_map{"$lang-compile"};
# Compute the rule to compile this object.
- my $flag = $language_map{$lang . '-flags'};
+ my $flag = $language_map{"$lang-flags"};
my $val = "(${derived}_${flag}";
- ($rule = $language_map{$lang . '-compile'}) =~
+ ($rule = $language_map{"$lang-compile"}) =~
s/\(AM_$flag/$val/;
- $rule .= ' ' . $language_map{$lang . '-output-arg'};
+ $rule .= ' ' . $language_map{"$lang-output-arg"};
# For C we have to add the -o, because the
# standard rule doesn't include it.
- if ($language_map{$lang . '-flags'} eq 'CFLAGS')
+ if ($language_map{"$lang-flags"} eq 'CFLAGS')
{
$rule .= ' -o $@';
}
@@ -1725,7 +1727,7 @@
# generated later, by add_depend2.
if (($use_dependencies
&& $rule ne ''
- && $language_map{$lang . '-autodep'} ne 'no')
+ && $language_map{"$lang-autodep"} ne 'no')
|| $directory ne '')
{
$rule = '';
@@ -1839,8 +1841,8 @@
# Transform .o or $o file into .P file (for automatic
# dependency code).
if ($lang
- && ($language_map{$lang . '-autodep'} ne 'no'
- || $language_map{$lang . '-derived-autodep'} eq 'yes'))
+ && ($language_map{"$lang-autodep"} ne 'no'
+ || $language_map{"$lang-derived-autodep"} eq 'yes'))
{
my $depfile = $object;
$depfile =~ s/\.([^.]*)$/.P$1/;
@@ -3138,7 +3140,7 @@
# Get information on $LANG.
my $pfx = $language_map{"$lang-autodep"};
my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
- my $flag = $language_map{"$lang-flags"};
+ my $flag = $language_map{"$lang-flags"} || '';
# First include code for ordinary objects.
my %transform = ('PFX' => $pfx,
@@ -3418,7 +3420,7 @@
# We know we can always add '.in' because it really should be an
# error if the .in was missing originally.
my $infile = '$(srcdir)/' . $input_base . '.in';
- my $colon_infile;
+ my $colon_infile = '';
if ($local ne $input || @secondary_inputs)
{
$colon_infile = ':' . $input . '.in';
@@ -3822,9 +3824,10 @@
# Deal with installdirs target.
sub handle_installdirs ()
{
- $output_rules .= &file_contents ('install',
- ('_am_installdirs'
- => $am_var_defs{'_am_installdirs'}));
+ $output_rules .=
+ &file_contents ('install',
+ ('_am_installdirs'
+ => $am_var_defs{'_am_installdirs'} || ''));
}
@@ -4068,7 +4071,8 @@
|| $required_targets{$_});
&pretty_print_rule ("$_:", "\t",
uniq (sort @{$dependencies{$_}}));
- $output_rules .= $actions{$_};
+ $output_rules .= $actions{$_}
+ if defined $actions{$_};
$output_rules .= "\n";
}
}
@@ -4388,7 +4392,12 @@
# Cygnus and hopefully nowhere else.
if (/sinclude\((.*)\)/ && -f $1)
{
+ # $_ being local, if we don't preserve it, when coming
+ # back we will have $_ = undef, which is bad for the
+ # the rest of this routine.
+ my $underscore = $_;
&scan_one_autoconf_file ($1);
+ $_ = $underscore;
}
# Populate libobjs array.
@@ -5277,7 +5286,8 @@
my ($ltcompile, $ltlink) = &libtool_compiler;
&define_variable ('GCJLD', '$(GCJ)');
- &define_variable ('GCJLINK', $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS)
$(AM_LDFLAGS) $(LDFLAGS) -o $@');
+ &define_variable ('GCJLINK',
+ $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS)
+$(LDFLAGS) -o $@');
if (! defined $configure_vars{'GCJ'})
{
@@ -5361,24 +5371,24 @@
# (sans `.').
sub register_language
{
- my ($language, @options) = @_;
+ my ($lang, @options) = @_;
# Set the defaults.
- $language_map{$language . '-ansi-p'} = 0;
- $language_map{$language . '-linker'} = '';
- $language_map{$language . '-autodep'} = 'no';
- $language_map{$language . '-derived-autodep'} = 'no';
+ $language_map{"$lang-ansi-p"} = 0;
+ $language_map{"$lang-autodep"} = 'no';
+ $language_map{"$lang-derived-autodep"} = 'no';
+ $language_map{"$lang-linker"} = '';
# `-pure' is `yes' or `no'. A `pure' language is one where, if
# all the files in a directory are of that language, then we do
# not require the C compiler or any code to call it.
- $language_map{$language . '-pure'} = 'no';
+ $language_map{"$lang-pure"} = 'no';
foreach my $iter (@options)
{
if ($iter =~ /^(.*)=(.*)$/)
{
- $language_map{$language . '-' . $1} = $2;
+ $language_map{"$lang-$1"} = $2;
}
elsif (defined $extension_map{$iter})
{
@@ -5386,7 +5396,7 @@
}
else
{
- $extension_map{$iter} = $language;
+ $extension_map{$iter} = $lang;
}
}
}
@@ -6722,8 +6732,8 @@
# line).
# I'm quite shoked! It seems that (\\\n|[^\n]) is not the
# same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
- my ($relationship, $actions) =
- /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
+ /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
+ my ($relationship, $actions) = ($1, $2 || '');
# Separate targets from dependencies: the first colon.
$relationship =~ /^([^:]+\S+) *: *(.*)$/som;
@@ -6770,6 +6780,8 @@
&prog_error ("$file:$.: macro `$var' with trailing backslash")
if /\\$/;;
# Accumulating variables must not be output.
+ $am_var_defs{$var} = ''
+ unless defined $am_var_defs{$var};
if ($type eq '+')
{
$am_var_defs{$var} .= ($am_var_defs{$var} && ' ') . $val;
@@ -6839,8 +6851,9 @@
{
if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
{
- if (($2 ne '' && ! $can_dist)
- || (! defined $valid{$3} && ! &variable_defined ($3 . 'dir')))
+ my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
+ if (($dist ne '' && ! $can_dist)
+ || (! defined $valid{$X} && ! &variable_defined ("${X}dir")))
{
# Note that a configure variable is always legitimate.
# It is natural to name such variables after the
@@ -6853,7 +6866,7 @@
else
{
# Ensure all extended prefixes are actually used.
- $valid{$1 . $2 . $3} = 1;
+ $valid{"$base$dist$X"} = 1;
}
}
}
Index: tests/lex2.test
===================================================================
RCS file: /cvs/automake/automake/tests/lex2.test,v
retrieving revision 1.5
diff -u -u -r1.5 lex2.test
--- tests/lex2.test 1998/04/05 21:27:04 1.5
+++ tests/lex2.test 2001/03/07 18:58:45
@@ -18,5 +18,5 @@
: > joe.l
-$AUTOMAKE 2> output || exit 1
+$AUTOMAKE --Wno-error 2> output || exit 1
test -n "`cat output`"
Index: tests/sinclude.test
===================================================================
RCS file: /cvs/automake/automake/tests/sinclude.test,v
retrieving revision 1.1
diff -u -u -r1.1 sinclude.test
--- tests/sinclude.test 1998/03/19 21:15:02 1.1
+++ tests/sinclude.test 2001/03/07 18:58:45
@@ -15,6 +15,6 @@
: > Makefile.am
-$AUTOMAKE || exit 1
+$AUTOMAKE --Wno-error || exit 1
grep MAGICALPIG Makefile.in
Index: tests/suffix3.test
===================================================================
RCS file: /cvs/automake/automake/tests/suffix3.test,v
retrieving revision 1.1
diff -u -u -r1.1 suffix3.test
--- tests/suffix3.test 1999/12/14 06:09:39 1.1
+++ tests/suffix3.test 2001/03/07 18:58:45
@@ -16,7 +16,7 @@
foo_SOURCES = foo.zoo
END
-$AUTOMAKE || exit 1
+$AUTOMAKE --Wno-error || exit 1
fgrep foo.cc Makefile.in && exit 1
exit 0