Merge branch 'maint'
[platform/upstream/automake.git] / automake.in
index cdbb820..940e770 100644 (file)
@@ -53,7 +53,6 @@ struct (# Short name of the language (c, f77...).
        # List of configure variables which must be defined.
        'config_vars' => '@',
 
-       'ansi'    => "\$",
        # `pure' is `1' or `'.  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.
@@ -208,8 +207,6 @@ my $INCLUDE_PATTERN = ('^include\s+'
                       . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
                       . '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$");
 
-# Match `-d' as a command-line argument in a string.
-my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
 # Directories installed during 'install-exec' phase.
 my $EXEC_DIR_PATTERN =
   '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$";
@@ -235,9 +232,9 @@ my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh);
 my @common_files =
     (qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB
        COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO
-       ansi2knr.1 ansi2knr.c compile config.guess config.rpath config.sub
-       depcomp elisp-comp install-sh libversion.in mdate-sh missing
-       mkinstalldirs py-compile texinfo.tex ylwrap),
+       ar-lib compile config.guess config.rpath
+       config.sub depcomp elisp-comp install-sh libversion.in mdate-sh
+       missing mkinstalldirs py-compile texinfo.tex ylwrap),
      @libtool_files, @libtool_sometimes);
 
 # Commonly used files we auto-include, but only sometimes.  This list
@@ -330,10 +327,6 @@ my @config_headers = ();
 # Names used in AC_CONFIG_LINKS call.
 my @config_links = ();
 
-# Directory where output files go.  Actually, output files are
-# relative to this directory.
-my $output_directory;
-
 # List of Makefile.am's to process, and their corresponding outputs.
 my @input_files = ();
 my %output_files = ();
@@ -393,8 +386,8 @@ my $package_version = '';
 # Where version is defined.
 my $package_version_location;
 
-# TRUE if we've seen AM_ENABLE_MULTILIB.
-my $seen_multilib = 0;
+# TRUE if we've seen AM_PROG_AR
+my $seen_ar = 0;
 
 # TRUE if we've seen AM_PROG_CC_C_O
 my $seen_cc_c_o = 0;
@@ -477,9 +470,8 @@ my %required_targets =
    'install-man' => 1,
   );
 
-# Set to 1 if this run will create the Makefile.in that distributes
-# the files in config_aux_dir.
-my $automake_will_process_aux_dir = 0;
+# Queue to push require_conf_file requirements to.
+my $required_conf_file_queue;
 
 # The name of the Makefile currently being processed.
 my $am_file = 'BUG';
@@ -574,12 +566,6 @@ my @dist_targets;
 my %known_programs;
 my %known_libraries;
 
-# Keys in this hash are the basenames of files which must depend on
-# ansi2knr.  Values are either the empty string, or the directory in
-# which the ANSI source file appears; the directory must have a
-# trailing `/'.
-my %de_ansi_files;
-
 # This keeps track of which extensions we've seen (that we care
 # about).
 my %extension_seen;
@@ -603,9 +589,9 @@ my %linkers_used;
 # True if we need `LINK' defined.  This is a hack.
 my $need_link;
 
-# Was get_object_extension run?
-# FIXME: This is a hack. a better switch should be found.
-my $get_object_extension_was_run;
+# Does the generated Makefile have to build some compiled object
+# (for binary programs, or plain or libtool libraries)?
+my $must_handle_compiled_objects;
 
 # Record each file processed by make_paragraphs.
 my %transformed_files;
@@ -705,8 +691,6 @@ sub initialize_per_input ()
     %known_programs = ();
     %known_libraries= ();
 
-    %de_ansi_files = ();
-
     %extension_seen = ();
 
     %language_scratch = ();
@@ -717,7 +701,7 @@ sub initialize_per_input ()
 
     $need_link = 0;
 
-    $get_object_extension_was_run = 0;
+    $must_handle_compiled_objects = 0;
 
     %transformed_files = ();
 }
@@ -731,7 +715,6 @@ sub initialize_per_input ()
 register_language ('name' => 'c',
                   'Name' => 'C',
                   'config_vars' => ['CC'],
-                  'ansi' => 1,
                   'autodep' => '',
                   'flags' => ['CFLAGS', 'CPPFLAGS'],
                   'ccer' => 'CC',
@@ -743,8 +726,7 @@ register_language ('name' => 'c',
                   'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
                   'compile_flag' => '-c',
                   'libtool_tag' => 'CC',
-                  'extensions' => ['.c'],
-                  '_finish' => \&lang_c_finish);
+                  'extensions' => ['.c']);
 
 # C++.
 register_language ('name' => 'cxx',
@@ -901,10 +883,7 @@ register_language ('name' => 'asm',
                   'compiler' => 'CCASCOMPILE',
                   'compile_flag' => '-c',
                   'output_flag' => '-o',
-                  'extensions' => ['.s'],
-
-                  # With assembly we still use the C linker.
-                  '_finish' => \&lang_c_finish);
+                  'extensions' => ['.s']);
 
 # Preprocessed Assembler.
 register_language ('name' => 'cppasm',
@@ -918,10 +897,7 @@ register_language ('name' => 'cppasm',
                   'compiler' => 'CPPASCOMPILE',
                   'compile_flag' => '-c',
                   'output_flag' => '-o',
-                  'extensions' => ['.S', '.sx'],
-
-                  # With assembly we still use the C linker.
-                  '_finish' => \&lang_c_finish);
+                  'extensions' => ['.S', '.sx']);
 
 # Fortran 77
 register_language ('name' => 'f77',
@@ -1210,11 +1186,25 @@ sub define_verbose_tagvar ($)
     my ($name) = @_;
     if (option 'silent-rules')
       {
-       define_verbose_var ($name, '@echo "  '. $name . ' ' x (6 - length ($name)) . '" $@;');
+       define_verbose_var ($name, '@echo "  '. $name . ' ' x (8 - length ($name)) . '" $@;');
        define_verbose_var ('at', '@');
       }
 }
 
+# define_verbose_texinfo
+# ----------------------
+# Engage the needed `silent-rules' machinery for assorted texinfo commands.
+sub define_verbose_texinfo ()
+{
+  my @tagvars = ('DVIPS', 'MAKEINFO', 'INFOHTML', 'TEXI2DVI', 'TEXI2PDF');
+  foreach my $tag (@tagvars)
+    {
+      define_verbose_tagvar($tag);
+    }
+  define_verbose_var('texinfo', '-q');
+  define_verbose_var('texidevnull', '> /dev/null');
+}
+
 # define_verbose_libtool
 # ----------------------
 # Engage the needed `silent-rules' machinery for `libtool --silent'.
@@ -1239,12 +1229,10 @@ sub handle_options
          msg_var ('unsupported', $var,
                   "`AUTOMAKE_OPTIONS' cannot have conditional contents");
        }
-      foreach my $locvals ($var->value_as_list_recursive (cond_filter => TRUE,
-                                                         location => 1))
-       {
-         my ($loc, $value) = @$locvals;
-         return 1 if (process_option_list ($loc, $value))
-       }
+      my @options = map { { option => $_->[1], where => $_->[0] } }
+                       $var->value_as_list_recursive (cond_filter => TRUE,
+                                                      location => 1);
+      return 1 if process_option_list (@options);
     }
 
   # Override portability-recursive warning.
@@ -1281,22 +1269,6 @@ sub shadow_unconditionally ($$)
   return "\$($varname)"
 }
 
-# get_object_extension ($EXTENSION)
-# ---------------------------------
-# Prefix $EXTENSION with $U if ansi2knr is in use.
-sub get_object_extension ($)
-{
-    my ($extension) = @_;
-
-    # Check for automatic de-ANSI-fication.
-    $extension = '$U' . $extension
-      if option 'ansi2knr';
-
-    $get_object_extension_was_run = 1;
-
-    return $extension;
-}
-
 # check_user_variables (@LIST)
 # ----------------------------
 # Make sure each variable VAR in @LIST does not exist, suggest using AM_VAR
@@ -1316,7 +1288,7 @@ sub check_user_variables (@)
                  msg_cond_var ('gnu', $cond, $flag,
                                "`$flag' is a user variable, "
                                . "you should not override it;\n"
-                               . "use `AM_$flag' instead.");
+                               . "use `AM_$flag' instead");
                }
            }
        }
@@ -1521,97 +1493,6 @@ sub handle_languages
                unless $depbase eq '';
            $depbase .= '$(DEPDIR)/' . basename ($obj);
 
