automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

07-use-w.patch


From: Akim Demaille
Subject: 07-use-w.patch
Date: Tue, 06 Mar 2001 08:34:59 +0100

The goal is to use -w *and* to have the test suite fail when there are
-w-warnings.

Note that I could catch the `$_ needs be saved' issue because I could
see the errors from sinclude.test, i.e., before that I realized that
--Wno-error was needed by this test, I had to observe the many
complaints from Perl.  In other words, checking that warnings are not
errors has the effect of hiding `die' from warnings.

I went throught the language_map normalization to ease my finding the
bad sites.  Sorry for the artificial growth to the patch :(

I suspect something like &defined_variable etc. for %language_map
might make a more readable and more robust code.


Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * 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.
        (&require_file_internal): Don't warn about installed files, just
        output on STDERR.
        (&scan_one_autoconf_file): Save $_.
        * tests/defs (AUTOMAKE): Add --Werror.
        * tests/lex2.test, tests/sinclude.test, tests/suffix3.test:
        Run automake with --Wno-error.

Index: automake.in
--- automake.in Mon, 05 Mar 2001 22:33:22 +0100 akim (am/f/39_automake.i 1.115 
755)
+++ automake.in Tue, 06 Mar 2001 00:31:49 +0100 akim (am/f/39_automake.i 1.115 
755)
@@ -1,4 +1,4 @@
address@hidden@
address@hidden@ -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 @@ sub parse_arguments ()
        '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;

@@ -1377,20 +1379,20 @@ sub finish_languages
        # 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'})
@@ -1400,7 +1402,7 @@ sub finish_languages
            }

            my $full = ("\t\$("
-                       . $language_map{$lang . '-compiler-name'}
+                       . $language_map{"$lang-compiler-name"}
                        . ") "
                        . $outarg);
            $output_rules .= (".$ext.o:\n"
@@ -1412,11 +1414,11 @@ sub finish_languages
                              . " \`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;
@@ -1435,17 +1437,17 @@ sub finish_languages
        # 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.
@@ -1577,7 +1579,7 @@ sub check_libobjs_sources
 # 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 = ();
@@ -1599,12 +1601,11 @@ sub handle_single_transform_list
         # 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;

@@ -1612,6 +1613,7 @@ sub handle_single_transform_list
         # its own flags.
         my $rule = '';
         my $renamed = 0;
+        my ($linker, $object);

         $extension = &derive_suffix ($extension);
         my $lang = $extension_map{$extension};
@@ -1626,10 +1628,10 @@ sub handle_single_transform_list
             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;
@@ -1640,9 +1642,9 @@ sub handle_single_transform_list
                 $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
@@ -1672,18 +1674,18 @@ sub handle_single_transform_list
                     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 $@';
                 }
@@ -1707,7 +1709,7 @@ sub handle_single_transform_list
             # 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 = '';
@@ -1821,8 +1823,8 @@ sub handle_single_transform_list
         # 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/;
@@ -3120,7 +3122,7 @@ sub add_depend2
     # 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,
@@ -3400,7 +3402,7 @@ sub handle_configure
     # 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';
@@ -3804,9 +3806,10 @@ sub handle_footer
 # 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'} || ''));
 }

 # There are several targets which need to be merged.  This is because
@@ -4071,7 +4074,8 @@ sub handle_factored_dependencies
                  || $required_targets{$_});
         &pretty_print_rule ("$_:", "\t",
                            uniq (sort @{$dependencies{$_}}));
-       $output_rules .= $actions{$_};
+       $output_rules .= $actions{$_}
+         if defined $actions{$_};
         $output_rules .= "\n";
     }
 }
@@ -4391,7 +4395,12 @@ sub scan_one_autoconf_file
        # 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.
@@ -5281,7 +5290,8 @@ sub lang_java_finish
     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'})
     {
@@ -5365,24 +5375,24 @@ sub saw_sources_p
 # (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})
        {
@@ -5390,7 +5400,7 @@ sub register_language
        }
        else
        {
-           $extension_map{$iter} = $language;
+           $extension_map{$iter} = $lang;
        }
     }
 }
@@ -6726,8 +6736,8 @@ sub file_contents ($%)
          # 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;
@@ -6774,6 +6784,8 @@ sub file_contents ($%)
            &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;
@@ -6843,8 +6855,9 @@ sub am_primary_prefixes
     {
        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
@@ -6857,7 +6870,7 @@ sub am_primary_prefixes
            else
            {
                # Ensure all extended prefixes are actually used.
-               $valid{$1 . $2 . $3} = 1;
+               $valid{"$base$dist$X"} = 1;
            }
        }
     }
@@ -7305,15 +7318,15 @@ sub require_file_internal
                }

                my $save = $exit_status;
+               $exit_status = 1;
                if ($is_configure)
                {
                    # FIXME: allow actual file to be specified.
-                   &am_conf_line_error ($configure_ac, $line,
-                                        "$message$trailer");
+                   print STDERR "$configure_ac:$line: $message$trailer\n";
                }
                else
                {
-                   &am_line_error ($line, "$message$trailer");
+                   print STDERR "$am_file.am:$line: $message$trailer\n";
                }
                $exit_status = $save if $suppress;
            }
Index: tests/defs
--- tests/defs Mon, 05 Mar 2001 22:33:22 +0100 akim (am/f/2_defs 1.4 644)
+++ tests/defs Mon, 05 Mar 2001 23:27:04 +0100 akim (am/f/2_defs 1.4 644)
@@ -71,7 +71,7 @@
 # See how Automake should be run.  We put --foreign as the default
 # strictness to avoid having to create lots and lots of files.  A test
 # can override this by specifying a different strictness.
-AUTOMAKE="$PERL ../../automake --amdir=$srcdir/.. --foreign"
+AUTOMAKE="$PERL ../../automake --amdir=$srcdir/.. --foreign --Werror"

 # See how aclocal should be run.
 ACLOCAL="$PERL ../../aclocal --acdir=$srcdir/../m4"
Index: tests/lex2.test
--- tests/lex2.test Sat, 13 Jan 2001 18:11:09 +0100 akim (am/c/25_lex2.test 1.1 
755)
+++ tests/lex2.test Tue, 06 Mar 2001 00:22:58 +0100 akim (am/c/25_lex2.test 1.1 
755)
@@ -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
--- tests/sinclude.test Sat, 13 Jan 2001 18:11:09 +0100 akim (am/b/5_sinclude.t 
1.1 755)
+++ tests/sinclude.test Tue, 06 Mar 2001 00:23:59 +0100 akim (am/b/5_sinclude.t 
1.1 755)
@@ -15,6 +15,6 @@

 : > Makefile.am

-$AUTOMAKE || exit 1
+$AUTOMAKE --Wno-error || exit 1

 grep MAGICALPIG Makefile.in
Index: tests/suffix3.test
--- tests/suffix3.test Sat, 13 Jan 2001 18:11:09 +0100 akim (am/33_suffix3.te 
1.1 755)
+++ tests/suffix3.test Tue, 06 Mar 2001 00:25:33 +0100 akim (am/33_suffix3.te 
1.1 755)
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]