-           # Support for deansified files in subdirectories is ugly
-           # enough to deserve an explanation.
-           #
-           # A Note about normal ansi2knr processing first.  On
-           #
-           #   AUTOMAKE_OPTIONS = ansi2knr
-           #   bin_PROGRAMS = foo
-           #   foo_SOURCES = foo.c
-           #
-           # we generate rules similar to:
-           #
-           #   foo: foo$U.o; link ...
-           #   foo$U.o: foo$U.c; compile ...
-           #   foo_.c: foo.c; ansi2knr ...
-           #
-           # this is fairly compact, and will call ansi2knr depending
-           # on the value of $U (`' or `_').
-           #
-           # It's harder with subdir sources. On
-           #
-           #   AUTOMAKE_OPTIONS = ansi2knr
-           #   bin_PROGRAMS = foo
-           #   foo_SOURCES = sub/foo.c
-           #
-           # we have to create foo_.c in the current directory.
-           # (Unless the user asks 'subdir-objects'.)  This is important
-           # in case the same file (`foo.c') is compiled from other
-           # directories with different cpp options: foo_.c would
-           # be preprocessed for only one set of options if it were
-           # put in the subdirectory.
-           #
-           # Because foo$U.o must be built from either foo_.c or
-           # sub/foo.c we can't be as concise as in the first example.
-           # Instead we output
-           #
-           #   foo: foo$U.o; link ...
-           #   foo_.o: foo_.c; compile ...
-           #   foo.o: sub/foo.c; compile ...
-           #   foo_.c: foo.c; ansi2knr ...
-           #
-           # This is why we'll now transform $rule_file twice
-           # if we detect this case.
-           # A first time we output the compile rule with `$U'
-           # replaced by `_' and the source directory removed,
-           # and another time we simply remove `$U'.
-           #
-           # Note that at this point $source (as computed by
-           # &handle_single_transform) is `sub/foo$U.c'.
-           # This can be confusing: it can be used as-is when
-           # subdir-objects is set, otherwise you have to know
-           # it really means `foo_.c' or `sub/foo.c'.
-           my $objdir = dirname ($obj);
-           my $srcdir = dirname ($source);
-           if ($lang->ansi && $obj =~ /\$U/)
-             {
-               prog_error "`$obj' contains \$U, but `$source' doesn't."
-                 if $source !~ /\$U/;
-
-               (my $source_ = $source) =~ s/\$U/_/g;
-               # Output an additional rule if _.c and .c are not in
-               # the same directory.  (_.c is always in $objdir.)
-               if ($objdir ne $srcdir)
-                 {
-                   (my $obj_ = $obj) =~ s/\$U/_/g;
-                   (my $depbase_ = $depbase) =~ s/\$U/_/g;
-                   $source_ = basename ($source_);
-
-                   $output_rules .=
-                     file_contents ($rule_file,
-                                    new Automake::Location,
-                                    %transform,
-                                    GENERIC   => 0,
-
-                                    DEPBASE   => $depbase_,
-                                    BASE      => $obj_,
-                                    SOURCE    => $source_,
-                                    SOURCEFLAG => $sourceflags{$srcext} || '',
-                                    OBJ       => "$obj_$myext",
-                                    OBJOBJ    => "$obj_.obj",
-                                    LTOBJ     => "$obj_.lo",
-
-                                    COMPILE   => $obj_compile,
-                                    LTCOMPILE => $obj_ltcompile,
-                                    -o        => $output_flag,
-                                    %file_transform);
-                   $obj =~ s/\$U//g;
-                   $depbase =~ s/\$U//g;
-                   $source =~ s/\$U//g;
-                 }
-             }
-
            $output_rules .=
              file_contents ($rule_file,
                             new Automake::Location,
@@ -1767,7 +1648,7 @@ sub check_libobjs_sources
 #   $VAR is the name of the variable that the source filenames come from
 #   $TOPPARENT is the name of the _SOURCES variable which is being processed
 #   $DERIVED is the name of resulting executable or library
-#   $OBJ is the object extension (e.g., `$U.lo')
+#   $OBJ is the object extension (e.g., `.lo')
 #   $FILE the source file to transform
 #   %TRANSFORM contains extras arguments to pass to file_contents
 #     when producing explicit rules
@@ -1778,8 +1659,6 @@ sub handle_single_transform ($$$$$%)
     my ($var, $topparent, $derived, $obj, $_file, %transform) = @_;
     my @files = ($_file);
     my @result = ();
-    my $nonansi_obj = $obj;
-    $nonansi_obj =~ s/\$U//g;
 
     # Turn sources into objects.  We use a while loop like this
     # because we might add to @files in the loop.
@@ -1826,7 +1705,7 @@ sub handle_single_transform ($$$$$%)
        # language function.
        my $aggregate = 'AM';
 
-       $extension = &derive_suffix ($extension, $nonansi_obj);
+       $extension = &derive_suffix ($extension, $obj);
        my $lang;
        if ($extension_map{$extension} &&
            ($lang = $languages{$extension_map{$extension}}))
@@ -1837,7 +1716,7 @@ sub handle_single_transform ($$$$$%)
            # Do we have per-executable flags for this executable?
            my $have_per_exec_flags = 0;
            my @peflags = @{$lang->flags};
-           push @peflags, 'LIBTOOLFLAGS' if $nonansi_obj eq '.lo';
+           push @peflags, 'LIBTOOLFLAGS' if $obj eq '.lo';
            foreach my $flag (@peflags)
              {
                if (set_seen ("${derived}_$flag"))
@@ -1857,7 +1736,7 @@ sub handle_single_transform ($$$$$%)
            my $subr = \&{'lang_' . $lang->name . '_rewrite'};
            my ($r, $source_extension)
                = &$subr ($directory, $base, $extension,
-                         $nonansi_obj, $have_per_exec_flags, $var);
+                         $obj, $have_per_exec_flags, $var);
            # Skip this entry if we were asked not to process it.
            next if $r == LANG_IGNORE;
 
@@ -1870,13 +1749,9 @@ sub handle_single_transform ($$$$$%)
                $this_obj_ext = $source_extension;
                $derived_source = 1;
            }
-           elsif ($lang->ansi)
-           {
-               $this_obj_ext = $obj;
-           }
            else
            {
-               $this_obj_ext = $nonansi_obj;
+               $this_obj_ext = $obj;
            }
            $object = $base . $this_obj_ext;
 
@@ -1965,12 +1840,6 @@ sub handle_single_transform ($$$$$%)
                        $full_ansi = $base . $extension;
                  }
 
-               if ($lang->ansi && option 'ansi2knr')
-                 {
-                   $full_ansi =~ s/$KNOWN_EXTENSIONS_PATTERN$/\$U$&/;
-                   $obj_sans_ext .= '$U';
-                 }
-
                my @specifics = ($full_ansi, $obj_sans_ext,
                                 # Only use $this_obj_ext in the derived
                                 # source case because in the other case we
@@ -2002,7 +1871,7 @@ sub handle_single_transform ($$$$$%)
                      [@specifics, %transform]);
            }
        }
-       elsif ($extension eq $nonansi_obj)
+       elsif ($extension eq $obj)
        {
            # This is probably the result of a direct suffix rule.
            # In this case we just accept the rewrite.
@@ -2316,9 +2185,9 @@ sub handle_lib_objects
   my ($xname, $varname) = @_;
 
   my $var = var ($varname);
-  prog_error "handle_lib_objects: `$varname' undefined"
+  prog_error "`$varname' undefined"
     unless $var;
-  prog_error "handle_lib_objects: unexpected variable name `$varname'"
+  prog_error "unexpected variable name `$varname'"
     unless $varname =~ /^(.*)(?:LIB|LD)ADD$/;
   my $prefix = $1 || 'AM_';
 
@@ -2351,7 +2220,7 @@ sub handle_lib_objects
               # FIXME: should display a stack of nested variables
               # as context when $var != $subvar.
               err_var ($var, "linker flags such as `$val' belong in "
-                       . "`${prefix}LDFLAGS");
+                       . "`${prefix}LDFLAGS'");
             }
           return ();
         }
@@ -2511,8 +2380,7 @@ sub check_canonical_spelling
 # Set up the compile suite.
 sub handle_compile ()
 {
-    return
-      unless $get_object_extension_was_run;
+   return if ! $must_handle_compiled_objects;
 
     # Boilerplate.
     my $default_includes = '';
@@ -2561,38 +2429,6 @@ sub handle_compile ()
                                'DISTRMS' => join ("\n", @dist_rms)));
     $output_vars .= $vars;
     $output_rules .= "$coms$rules";
-
-    # Check for automatic de-ANSI-fication.
-    if (option 'ansi2knr')
-      {
-       my ($ansi2knr_filename, $ansi2knr_where) = @{option 'ansi2knr'};
-       my $ansi2knr_dir = '';
-
-       require_variables ($ansi2knr_where, "option `ansi2knr' is used",
-                          TRUE, "ANSI2KNR", "U");
-
-       # topdir is where ansi2knr should be.
-       if ($ansi2knr_filename eq 'ansi2knr')
-         {
-           # Only require ansi2knr files if they should appear in
-           # this directory.
-           require_file ($ansi2knr_where, FOREIGN,
-                         'ansi2knr.c', 'ansi2knr.1');
-
-           # ansi2knr needs to be built before subdirs, so unshift it
-           # rather then pushing it.
-           unshift (@all, '$(ANSI2KNR)');
-         }
-       else
-         {
-           $ansi2knr_dir = dirname ($ansi2knr_filename);
-         }
-
-       $output_rules .= &file_contents ('ansi2knr',
-                                        new Automake::Location,
-                                        'ANSI2KNR-DIR' => $ansi2knr_dir);
-
-    }
 }
 
 # handle_libtool ()
@@ -2633,6 +2469,7 @@ sub handle_programs
                                  'bin', 'sbin', 'libexec', 'pkglibexec',
                                  'noinst', 'check');
   return if ! @proglist;
+  $must_handle_compiled_objects = 1;
 
   my $seen_global_libobjs =
     var ('LDADD') && &handle_lib_objects ('', 'LDADD');
@@ -2642,7 +2479,7 @@ sub handle_programs
       my ($where, $one_file) = @$pair;
 
       my $seen_libobjs = 0;
-      my $obj = get_object_extension '.$(OBJEXT)';
+      my $obj = '.$(OBJEXT)';
 
       $known_programs{$one_file} = $where;
 
@@ -2723,6 +2560,7 @@ sub handle_libraries
   my @liblist = &am_install_var ('libs', 'LIBRARIES',
                                 'lib', 'pkglib', 'noinst', 'check');
   return if ! @liblist;
+  $must_handle_compiled_objects = 1;
 
   my @prefix = am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
                                    'noinst', 'check');
@@ -2759,7 +2597,7 @@ sub handle_libraries
       $where->push_context ("while processing library `$onelib'");
       $where->set (INTERNAL->get);
 
-      my $obj = get_object_extension '.$(OBJEXT)';
+      my $obj = '.$(OBJEXT)';
 
       # Canonicalize names and check for misspellings.
       my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
@@ -2816,6 +2654,13 @@ sub handle_libraries
              &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
            }
        }
+
+      if (! $seen_ar)
+       {
+         msg ('extra-portability', $where,
+              "`$onelib': linking libraries using a non-POSIX\n"
+              . "archiver requires `AM_PROG_AR' in `$configure_ac'")
+       }
     }
 }
 
@@ -2828,6 +2673,7 @@ sub handle_ltlibraries
   my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
                                 'noinst', 'lib', 'pkglib', 'check');
   return if ! @liblist;
+  $must_handle_compiled_objects = 1;
 
   my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
                                    'noinst', 'check');
@@ -2896,7 +2742,7 @@ sub handle_ltlibraries
 
                   my $onlyone = ($dir ne $adir) ?
                     ("\nLibtool libraries can be built for only one "
-                     . "destination.") : "";
+                     . "destination") : "";
 
                   error ($liblocations{$val}{$acond},
                          "... and should also be $adirtxt$adircond.$onlyone");
@@ -2924,7 +2770,7 @@ sub handle_ltlibraries
       my ($where, $onelib) = @$pair;
 
       my $seen_libobjs = 0;
-      my $obj = get_object_extension '.lo';
+      my $obj = '.lo';
 
       # Canonicalize names and check for misspellings.
       my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
@@ -3054,6 +2900,13 @@ sub handle_ltlibraries
              &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
            }
        }
+
+      if (! $seen_ar)
+       {
+         msg ('extra-portability', $where,
+              "`$onelib': linking libtool libraries using a non-POSIX\n"
+              . "archiver requires `AM_PROG_AR' in `$configure_ac'")
+       }
     }
 }
 
@@ -3073,7 +2926,7 @@ sub check_typos ()
 
          for my $cond ($var->conditions->conds)
            {
-             $varname =~ /^(?:nobase_)?(?:dist_|nodist_)?(.*)_[[:alnum:]]+$/;
+             $varname =~ /^(?:EXTRA_)?(?:nobase_)?(?:dist_|nodist_)?(.*)_[[:alnum:]]+$/;
              msg_var ('syntax', $var, "variable `$varname' is defined but no"
                       . " program or\nlibrary has `$1' as canonical name"
                       . " (possible typo)")
@@ -3262,6 +3115,9 @@ sub output_texinfo_build_rules ($$$@)
 
   $output_rules .= file_contents ('texibuild',
                                  new Automake::Location,
+                                  AM_V_MAKEINFO    => verbose_flag('MAKEINFO'),
+                                  AM_V_TEXI2DVI    => verbose_flag('TEXI2DVI'),
+                                  AM_V_TEXI2PDF    => verbose_flag('TEXI2PDF'),
                                  DEPS             => "@deps",
                                  DEST_PREFIX      => $dpfx,
                                  DEST_INFO_PREFIX => $dipfx,
@@ -3271,12 +3127,15 @@ sub output_texinfo_build_rules ($$$@)
                                  GENERIC_INFO     => $generic_info,
                                  INSRC            => $insrc,
                                  MAKEINFOFLAGS    => $makeinfoflags,
+                                  SILENT           => silent_flag(),
                                  SOURCE           => ($generic
                                                       ? '$<' : $source),
                                  SOURCE_INFO      => ($generic_info
                                                       ? '$<' : $source),
                                  SOURCE_REAL      => $source,
                                  SOURCE_SUFFIX    => $ssfx,
+                                  TEXIQUIET        => verbose_flag('texinfo'),
+                                  TEXIDEVNULL      => verbose_flag('texidevnull'),
                                  );
   return ($dirstamp, "$dpfx.dvi", "$dpfx.pdf", "$dpfx.ps", "$dpfx.html");
 }
@@ -3585,6 +3444,7 @@ sub handle_texinfo ()
   my ($mostlyclean, $clean, $maintclean) = ('', '', '');
   if ($info_texinfos)
     {
+      define_verbose_texinfo;
       ($mostlyclean, $clean, $maintclean) = handle_texinfo_helper ($info_texinfos);
       chomp $mostlyclean;
       chomp $clean;
@@ -3593,10 +3453,12 @@ sub handle_texinfo ()
 
   $output_rules .=  file_contents ('texinfos',
                                   new Automake::Location,
+                                   AM_V_DVIPS    => verbose_flag('DVIPS'),
                                   MOSTLYCLEAN   => $mostlyclean,
                                   TEXICLEAN     => $clean,
                                   MAINTCLEAN    => $maintclean,
-                                  'LOCAL-TEXIS' => !!$info_texinfos);
+                                  'LOCAL-TEXIS' => !!$info_texinfos,
+                                   TEXIQUIET     => verbose_flag('texinfo'));
 }
 
 
@@ -3753,6 +3615,7 @@ sub handle_tags
 {
     my @tag_deps = ();
     my @ctag_deps = ();
+    my @cscope_deps = ();
     if (var ('SUBDIRS'))
     {
        $output_rules .= ("tags-recursive:\n"
@@ -3776,6 +3639,17 @@ sub handle_tags
        push (@ctag_deps, 'ctags-recursive');
        &depend ('.PHONY', 'ctags-recursive');
        &depend ('.MAKE', 'ctags-recursive');
+
+       $output_rules .= ("cscopelist-recursive:\n"
+                         . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
+                         # Never fail here if a subdir fails; it
+                         # isn't important.
+                         . "\t  test \"\$\$subdir\" = . || (\$(am__cd) \$\$subdir"
+                         . " && \$(MAKE) \$(AM_MAKEFLAGS) cscopelist); \\\n"
+                         . "\tdone\n");
+       push (@cscope_deps, 'cscopelist-recursive');
+       &depend ('.PHONY', 'cscopelist-recursive');
+       &depend ('.MAKE', 'cscopelist-recursive');
     }
 
     if (&saw_sources_p (1)
@@ -3798,13 +3672,14 @@ sub handle_tags
                                         new Automake::Location,
                                         CONFIG    => "@config",
                                         TAGSDIRS  => "@tag_deps",
-                                        CTAGSDIRS => "@ctag_deps");
+                                        CTAGSDIRS => "@ctag_deps",
+                                        CSCOPEDIRS => "@cscope_deps");
 
        set_seen 'TAGS_DEPENDENCIES';
     }
     elsif (reject_var ('TAGS_DEPENDENCIES',
-                      "doesn't make sense to define `TAGS_DEPENDENCIES'"
-                      . "without\nsources or `ETAGS_ARGS'"))
+                      "it doesn't make sense to define `TAGS_DEPENDENCIES'"
+                      . " without\nsources or `ETAGS_ARGS'"))
     {
     }
     else
@@ -3813,18 +3688,9 @@ sub handle_tags
        # Otherwise, it would be possible for a top-level "make TAGS"
        # to fail because some subdirectory failed.
        $output_rules .= "tags: TAGS\nTAGS:\n\n";
-       # Ditto ctags.
+       # Ditto ctags and cscope.
        $output_rules .= "ctags: CTAGS\nCTAGS:\n\n";
-    }
-}
-
-# Handle multilib support.
-sub handle_multilib
-{
-  if ($seen_multilib && $relative_dir eq '.')
-    {
-      $output_rules .= &file_contents ('multilib', new Automake::Location);
-      push (@all, 'all-multi');
+       $output_rules .= "cscope cscopelist:\n\n";
     }
 }
 
@@ -3926,7 +3792,7 @@ sub handle_dist ()
       $archive_defined ||=
        grep { option "dist-$_" } qw(shar zip tarZ bzip2 lzip lzma xz);
       error (option 'no-dist-gzip',
-            "no-dist-gzip specified but no dist-* specified, "
+            "no-dist-gzip specified but no dist-* specified,\n"
             . "at least one archive format must be enabled")
        unless $archive_defined;
     }
@@ -3965,12 +3831,19 @@ sub handle_dist ()
   # directory, we would have discovered it already, so we don't
   # check that.  But if the file is in a subdir without a Makefile,
   # we want to distribute it here if we are doing `.'.  Ugly!
+  # Also, in some corner cases, it's possible that the following code
+  # will cause the same file to appear in the $(DIST_COMMON) variables
+  # of two distinct Makefiles; but this is not a problem, since the
+  # `distdir' target in `lib/am/distdir.am' can deal with the same
+  # file being distributed multiple times.
+  # See also automake bug#9651.
   if ($relative_dir eq '.')
     {
       foreach my $file (split (' ' , $configure_dist_common))
        {
+         my $dir = dirname ($file);
          push_dist_common ($file)
-           unless is_make_dir (dirname ($file));
+           if ($dir eq '.' || ! is_make_dir ($dir));
        }
     }
 
@@ -4011,16 +3884,17 @@ sub handle_dist ()
 }
 
 
-# check_directory ($NAME, $WHERE)
-# -------------------------------
-# Ensure $NAME is a directory, and that it uses a sane name.
-# Use $WHERE as a location in the diagnostic, if any.
-sub check_directory ($$)
+# check_directory ($NAME, $WHERE [, $RELATIVE_DIR = "."])
+# -------------------------------------------------------
+# Ensure $NAME is a directory (in $RELATIVE_DIR), and that it uses a sane
+# name.  Use $WHERE as a location in the diagnostic, if any.
+sub check_directory ($$;$)
 {
-  my ($dir, $where) = @_;
+  my ($dir, $where, $reldir) = @_;
+  $reldir = '.' unless defined $reldir;
 
-  error $where, "required directory $relative_dir/$dir does not exist"
-    unless -d "$relative_dir/$dir";
+  error $where, "required directory $reldir/$dir does not exist"
+    unless -d "$reldir/$dir";
 
   # If an `obj/' directory exists, BSD make will enter it before
   # reading `Makefile'.  Hence the `Makefile' in the current directory
@@ -4059,7 +3933,7 @@ sub check_directories_in_var ($)
     (sub
      {
        my ($var, $val, $cond, $full_cond) = @_;
-       check_directory ($val, $var->rdef ($cond)->location);
+       check_directory ($val, $var->rdef ($cond)->location, $relative_dir);
        return ();
      },
      undef,
@@ -4113,7 +3987,7 @@ sub scan_aclocal_m4 ()
       push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
       msg_var ('obsolete', 'ACLOCAL_M4_SOURCES',
               "`ACLOCAL_M4_SOURCES' is obsolete.\n"
-              . "It should be safe to simply remove it.");
+              . "It should be safe to simply remove it");
     }
 
   # Note that it might be possible that aclocal.m4 doesn't exist but
@@ -4925,6 +4799,58 @@ sub handle_tests_dejagnu
     $output_rules .= file_contents ('dejagnu', new Automake::Location);
 }
 
+sub handle_per_suffix_test
+{
+  my ($test_suffix, %transform) = @_;
+  my ($pfx, $generic, $parallel_tests_option, $am_exeext);
+  prog_error ("called with 'parallel-tests' option not set")
+    unless $parallel_tests_option = option 'parallel-tests';
+  if ($test_suffix eq '')
+    {
+      $pfx = '';
+      $generic = 0;
+      $am_exeext = 'FALSE';
+    }
+  else
+    {
+      prog_error ("test suffix `$test_suffix' lacks leading dot")
+        unless $test_suffix =~ m/^\.(.*)/;
+      $pfx = uc ($1) . '_';
+      $generic = 1;
+      $am_exeext = exists $configure_vars{'EXEEXT'} ? 'am__EXEEXT'
+                                                    : 'FALSE';
+    }
+  # The "test driver" program, deputed to handle tests protocol used by
+  # test scripts.  By default, it's assumed that no protocol is used,
+  # so we fall back to the old "parallel-tests" behaviour, implemented
+  # by the `test-driver' auxiliary script.
+  if (! var "${pfx}LOG_DRIVER")
+    {
+      require_conf_file ($parallel_tests_option->{position}, FOREIGN,
+                        'test-driver');
+      define_variable ("${pfx}LOG_DRIVER",
+                       "\$(SHELL) $am_config_aux_dir/test-driver",
+                       INTERNAL);
+    }
+  my $driver = '$(' . $pfx . 'LOG_DRIVER)';
+  my $driver_flags = '$(AM_' . $pfx . 'LOG_DRIVER_FLAGS)'
+                       . ' $(' . $pfx . 'LOG_DRIVER_FLAGS)';
+  my $compile = "${pfx}LOG_COMPILE";
+  define_variable ($compile,
+                   '$(' . $pfx . 'LOG_COMPILER)'
+                      . ' $(AM_' .  $pfx . 'LOG_FLAGS)'
+                      . ' $(' . $pfx . 'LOG_FLAGS)',
+                     INTERNAL);
+  $output_rules .= file_contents ('check2', new Automake::Location,
+                                   GENERIC => $generic,
+                                   DRIVER => $driver,
+                                   DRIVER_FLAGS => $driver_flags,
+                                   COMPILE => '$(' . $compile . ')',
+                                   EXT => $test_suffix,
+                                   am__EXEEXT => $am_exeext,
+                                   %transform);
+}
+
 # is_valid_test_extension ($EXT)
 # ------------------------------
 # Return true if $EXT can appear in $(TEST_EXTENSIONS), return false
@@ -4970,7 +4896,7 @@ sub handle_tests
       append_exeext { exists $known_programs{$_[0]} } 'XFAIL_TESTS'
        if (var ('XFAIL_TESTS'));
 
-      if (option 'parallel-tests')
+      if (my $parallel_tests = option 'parallel-tests')
         {
          define_variable ('TEST_SUITE_LOG', 'test-suite.log', INTERNAL);
          my $suff = '.test';
@@ -5030,17 +4956,12 @@ sub handle_tests
                    return substr ($obj, 0, length ($obj) - length ($test_suffix)) . '.log'
                      if substr ($obj, - length ($test_suffix)) eq $test_suffix;
                  }
+               my $base = $obj;
                $obj .= '.log';
-               my $compile = 'LOG_COMPILE';
-               define_variable ($compile,
-                                '$(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)', INTERNAL);
-               $output_rules .= file_contents ('check2', new Automake::Location,
-                                               GENERIC => 0,
-                                               OBJ => $obj,
-                                               SOURCE => $val,
-                                               COMPILE =>'$(' . $compile . ')',
-                                               EXT => '',
-                                               am__EXEEXT => 'FALSE');
+                handle_per_suffix_test ('',
+                                        OBJ => $obj,
+                                        BASE => $base,
+                                        SOURCE => $val);
                return $obj;
              });
 
@@ -5066,27 +4987,14 @@ sub handle_tests
              $nhelper++;
              if ($test_suffix ne $at_exeext && $test_suffix ne '')
                {
-                 (my $ext = $test_suffix) =~ s/^\.//;
-                 $ext = uc $ext;
-                 my $compile = $ext . '_LOG_COMPILE';
-                 define_variable ($compile,
-                                  '$(' . $ext . '_LOG_COMPILER) $(AM_' .  $ext . '_LOG_FLAGS)'
-                                  . ' $(' . $ext . '_LOG_FLAGS)', INTERNAL);
-                 my $am_exeext = $handle_exeext ? 'am__EXEEXT' : 'FALSE';
-                 $output_rules .= file_contents ('check2', new Automake::Location,
-                                                 GENERIC => 1,
-                                                 OBJ => '',
-                                                 SOURCE => '$<',
-                                                 COMPILE => '$(' . $compile . ')',
-                                                 EXT => $test_suffix,
-                                                 am__EXEEXT => $am_exeext);
+                  handle_per_suffix_test ($test_suffix,
+                                          OBJ => '',
+                                          BASE => '$*',
+                                          SOURCE => '$<');
                }
            }
-
-         define_variable ('TEST_LOGS_TMP', '$(TEST_LOGS:.log=.log-t)', INTERNAL);
-
-         $clean_files{'$(TEST_LOGS_TMP)'} = MOSTLY_CLEAN;
          $clean_files{'$(TEST_LOGS)'} = MOSTLY_CLEAN;
+         $clean_files{'$(TEST_LOGS:.log=.trs)'} = MOSTLY_CLEAN;
          $clean_files{'$(TEST_SUITE_LOG)'} = MOSTLY_CLEAN;
        }
     }
@@ -5304,11 +5212,11 @@ sub scan_autoconf_traces ($)
                AC_SUBST_TRACE => 1,
                AM_AUTOMAKE_VERSION => 1,
                AM_CONDITIONAL => 2,
-               AM_ENABLE_MULTILIB => 0,
                AM_GNU_GETTEXT => 0,
                AM_GNU_GETTEXT_INTL_SUBDIR => 0,
                AM_INIT_AUTOMAKE => 0,
                AM_MAINTAINER_MODE => 0,
+               AM_PROG_AR => 0,
                AM_PROG_CC_C_O => 0,
                AM_SILENT_RULES => 0,
                _AM_SUBST_NOTMAKE => 1,
@@ -5380,12 +5288,11 @@ sub scan_autoconf_traces ($)
          if ($seen_init_automake)
            {
              error ($where, "AC_CONFIG_AUX_DIR must be called before "
-                    . "AM_INIT_AUTOMAKE...", partial => 1);
+                    . "AM_INIT_AUTOMAKE ...", partial => 1);
              error ($seen_init_automake, "... AM_INIT_AUTOMAKE called here");
            }
          $config_aux_dir = $args[1];
          $config_aux_dir_set_in_configure_ac = 1;
-         $relative_dir = '.';
          check_directory ($config_aux_dir, $where);
        }
       elsif ($macro eq 'AC_CONFIG_FILES')
@@ -5405,7 +5312,6 @@ sub scan_autoconf_traces ($)
       elsif ($macro eq 'AC_CONFIG_LIBOBJ_DIR')
        {
          $config_libobj_dir = $args[1];
-         $relative_dir = '.';
          check_directory ($config_libobj_dir, $where);
        }
       elsif ($macro eq 'AC_CONFIG_LINKS')
@@ -5467,10 +5373,6 @@ sub scan_autoconf_traces ($)
        {
          $configure_cond{$args[1]} = $where;
        }
-      elsif ($macro eq 'AM_ENABLE_MULTILIB')
-       {
-         $seen_multilib = $where;
-       }
       elsif ($macro eq 'AM_GNU_GETTEXT')
        {
          $seen_gettext = $where;
@@ -5491,15 +5393,19 @@ sub scan_autoconf_traces ($)
            }
          elsif (defined $args[1])
            {
-             exit $exit_code
-               if (process_global_option_list ($where,
-                                               split (' ', $args[1])));
+             my @opts = split (' ', $args[1]);
+             @opts = map { { option => $_, where => $where } } @opts;
+             exit $exit_code if process_global_option_list (@opts);
            }
        }
       elsif ($macro eq 'AM_MAINTAINER_MODE')
        {
          $seen_maint_mode = $where;
        }
+      elsif ($macro eq 'AM_PROG_AR')
+       {
+         $seen_ar = $where;
+       }
       elsif ($macro eq 'AM_PROG_CC_C_O')
        {
          $seen_cc_c_o = $where;
@@ -5616,7 +5522,7 @@ sub scan_autoconf_files ()
              . "should verify that $configure_ac invokes AM_INIT_AUTOMAKE,"
              . "\nthat aclocal.m4 is present in the top-level directory,\n"
              . "and that aclocal.m4 was recently regenerated "
-             . "(using aclocal).");
+             . "(using aclocal)");
     }
   else
     {
@@ -5627,7 +5533,7 @@ sub scan_autoconf_files ()
              error ($seen_init_automake,
                     "your implementation of AM_INIT_AUTOMAKE comes from " .
                     "an\nold Automake version.  You should recreate " .
-                    "aclocal.m4\nwith aclocal and run automake again.\n",
+                    "aclocal.m4\nwith aclocal and run automake again",
                     # $? = 63 is used to indicate version mismatch to missing.
                     exit_code => 63);
            }
@@ -5635,50 +5541,19 @@ sub scan_autoconf_files ()
            {
              error ($seen_init_automake,
                     "no proper implementation of AM_INIT_AUTOMAKE was " .
-                    "found,\nprobably because aclocal.m4 is missing...\n" .
+                    "found,\nprobably because aclocal.m4 is missing.\n" .
                     "You should run aclocal to create this file, then\n" .
-                    "run automake again.\n");
+                    "run automake again");
            }
        }
     }
 
   locate_aux_dir ();
 
-  # Reorder @input_files so that the Makefile that distributes aux
-  # files is processed last.  This is important because each directory
-  # can require auxiliary scripts and we should wait until they have
-  # been installed before distributing them.
-
-  # The Makefile.in that distribute the aux files is the one in
-  # $config_aux_dir or the top-level Makefile.
-  my $auxdirdist = is_make_dir ($config_aux_dir) ? $config_aux_dir : '.';
-  my @new_input_files = ();
-  while (@input_files)
-    {
-      my $in = pop @input_files;
-      my @ins = split (/:/, $output_files{$in});
-      if (dirname ($ins[0]) eq $auxdirdist)
-       {
-         push @new_input_files, $in;
-         $automake_will_process_aux_dir = 1;
-       }
-      else
-       {
-         unshift @new_input_files, $in;
-       }
-    }
-  @input_files = @new_input_files;
-
-  # If neither the auxdir/Makefile nor the ./Makefile are generated
-  # by Automake, we won't distribute the aux files anyway.  Assume
-  # the user know what (s)he does, and pretend we will distribute
-  # them to disable the error in require_file_internal.
-  $automake_will_process_aux_dir = 1 if ! is_make_dir ($auxdirdist);
-
   # Look for some files we need.  Always check for these.  This
   # check must be done for every run, even those where we are only
   # looking at a subdir Makefile.  We must set relative_dir for
-  # maybe_push_required_file to work.
+  # push_required_file to work.
   # Sort the files for stable verbose output.
   $relative_dir = '.';
   foreach my $file (sort keys %required_aux_file)
@@ -5777,13 +5652,7 @@ sub lang_sub_obj
 # Rewrite a single C source file.
 sub lang_c_rewrite
 {
-  my ($directory, $base, $ext, $nonansi_obj, $have_per_exec_flags, $var) = @_;
-
-  if (option 'ansi2knr' && $base =~ /_$/)
-    {
-      # FIXME: include line number in error.
-      err_am "C source file `$base.c' would be deleted by ansi2knr rules";
-    }
+  my ($directory, $base, $ext, $obj, $have_per_exec_flags, $var) = @_;
 
   my $r = LANG_PROCESS;
   if (option 'subdir-objects')
@@ -5800,24 +5669,14 @@ sub lang_c_rewrite
                   . "`AM_PROG_CC_C_O' in `$configure_ac'",
                   uniq_scope => US_GLOBAL,
                   uniq_part => 'AM_PROG_CC_C_O subdir')
-           unless $seen_cc_c_o || $nonansi_obj eq '.lo';
+           unless $seen_cc_c_o || $obj eq '.lo';
        }
-
-      # In this case we already have the directory information, so
-      # don't add it again.
-      $de_ansi_files{$base} = '';
-    }
-  else
-    {
-      $de_ansi_files{$base} = (($directory eq '.' || $directory eq '')
-                              ? ''
-                              : "$directory/");
     }
 
   if (! $seen_cc_c_o
       && $have_per_exec_flags
       && ! option 'subdir-objects'
-      && $nonansi_obj ne '.lo')
+      && $obj ne '.lo')
     {
       msg_var ('portability',
               $var, "compiling `$base.c' with per-target flags requires "
@@ -5956,59 +5815,6 @@ sub lang_java_rewrite
 # language, etc.  A finish function is only called if a source file of
 # the appropriate type has been seen.
 
-sub lang_c_finish
-{
-    # Push all libobjs files onto de_ansi_files.  We actually only
-    # push files which exist in the current directory, and which are
-    # genuine source files.
-    foreach my $file (keys %libsources)
-    {
-       if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
-       {
-           $de_ansi_files{$1} = ''
-       }
-    }
-
-    if (option 'ansi2knr' && keys %de_ansi_files)
-    {
-       # Make all _.c files depend on their corresponding .c files.
-       my @objects;
-       foreach my $base (sort keys %de_ansi_files)
-       {
-           # Each _.c file must depend on ansi2knr; otherwise it
-           # might be used in a parallel build before it is built.
-           # We need to support files in the srcdir and in the build
-           # dir (because these files might be auto-generated.  But
-           # we can't use $< -- some makes only define $< during a
-           # suffix rule.
-           my $ansfile = $de_ansi_files{$base} . $base . '.c';
-           $output_rules .= ($base . "_.c: $ansfile \$(ANSI2KNR)\n\t"
-                             . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
-                             . '`if test -f $(srcdir)/' . $ansfile
-                             . '; then echo $(srcdir)/' . $ansfile
-                             . '; else echo ' . $ansfile . '; fi` '
-                             . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
-                             . '| $(ANSI2KNR) > $@'
-                             # If ansi2knr fails then we shouldn't
-                             # create the _.c file
-                             . " || rm -f \$\@\n");
-           push (@objects, $base . '_.$(OBJEXT)');
-           push (@objects, $base . '_.lo')
-             if var ('LIBTOOL');
-
-           # Explicitly clean the _.c files if they are in a
-           # subdirectory. (In the current directory they get erased
-           # by a `rm -f *_.c' rule.)
-           $clean_files{$base . '_.c'} = MOSTLY_CLEAN
-             if dirname ($base) ne '.';
-       }
-
-       # Make all _.o (and _.lo) files depend on ansi2knr.
-       # Use a sneaky little hack to make it print nicely.
-       &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
-    }
-}
-
 sub lang_vala_finish_target ($$)
 {
   my ($self, $name) = @_;
@@ -6127,12 +5933,29 @@ sub lang_yacc_target_hook
 {
     my ($self, $aggregate, $output, $input, %transform) = @_;
 
-    my $flag = $aggregate . "_YFLAGS";
-    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))
-    {
+    # If some relevant *YFLAGS variable contains the `-d' flag, we'll
+    # have to to generate special code.
+    my $yflags_contains_minus_d = 0;
+
+    foreach my $pfx ("", "${aggregate}_")
+      {
+       my $yflagsvar = var ("${pfx}YFLAGS");
+       next unless $yflagsvar;
+       # We cannot work reliably with conditionally-defined YFLAGS.
+       if ($yflagsvar->has_conditional_contents)
+         {
+           msg_var ('unsupported', $yflagsvar,
+                    "`${pfx}YFLAGS' cannot have conditional contents");
+         }
+       else
+         {
+           $yflags_contains_minus_d = 1
+             if grep (/^-d$/, $yflagsvar->value_as_list_recursive);
+         }
+      }
+
+    if ($yflags_contains_minus_d)
+      {
        (my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//;
        my $header = $output_base . '.h';
 
@@ -6156,17 +5979,14 @@ sub lang_yacc_target_hook
        &push_dist_common ($header)
          if $transform{'DIST_SOURCE'};
 
-       # If the files are built in the build directory, then we want
-       # to remove them with `make clean'.  If they are in srcdir
-       # they shouldn't be touched.  However, we can't determine this
-       # statically, and the GNU rules say that yacc/lex output files
-       # should be removed by maintainer-clean.  So that's what we
-       # do.
-       $clean_files{$header} = MAINTAINER_CLEAN;
-    }
-    # Erase $OUTPUT on `make maintainer-clean' (by GNU standards).
+       # The GNU rules say that yacc/lex output files should be removed
+       # by maintainer-clean.  However, if the files are not distributed,
+       # then we want to remove them with "make clean"; otherwise,
+       # "make distcheck" will fail.
+       $clean_files{$header} = $transform{'DIST_SOURCE'} ? MAINTAINER_CLEAN : CLEAN;
+      }
     # See the comment above for $HEADER.
-    $clean_files{$output} = MAINTAINER_CLEAN;
+    $clean_files{$output} = $transform{'DIST_SOURCE'} ? MAINTAINER_CLEAN : CLEAN;
 }
 
 # This is a lex helper which is called whenever we have decided to
@@ -6311,8 +6131,6 @@ sub register_language (%)
   my (%option) = @_;
 
   # Set the defaults.
-  $option{'ansi'} = 0
-    unless defined $option{'ansi'};
   $option{'autodep'} = 'no'
     unless defined $option{'autodep'};
   $option{'linker'} = ''
@@ -6437,7 +6255,7 @@ sub cond_stack_if ($$$)
          my $mac = $_am_macro_for_cond{$cond};
          $text .= "\n  The usual way to define `$cond' is to add ";
          $text .= ($mac =~ / /) ? $mac : "`$mac'";
-         $text .= "\n  to `$configure_ac' and run `aclocal' and `autoconf' again.";
+         $text .= "\n  to `$configure_ac' and run `aclocal' and `autoconf' again";
          # These warnings appear in Automake files (depend2.am),
          # so there is no need to display them more than once:
          $scope = US_GLOBAL;
@@ -6569,22 +6387,11 @@ sub define_files_variable ($\@$$)
 sub define_configure_variable ($)
 {
   my ($var) = @_;
-
-  my $pretty = VAR_ASIS;
-  my $owner = VAR_CONFIGURE;
-
   # Some variables we do not want to output.  For instance it
   # would be a bad idea to output `U = @U@` when `@U@` can be
   # substituted as `\`.
-  $pretty = VAR_SILENT if exists $ignored_configure_vars{$var};
-
-  # ANSI2KNR is a variable that Automake wants to redefine, so
-  # it must be owned by Automake.  (It is also used as a proof
-  # that AM_C_PROTOTYPES has been run, that's why we do not simply
-  # omit the AC_SUBST.)
-  $owner = VAR_AUTOMAKE if $var eq 'ANSI2KNR';
-
-  Automake::Variable::define ($var, $owner, '', TRUE, subst $var,
+  my $pretty = exists $ignored_configure_vars{$var} ? VAR_SILENT : VAR_ASIS;
+  Automake::Variable::define ($var, VAR_CONFIGURE, '', TRUE, subst $var,
                              '', $configure_vars{$var}, $pretty);
 }
 
@@ -7780,18 +7587,42 @@ sub locate_aux_dir ()
 }
 
 
-# &maybe_push_required_file ($DIR, $FILE, $FULLFILE)
+# &push_required_file ($DIR, $FILE, $FULLFILE)
 # --------------------------------------------------
-# See if we want to push this file onto dist_common.  This function
-# encodes the rules for deciding when to do so.
-sub maybe_push_required_file
+# Push the given file onto DIST_COMMON.
+sub push_required_file
 {
   my ($dir, $file, $fullfile) = @_;
 
+  # If the file to be distributed is in the same directory of the
+  # currently processed Makefile.am, then we want to distribute it
+  # from this same Makefile.am.
   if ($dir eq $relative_dir)
     {
       push_dist_common ($file);
-      return 1;
+    }
+  # This is needed to allow a construct in a non-top-level Makefile.am
+  # to require a file in the build-aux directory (see at least the test
+  # script `test-driver-is-distributed.test').  This is related to the
+  # automake bug#9546.  Note that the use of $config_aux_dir instead
+  # of $am_config_aux_dir here is deliberate and necessary.
+  elsif ($dir eq $config_aux_dir)
+    {
+      push_dist_common ("$am_config_aux_dir/$file");
+    }
+  # FIXME: another spacial case, for AC_LIBOBJ/AC_LIBSOURCE support.
+  # We probably need some refactoring of this function and its callers,
+  # to have a more explicit and systematic handling of all the special
+  # cases; but, since there are only two of them, this is low-priority
+  # ATM.
+  elsif ($config_libobj_dir && $dir eq $config_libobj_dir)
+    {
+      # Avoid unsightly '/.'s.
+      my $am_config_libobj_dir =
+        '$(top_srcdir)' .
+        ($config_libobj_dir eq '.' ? "" : "/$config_libobj_dir");
+      $am_config_libobj_dir =~ s|/*$||;
+      push_dist_common ("$am_config_libobj_dir/$file");
     }
   elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
     {
@@ -7829,9 +7660,12 @@ sub maybe_push_required_file
        if $dir =~ m,^\.\.(?:$|/),;
 
       push_dist_common ($fullfile);
-      return 1;
     }
-  return 0;
+  else
+    {
+      prog_error "a Makefile in relative directory $relative_dir " .
+                 "can't add files in directory $dir to DIST_COMMON";
+    }
 }
 
 
@@ -7840,140 +7674,141 @@ sub maybe_push_required_file
 # than once.
 my %required_file_not_found = ();
 
-# &require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, @FILES)
-# --------------------------------------------------------------
+# &required_file_check_or_copy ($WHERE, $DIRECTORY, $FILE)
+# --------------------------------------------------------
 # Verify that the file must exist in $DIRECTORY, or install it.
-# $MYSTRICT is the strictness level at which this file becomes required.
-sub require_file_internal ($$$@)
+sub required_file_check_or_copy ($$$)
 {
-  my ($where, $mystrict, $dir, @files) = @_;
+  my ($where, $dir, $file) = @_;
 
-  foreach my $file (@files)
+  my $fullfile = "$dir/$file";
+  my $found_it = 0;
+  my $dangling_sym = 0;
+
+  if (-l $fullfile && ! -f $fullfile)
     {
-      my $fullfile = "$dir/$file";
-      my $found_it = 0;
-      my $dangling_sym = 0;
+      $dangling_sym = 1;
+    }
+  elsif (dir_has_case_matching_file ($dir, $file))
+    {
+      $found_it = 1;
+    }
 
-      if (-l $fullfile && ! -f $fullfile)
-       {
-         $dangling_sym = 1;
-       }
-      elsif (dir_has_case_matching_file ($dir, $file))
-       {
-         $found_it = 1;
-         maybe_push_required_file ($dir, $file, $fullfile);
-       }
+  # `--force-missing' only has an effect if `--add-missing' is
+  # specified.
+  return
+    if $found_it && (! $add_missing || ! $force_missing);
 
-      # `--force-missing' only has an effect if `--add-missing' is
-      # specified.
-      if ($found_it && (! $add_missing || ! $force_missing))
-       {
-         next;
-       }
-      else
-       {
-         # If we've already looked for it, we're done.  You might
-         # wonder why we don't do this before searching for the
-         # file.  If we do that, then something like
-         # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
-         # DIST_COMMON.
-         if (! $found_it)
-           {
-             next if defined $required_file_not_found{$fullfile};
-             $required_file_not_found{$fullfile} = 1;
-           }
+  # If we've already looked for it, we're done.  You might
+  # wonder why we don't do this before searching for the
+  # file.  If we do that, then something like
+  # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
+  # DIST_COMMON.
+  if (! $found_it)
+    {
+      return if defined $required_file_not_found{$fullfile};
+      $required_file_not_found{$fullfile} = 1;
+    }
+  if ($dangling_sym && $add_missing)
+    {
+      unlink ($fullfile);
+    }
 
-         if ($strictness >= $mystrict)
-           {
-             if ($dangling_sym && $add_missing)
-               {
-                 unlink ($fullfile);
-               }
+  my $trailer = '';
+  my $trailer2 = '';
+  my $suppress = 0;
 
-             my $trailer = '';
-             my $trailer2 = '';
-             my $suppress = 0;
+  # Only install missing files according to our desired
+  # strictness level.
+  my $message = "required file `$fullfile' not found";
+  if ($add_missing)
+    {
+      if (-f "$libdir/$file")
+        {
+          $suppress = 1;
 
-             # Only install missing files according to our desired
-             # strictness level.
-             my $message = "required file `$fullfile' not found";
-             if ($add_missing)
-               {
-                 if (-f "$libdir/$file")
-                   {
-                     $suppress = 1;
-
-                     # Install the missing file.  Symlink if we
-                     # can, copy if we must.  Note: delete the file
-                     # first, in case it is a dangling symlink.
-                     $message = "installing `$fullfile'";
-
-                     # The license file should not be volatile.
-                     if ($file eq "COPYING")
-                       {
-                         $message .= " using GNU General Public License v3 file";
-                         $trailer2 = "\n    Consider adding the COPYING file"
-                                   . " to the version control system"
-                                   . "\n    for your code, to avoid questions"
-                                   . " about which license your project uses.";
-                       }
+          # Install the missing file.  Symlink if we
+          # can, copy if we must.  Note: delete the file
+          # first, in case it is a dangling symlink.
+          $message = "installing `$fullfile'";
 
-                     # Windows Perl will hang if we try to delete a
-                     # file that doesn't exist.
-                     unlink ($fullfile) if -f $fullfile;
-                     if ($symlink_exists && ! $copy_missing)
-                       {
-                         if (! symlink ("$libdir/$file", $fullfile)
-                             || ! -e $fullfile)
-                           {
-                             $suppress = 0;
-                             $trailer = "; error while making link: $!";
-                           }
-                       }
-                     elsif (system ('cp', "$libdir/$file", $fullfile))
-                       {
-                         $suppress = 0;
-                         $trailer = "\n    error while copying";
-                       }
-                     set_dir_cache_file ($dir, $file);
-                   }
+          # The license file should not be volatile.
+          if ($file eq "COPYING")
+            {
+              $message .= " using GNU General Public License v3 file";
+              $trailer2 = "\n    Consider adding the COPYING file"
+                        . " to the version control system"
+                        . "\n    for your code, to avoid questions"
+                        . " about which license your project uses";
+            }
 
-                 if (! maybe_push_required_file (dirname ($fullfile),
-                                                 $file, $fullfile))
-                   {
-                     if (! $found_it && ! $automake_will_process_aux_dir)
-                       {
-                         # We have added the file but could not push it
-                         # into DIST_COMMON, probably because this is
-                         # an auxiliary file and we are not processing
-                         # the top level Makefile.  Furthermore Automake
-                         # hasn't been asked to create the Makefile.in
-                         # that distributes the aux dir files.
-                         error ($where, 'Please make a full run of automake'
-                                . " so $fullfile gets distributed.");
-                       }
-                   }
-               }
-             else
-               {
-                 $trailer = "\n  `automake --add-missing' can install `$file'"
-                   if -f "$libdir/$file";
-               }
+          # Windows Perl will hang if we try to delete a
+          # file that doesn't exist.
+          unlink ($fullfile) if -f $fullfile;
+          if ($symlink_exists && ! $copy_missing)
+            {
+              if (! symlink ("$libdir/$file", $fullfile)
+                  || ! -e $fullfile)
+                {
+                  $suppress = 0;
+                  $trailer = "; error while making link: $!";
+                }
+            }
+          elsif (system ('cp', "$libdir/$file", $fullfile))
+            {
+              $suppress = 0;
+              $trailer = "\n    error while copying";
+            }
+          set_dir_cache_file ($dir, $file);
+        }
+    }
+  else
+    {
+      $trailer = "\n  `automake --add-missing' can install `$file'"
+        if -f "$libdir/$file";
+    }
 
-             # If --force-missing was specified, and we have
-             # actually found the file, then do nothing.
-             next
-               if $found_it && $force_missing;
+  # If --force-missing was specified, and we have
+  # actually found the file, then do nothing.
+  return
+    if $found_it && $force_missing;
 
-             # If we couldn't install the file, but it is a target in
-             # the Makefile, don't print anything.  This allows files
-             # like README, AUTHORS, or THANKS to be generated.
-             next
-               if !$suppress && rule $file;
+  # If we couldn't install the file, but it is a target in
+  # the Makefile, don't print anything.  This allows files
+  # like README, AUTHORS, or THANKS to be generated.
+  return
+    if !$suppress && rule $file;
 
-             msg ($suppress ? 'note' : 'error', $where, "$message$trailer$trailer2");
-           }
-       }
+  msg ($suppress ? 'note' : 'error', $where, "$message$trailer$trailer2");
+}
+
+
+# &require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, $QUEUE, @FILES)
+# ----------------------------------------------------------------------
+# Verify that the file must exist in $DIRECTORY, or install it.
+# $MYSTRICT is the strictness level at which this file becomes required.
+# Worker threads may queue up the action to be serialized by the master,
+# if $QUEUE is true
+sub require_file_internal ($$$@)
+{
+  my ($where, $mystrict, $dir, $queue, @files) = @_;
+
+  return
+    unless $strictness >= $mystrict;
+
+  foreach my $file (@files)
+    {
+      push_required_file ($dir, $file, "$dir/$file");
+      if ($queue)
+        {
+          queue_required_file_check_or_copy ($required_conf_file_queue,
+                                             QUEUE_CONF_FILE, $relative_dir,
+                                             $where, $mystrict, @files);
+        }
+      else
+        {
+          required_file_check_or_copy ($where, $dir, $file);
+        }
     }
 }
 
@@ -7982,7 +7817,7 @@ sub require_file_internal ($$$@)
 sub require_file ($$@)
 {
     my ($where, $mystrict, @files) = @_;
-    require_file_internal ($where, $mystrict, $relative_dir, @files);
+    require_file_internal ($where, $mystrict, $relative_dir, 0, @files);
 }
 
 # &require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
@@ -8005,7 +7840,7 @@ sub require_libsource_with_macro ($$$@)
     if ($config_libobj_dir)
       {
        require_file_internal ($macro->rdef ($cond)->location, $mystrict,
-                              $config_libobj_dir, @files);
+                              $config_libobj_dir, 0, @files);
       }
     else
       {
@@ -8013,12 +7848,10 @@ sub require_libsource_with_macro ($$$@)
       }
 }
 
-# Queue to push require_conf_file requirements to.
-my $required_conf_file_queue;
-
-# &queue_required_conf_file ($QUEUE, $KEY, $DIR, $WHERE, $MYSTRICT, @FILES)
-# -------------------------------------------------------------------------
-sub queue_required_conf_file ($$$$@)
+# &queue_required_file_check_or_copy ($QUEUE, $KEY, $DIR, $WHERE,
+#                                     $MYSTRICT, @FILES)
+# ---------------------------------------------------------------
+sub queue_required_file_check_or_copy ($$$$@)
 {
     my ($queue, $key, $dir, $where, $mystrict, @files) = @_;
     my @serial_loc;
@@ -8033,9 +7866,9 @@ sub queue_required_conf_file ($$$$@)
     $queue->enqueue ($key, $dir, @serial_loc, $mystrict, 0 + @files, @files);
 }
 
-# &require_queued_conf_file ($QUEUE)
-# ----------------------------------
-sub require_queued_conf_file ($)
+# &require_queued_file_check_or_copy ($QUEUE)
+# -------------------------------------------
+sub require_queued_file_check_or_copy ($)
 {
     my ($queue) = @_;
     my $where;
@@ -8058,35 +7891,23 @@ sub require_queued_conf_file ($)
     my @files;
     push @files, $queue->dequeue ()
       foreach (1 .. $nfiles);
-
-    # Dequeuing happens outside of per-makefile context, so we have to
-    # set the variables used by require_file_internal and the functions
-    # it calls.  Gross!
-    $relative_dir = $dir;
-    require_file_internal ($where, $mystrict, $config_aux_dir, @files);
+    return
+      unless $strictness >= $mystrict;
+    foreach my $file (@files)
+      {
+        required_file_check_or_copy ($where, $config_aux_dir, $file);
+      }
 }
 
 # &require_conf_file ($WHERE, $MYSTRICT, @FILES)
 # ----------------------------------------------
-# Looks in configuration path, as specified by AC_CONFIG_AUX_DIR;
-# worker threads may queue up the action to be serialized by the master.
-#
-# FIXME: this seriously relies on the semantics of require_file_internal
-# and maybe_push_required_file, in that we exploit the fact that only the
-# contents of the last handled output file may be impacted (which in turn
-# is dealt with by the master thread).
+# Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
 sub require_conf_file ($$@)
 {
     my ($where, $mystrict, @files) = @_;
-    if (defined $required_conf_file_queue)
-      {
-       queue_required_conf_file ($required_conf_file_queue, QUEUE_CONF_FILE,
-                                 $relative_dir, $where, $mystrict, @files);
-      }
-    else
-      {
-       require_file_internal ($where, $mystrict, $config_aux_dir, @files);
-      }
+    my $queue = defined $required_conf_file_queue ? 1 : 0;
+    require_file_internal ($where, $mystrict, $config_aux_dir,
+                           $queue, @files);
 }
 
 
@@ -8272,7 +8093,6 @@ sub generate_makefile ($$)
       define_pretty_variable ('DIST_SOURCES', TRUE, INTERNAL, @dist_sources);
     }
 
-  handle_multilib;
   handle_texinfo;
   handle_emacs_lisp;
   handle_python;
@@ -8313,18 +8133,13 @@ sub generate_makefile ($$)
 
   check_typos;
 
-  my ($out_file) = $output_directory . '/' . $makefile_in;
-
   if ($exit_code != 0)
     {
-      verb "not writing $out_file because of earlier errors";
+      verb "not writing $makefile_in because of earlier errors";
       return;
     }
 
-  if (! -d ($output_directory . '/' . $am_relative_dir))
-    {
-      mkdir ($output_directory . '/' . $am_relative_dir, 0755);
-    }
+  mkdir ($am_relative_dir, 0755) if ! -d $am_relative_dir;
 
   # We make sure that `all:' is the first target.
   my $output =
@@ -8343,25 +8158,25 @@ sub generate_makefile ($$)
   #  * other dependencies, specific to the Makefile.am being processed
   #    (such as the Makefile.am itself, or any Makefile fragment
   #    it includes).
-  my $timestamp = mtime $out_file;
+  my $timestamp = mtime $makefile_in;
   if (! $force_generation
       && $configure_deps_greatest_timestamp < $timestamp
       && $output_deps_greatest_timestamp < $timestamp
-      && $output eq contents ($out_file))
+      && $output eq contents ($makefile_in))
     {
-      verb "$out_file unchanged";
+      verb "$makefile_in unchanged";
       # No need to update.
       return;
     }
 
-  if (-e $out_file)
+  if (-e $makefile_in)
     {
-      unlink ($out_file)
-       or fatal "cannot remove $out_file: $!\n";
+      unlink ($makefile_in)
+       or fatal "cannot remove $makefile_in: $!";
     }
 
-  my $gm_file = new Automake::XFile "> $out_file";
-  verb "creating $out_file";
+  my $gm_file = new Automake::XFile "> $makefile_in";
+  verb "creating $makefile_in";
   print $gm_file $output;
 }
 
@@ -8419,7 +8234,7 @@ sub print_autodist_files (@)
 # Print usage information.
 sub usage ()
 {
-    print "Usage: $0 [OPTION] ... [Makefile]...
+    print "Usage: $0 [OPTION]... [Makefile]...
 
 Generate Makefile.in for configure from Makefile.am.
 
@@ -8491,46 +8306,40 @@ EOF
 # Parse command line.
 sub parse_arguments ()
 {
-  # Start off as gnu.
-  set_strictness ('gnu');
+  my $strict = 'gnu';
+  my $cygnus = 0;
+  my $ignore_deps = 0;
+  my @warnings = ();
 
-  my $cli_where = new Automake::Location;
   my %cli_options =
     (
      'version' => \&version,
      'help'    => \&usage,
      'libdir=s'        => \$libdir,
-     'gnu'             => sub { set_strictness ('gnu'); },
-     'gnits'           => sub { set_strictness ('gnits'); },
-     'cygnus'          => sub { set_global_option ('cygnus', $cli_where); },
-     'foreign'          => sub { set_strictness ('foreign'); },
-     'include-deps'    => sub { unset_global_option ('no-dependencies'); },
-     'i|ignore-deps'   => sub { set_global_option ('no-dependencies',
-                                                   $cli_where); },
+     'gnu'             => sub { $strict = 'gnu'; },
+     'gnits'           => sub { $strict = 'gnits'; },
+     'foreign'         => sub { $strict = 'foreign'; },
+     'cygnus'          => \$cygnus,
+     'include-deps'    => sub { $ignore_deps = 0; },
+     'i|ignore-deps'   => sub { $ignore_deps = 1; },
      'no-force'        => sub { $force_generation = 0; },
      'f|force-missing'  => \$force_missing,
-     'o|output-dir=s'  => \$output_directory,
      'a|add-missing'   => \$add_missing,
      'c|copy'          => \$copy_missing,
      'v|verbose'       => sub { setup_channel 'verb', silent => 0; },
-     'W|warnings=s'     => \&parse_warnings,
-     # These long options (--Werror and --Wno-error) for backward
-     # compatibility.  Use -Werror and -Wno-error today.
-     'Werror'           => sub { parse_warnings 'W', 'error'; },
-     'Wno-error'        => sub { parse_warnings 'W', 'no-error'; },
+     'W|warnings=s'     => \@warnings,
      );
 
   use Automake::Getopt ();
   Automake::Getopt::parse_options %cli_options;
 
-  if (defined $output_directory)
-    {
-      msg 'obsolete', "`--output-dir' is deprecated\n";
-    }
-  else
+  set_strictness ($strict);
+  my $cli_where = new Automake::Location;
+  set_global_option ('cygnus', $cli_where) if $cygnus;
+  set_global_option ('no-dependencies', $cli_where) if $ignore_deps;
+  for my $warning (@warnings)
     {
-      # In the next release we'll remove this entirely.
-      $output_directory = '.';
+      &parse_warnings ('-W', $warning);
     }
 
   return unless @ARGV;
@@ -8538,7 +8347,7 @@ sub parse_arguments ()
   my $errspec = 0;
   foreach my $arg (@ARGV)
     {
-      fatal ("empty argument\nTry `$0 --help' for more information.")
+      fatal ("empty argument\nTry `$0 --help' for more information")
        if ($arg eq '');
 
       # Handle $local:$input syntax.
@@ -8608,11 +8417,6 @@ sub get_number_of_threads
   # It doesn't make sense to use more threads than makefiles,
   my $max_threads = @input_files;
 
-  # but a single worker thread is helpful for exposing bugs.
-  if ($automake_will_process_aux_dir && $max_threads > 1)
-    {
-      $max_threads--;
-    }
   if ($nthreads > $max_threads)
     {
       $nthreads = $max_threads;
@@ -8636,18 +8440,11 @@ sub handle_makefiles_threaded ($)
 {
   my ($nthreads) = @_;
 
-  my @queued_input_files = @input_files;
-  my $last_input_file = undef;
-  if ($automake_will_process_aux_dir)
-    {
-      $last_input_file = pop @queued_input_files;
-    }
-
   # The file queue distributes all makefiles, the message queues
   # collect all serializations needed for respective files.
   my $file_queue = Thread::Queue->new;
   my %msg_queues;
-  foreach my $file (@queued_input_files)
+  foreach my $file (@input_files)
     {
       $msg_queues{$file} = Thread::Queue->new;
     }
@@ -8673,12 +8470,12 @@ sub handle_makefiles_threaded ($)
        });
     }
 
-  # Queue all normal makefiles.
-  verb "queuing " . @queued_input_files . " input files";
-  $file_queue->enqueue (@queued_input_files, (undef) x @threads);
+  # Queue all makefiles.
+  verb "queuing " . @input_files . " input files";
+  $file_queue->enqueue (@input_files, (undef) x @threads);
 
   # Collect and process serializations.
-  foreach my $file (@queued_input_files)
+  foreach my $file (@input_files)
     {
       verb "dequeuing messages for " . $file;
       reset_local_duplicates ();
@@ -8691,7 +8488,7 @@ sub handle_makefiles_threaded ($)
            }
          elsif ($key eq QUEUE_CONF_FILE)
            {
-             require_queued_conf_file ($queue);
+             require_queued_file_check_or_copy ($queue);
            }
          else
            {
@@ -8706,13 +8503,6 @@ sub handle_makefiles_threaded ($)
       $exit_code = $exit_thread[0]
        if ($exit_thread[0] > $exit_code);
     }
-
-  # The master processes the last file.
-  if ($automake_will_process_aux_dir)
-    {
-      verb "processing last input file";
-      handle_makefile ($last_input_file);
-    }
 }
 
 ################################################################