lang, suffix rules: don't require C stuff needlessly
[platform/upstream/automake.git] / automake.in
index 0983def..835d3bd 100644 (file)
@@ -6,7 +6,7 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
     if 0;
 
 # automake - create Makefile.in from Makefile.am
-# Copyright (C) 1994-2012 Free Software Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,8 +29,9 @@ package Language;
 
 BEGIN
 {
-  my $perllibdir = $ENV{'perllibdir'} || '@datadir@/@PACKAGE@-@APIVERSION@';
-  unshift @INC, (split '@PATH_SEPARATOR@', $perllibdir);
+  @Automake::perl_libdirs = ('@datadir@/@PACKAGE@-@APIVERSION@')
+    unless @Automake::perl_libdirs;
+  unshift @INC, @Automake::perl_libdirs;
 
   # Override SHELL.  This is required on DJGPP so that system() uses
   # bash, not COMMAND.COM which doesn't quote arguments properly.
@@ -231,7 +232,7 @@ my @common_files =
     (qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB
        COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO
        ar-lib compile config.guess config.rpath
-       config.sub depcomp elisp-comp install-sh libversion.in mdate-sh
+       config.sub depcomp install-sh libversion.in mdate-sh
        missing mkinstalldirs py-compile texinfo.tex ylwrap),
      @libtool_files, @libtool_sometimes);
 
@@ -317,7 +318,7 @@ my $configure_ac;
 # Files found by scanning configure.ac for LIBOBJS.
 my %libsources = ();
 
-# Names used in AC_CONFIG_HEADER call.
+# Names used in AC_CONFIG_HEADERS call.
 my @config_headers = ();
 
 # Names used in AC_CONFIG_LINKS call.
@@ -333,8 +334,8 @@ my @configure_input_files = ();
 # List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's,
 # and their outputs.
 my @other_input_files = ();
-# Where each AC_CONFIG_FILES/AC_OUTPUT/AC_CONFIG_LINK/AC_CONFIG_HEADER appears.
-# The keys are the files created by these macros.
+# Where each AC_CONFIG_FILES/AC_OUTPUT/AC_CONFIG_LINK/AC_CONFIG_HEADERS
+# appears.  The keys are the files created by these macros.
 my %ac_config_files_location = ();
 # The condition under which AC_CONFIG_FOOS appears.
 my %ac_config_files_condition = ();
@@ -362,6 +363,9 @@ my $ac_gettext_location;
 # Whether AM_GNU_GETTEXT_INTL_SUBDIR has been seen.
 my $seen_gettext_intl = 0;
 
+# The arguments of the AM_EXTRA_RECURSIVE_TARGETS call (if any).
+my @extra_recursive_targets = ();
+
 # Lists of tags supported by Libtool.
 my %libtool_tags = ();
 # 1 if Libtool uses LT_SUPPORTED_TAG.  If it does, then it also
@@ -459,9 +463,11 @@ my %required_targets =
    'install-ps-am'   => 1,
    'install-info-am' => 1,
    'installcheck-am' => 1,
-   'uninstall-am' => 1,
-
-   'install-man' => 1,
+   'uninstall-am'    => 1,
+   'tags-am'         => 1,
+   'ctags-am'        => 1,
+   'cscopelist-am'   => 1,
+   'install-man'     => 1,
   );
 
 # Queue to push require_conf_file requirements to.
@@ -1103,11 +1109,11 @@ sub backname ($)
 
 ################################################################
 
-# 'silent-rules' mode handling functions.
+# Silent rules handling functions.
 
 # verbose_var (NAME)
 # ------------------
-# The public variable stem used to implement 'silent-rules'.
+# The public variable stem used to implement silent rules.
 sub verbose_var ($)
 {
     my ($name) = @_;
@@ -1116,7 +1122,7 @@ sub verbose_var ($)
 
 # verbose_private_var (NAME)
 # --------------------------
-# The naming policy for the private variables for 'silent-rules'.
+# The naming policy for the private variables for silent rules.
 sub verbose_private_var ($)
 {
     my ($name) = @_;
@@ -1125,9 +1131,9 @@ sub verbose_private_var ($)
 
 # define_verbose_var (NAME, VAL-IF-SILENT, [VAL-IF-VERBOSE])
 # ----------------------------------------------------------
-# For 'silent-rules' mode, setup VAR and dispatcher, to expand to
-# VAL-IF-SILENT if silent, to VAL-IF-VERBOSE (defaulting to empty)
-# if not.
+# For  silent rules, setup VAR and dispatcher, to expand to
+# VAL-IF-SILENT if silent, to VAL-IF-VERBOSE (defaulting to
+# empty) if not.
 sub define_verbose_var ($$;$)
 {
     my ($name, $silent_val, $verbose_val) = @_;
@@ -1136,21 +1142,19 @@ sub define_verbose_var ($$;$)
     my $pvar = verbose_private_var ($name);
     my $silent_var = $pvar . '_0';
     my $verbose_var = $pvar . '_1';
-    if (option 'silent-rules')
-      {
-       # For typical 'make's, 'configure' replaces AM_V (inside @@) with $(V)
-       # and AM_DEFAULT_V (inside @@) with $(AM_DEFAULT_VERBOSITY).
-       # For strict POSIX 2008 'make's, it replaces them with 0 or 1 instead.
-       # See AM_SILENT_RULES in m4/silent.m4.
-       define_variable ($var, '$(' . $pvar . '_@'.'AM_V'.'@)', INTERNAL);
-       define_variable ($pvar . '_', '$(' . $pvar . '_@'.'AM_DEFAULT_V'.'@)', INTERNAL);
-        Automake::Variable::define ($silent_var, VAR_AUTOMAKE, '', TRUE,
-                                    $silent_val, '', INTERNAL, VAR_ASIS)
-         if (! vardef ($silent_var, TRUE));
-        Automake::Variable::define ($verbose_var, VAR_AUTOMAKE, '', TRUE,
-                                    $verbose_val, '', INTERNAL, VAR_ASIS)
-         if (! vardef ($verbose_var, TRUE));
-}
+    # For typical 'make's, 'configure' replaces AM_V (inside @@) with $(V)
+    # and AM_DEFAULT_V (inside @@) with $(AM_DEFAULT_VERBOSITY).
+    # For strict POSIX 2008 'make's, it replaces them with 0 or 1 instead.
+    # See AM_SILENT_RULES in m4/silent.m4.
+    define_variable ($var, '$(' . $pvar . '_@'.'AM_V'.'@)', INTERNAL);
+    define_variable ($pvar . '_', '$(' . $pvar . '_@'.'AM_DEFAULT_V'.'@)',
+                     INTERNAL);
+    Automake::Variable::define ($silent_var, VAR_AUTOMAKE, '', TRUE,
+                                $silent_val, '', INTERNAL, VAR_ASIS)
+      if (! vardef ($silent_var, TRUE));
+    Automake::Variable::define ($verbose_var, VAR_AUTOMAKE, '', TRUE,
+                                $verbose_val, '', INTERNAL, VAR_ASIS)
+      if (! vardef ($verbose_var, TRUE));
 }
 
 # Above should not be needed in the general automake code.
@@ -1161,17 +1165,13 @@ sub define_verbose_var ($$;$)
 sub verbose_flag ($)
 {
     my ($name) = @_;
-    return '$(' . verbose_var ($name) . ')'
-      if (option 'silent-rules');
-    return '';
+    return '$(' . verbose_var ($name) . ')';
 }
 
 sub verbose_nodep_flag ($)
 {
     my ($name) = @_;
-    return '$(' . verbose_var ($name) . subst ('am__nodep') . ')'
-      if (option 'silent-rules');
-    return '';
+    return '$(' . verbose_var ($name) . subst ('am__nodep') . ')';
 }
 
 # silent_flag
@@ -1184,19 +1184,16 @@ sub silent_flag ()
 
 # define_verbose_tagvar (NAME)
 # ----------------------------
-# Engage the needed 'silent-rules' machinery for tag NAME.
+# Engage the needed silent rules machinery for tag NAME.
 sub define_verbose_tagvar ($)
 {
     my ($name) = @_;
-    if (option 'silent-rules')
-      {
-       define_verbose_var ($name, '@echo "  '. $name . ' ' x (8 - length ($name)) . '" $@;');
-      }
+    define_verbose_var ($name, '@echo "  '. $name . ' ' x (8 - length ($name)) . '" $@;');
 }
 
 # define_verbose_texinfo
 # ----------------------
-# Engage the needed 'silent-rules' machinery for assorted texinfo commands.
+# Engage the needed silent rules machinery for assorted texinfo commands.
 sub define_verbose_texinfo ()
 {
   my @tagvars = ('DVIPS', 'MAKEINFO', 'INFOHTML', 'TEXI2DVI', 'TEXI2PDF');
@@ -1210,7 +1207,7 @@ sub define_verbose_texinfo ()
 
 # define_verbose_libtool
 # ----------------------
-# Engage the needed 'silent-rules' machinery for 'libtool --silent'.
+# Engage the needed silent rules machinery for 'libtool --silent'.
 sub define_verbose_libtool ()
 {
     define_verbose_var ('lt', '--silent');
@@ -1219,7 +1216,6 @@ sub define_verbose_libtool ()
 
 sub handle_silent ()
 {
-    return unless option 'silent-rules';
     # Define "$(AM_V_P)", expanding to a shell conditional that can be
     # used in make recipes to determine whether we are being run in
     # silent mode or not.  The choice of the name derives from the LISP
@@ -1227,7 +1223,7 @@ sub handle_silent ()
     # also "the '-P' convention" in the Jargon File); we do so for lack
     # of a better convention.
     define_verbose_var ('P', 'false', ':');
-    # *Always* provide the user with 'AM_V_GEN' for 'silent-rules' mode.
+    # *Always* provide the user with '$(AM_V_GEN)', unconditionally.
     define_verbose_tagvar ('GEN');
     define_verbose_var ('at', '@');
 }
@@ -1253,10 +1249,6 @@ sub handle_options
       return 1 if process_option_list (@options);
     }
 
-  # Override portability-recursive warning.
-  switch_warning ('no-portability-recursive')
-    if option 'silent-rules';
-
   if ($strictness == GNITS)
     {
       set_option ('readme-alpha', INTERNAL);
@@ -1320,7 +1312,7 @@ sub handle_languages
     {
        # Include auto-dep code.  Don't include it if DEP_FILES would
        # be empty.
-       if (&saw_sources_p (0) && keys %dep_files)
+       if (keys %extension_seen && keys %dep_files)
        {
            # Set location of depcomp.
            &define_variable ('depcomp',
@@ -1580,10 +1572,11 @@ sub handle_languages
     # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
     # suffix rule was learned), don't bother with the C stuff.  But if
     # anything else creeps in, then use it.
-    $needs_c = 1
-      if $need_link || suffix_rules_count > 1;
-
-    if ($needs_c)
+    my @languages_seen = map { $languages{$extension_map{$_}}->name }
+                             (keys %extension_seen);
+    @languages_seen = uniq (@languages_seen);
+    $needs_c = 1 if @languages_seen > 1;
+    if ($need_link || $needs_c)
       {
        &define_compiler_variable ($languages{'c'})
          unless defined $done{$languages{'c'}};
@@ -2139,6 +2132,7 @@ sub handle_source_transform ($$$$%)
        msg_var ('unsupported', $ext_var, $ext_var->name . " can assume at most one value")
          if $default_source_ext =~ /[\t ]/;
        (my $default_source = $unxformed) =~ s,(\.[^./\\]*)?$,$default_source_ext,;
+       # TODO: Remove this backward-compatibility hack in Automake 2.0.
        if ($old_default_source ne $default_source
            && !$ext_var
            && (rule $old_default_source
@@ -2977,35 +2971,15 @@ sub handle_scripts
 ## Handling Texinfo files.  ##
 ## ------------------------ ##
 
-# ($OUTFILE, $VFILE, @CLEAN_FILES)
+# ($OUTFILE, $VFILE)
 # &scan_texinfo_file ($FILENAME)
 # ------------------------------
 # $OUTFILE     - name of the info file produced by $FILENAME.
 # $VFILE       - name of the version.texi file used (undef if none).
-# @CLEAN_FILES - list of byproducts (indexes etc.)
 sub scan_texinfo_file ($)
 {
   my ($filename) = @_;
 
-  # Some of the following extensions are always created, no matter
-  # whether indexes are used or not.  Other (like cps, fns, ... pgs)
-  # are only created when they are used.  We used to scan $FILENAME
-  # for their use, but that is not enough: they could be used in
-  # included files.  We can't scan included files because we don't
-  # know the include path.  Therefore we always erase these files, no
-  # matter whether they are used or not.
-  #
-  # (tmp is only created if an @macro is used and a certain e-TeX
-  # feature is not available.)
-  my %clean_suffixes =
-    map { $_ => 1 } (qw(aux log toc tmp
-                       cp cps
-                       fn fns
-                       ky kys
-                       vr vrs
-                       tp tps
-                       pg pgs)); # grep 'new.*index' texinfo.tex
-
   my $texi = new Automake::XFile "< $filename";
   verb "reading $filename";
 
@@ -3020,7 +2994,12 @@ sub scan_texinfo_file ($)
          next if $outfile;
 
          $outfile = $1;
-         if ($outfile =~ /\.([^.]+)$/ && $1 ne 'info')
+         if (index ($outfile, '.') < 0)
+           {
+             msg 'obsolete', "$filename:$.",
+                 "use of suffix-less info files is discouraged"
+           }
+         elsif ($outfile !~ /\.info$/)
            {
              error ("$filename:$.",
                     "output '$outfile' has unrecognized extension");
@@ -3033,23 +3012,6 @@ sub scan_texinfo_file ($)
        {
          $vfile = $1;
        }
-
-      # Try to find new or unused indexes.
-
-      # Creating a new category of index.
-      elsif (/^\@def(code)?index (\w+)/)
-       {
-         $clean_suffixes{$2} = 1;
-         $clean_suffixes{"$2s"} = 1;
-       }
-
-      # Merging an index into an another.
-      elsif (/^\@syn(code)?index (\w+) (\w+)/)
-       {
-         delete $clean_suffixes{"$2s"};
-         $clean_suffixes{"$3s"} = 1;
-       }
-
     }
 
   if (! $outfile)
@@ -3058,10 +3020,7 @@ sub scan_texinfo_file ($)
       return;
     }
 
-  my $infobase = basename ($filename);
-  $infobase =~ s/\.te?xi(nfo)?$//;
-  return ($outfile, $vfile,
-         map { "$infobase.$_" } (sort keys %clean_suffixes));
+  return ($outfile, $vfile);
 }
 
 
@@ -3188,9 +3147,17 @@ sub handle_texinfo_helper ($)
       ($info_texinfos->value_as_list_recursive (inner_expand => 1))
     {
       my $infobase = $texi;
-      $infobase =~ s/\.(txi|texinfo|texi)$//;
-
-      if ($infobase eq $texi)
+      if ($infobase =~ s/\.texi$//)
+        {
+          1; # Nothing more to do.
+        }
+      elsif ($infobase =~ s/\.(txi|texinfo)$//)
+        {
+         msg_var 'obsolete', $info_texinfos,
+                 "suffix '.$1' for Texinfo files is discouraged;" .
+                  " use '.texi' instead";
+        }
+      else
        {
          # FIXME: report line number.
          err_am "texinfo file '$texi' has unrecognized extension";
@@ -3201,10 +3168,13 @@ sub handle_texinfo_helper ($)
 
       # If 'version.texi' is referenced by input file, then include
       # automatic versioning capability.
-      my ($out_file, $vtexi, @clean_files) =
+      my ($out_file, $vtexi) =
        scan_texinfo_file ("$relative_dir/$texi")
        or next;
-      push (@mostly_cleans, @clean_files);
+      # Directory of auxiliary files and build by-products used by texi2dvi
+      # and texi2pdf.
+      push @mostly_cleans, "$infobase.t2d";
+      push @mostly_cleans, "$infobase.t2p";
 
       # If the Texinfo source is in a subdirectory, create the
       # resulting info in this subdirectory.  If it is in the current
@@ -3392,11 +3362,6 @@ sub handle_texinfo_helper ($)
       $texinfodir = ('$(srcdir)/'
                     . dirname (variable_value ('TEXINFO_TEX')));
     }
-  elsif (option 'cygnus')
-    {
-      $texinfodir = '$(top_srcdir)/../texinfo';
-      define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL);
-    }
   elsif ($config_aux_dir_set_in_configure_ac)
     {
       $texinfodir = $am_config_aux_dir;
@@ -3635,85 +3600,43 @@ sub handle_data
 # Handle TAGS.
 sub handle_tags
 {
-    my @tag_deps = ();
-    my @ctag_deps = ();
-    my @cscope_deps = ();
-    if (var ('SUBDIRS'))
-    {
-       $output_rules .= ("tags-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) tags); \\\n"
-                         . "\tdone\n");
-       push (@tag_deps, 'tags-recursive');
-       &depend ('.PHONY', 'tags-recursive');
-       &depend ('.MAKE', 'tags-recursive');
-
-       $output_rules .= ("ctags-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) ctags); \\\n"
-                         . "\tdone\n");
-       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)
-       || var ('ETAGS_ARGS')
-       || @tag_deps)
-    {
-       my @config;
-       foreach my $spec (@config_headers)
-       {
-           my ($out, @ins) = split_config_file_spec ($spec);
-           foreach my $in (@ins)
-             {
-               # If the config header source is in this directory,
-               # require it.
-               push @config, basename ($in)
-                 if $relative_dir eq dirname ($in);
-             }
-       }
-       $output_rules .= &file_contents ('tags',
-                                        new Automake::Location,
-                                        CONFIG    => "@config",
-                                        TAGSDIRS  => "@tag_deps",
-                                        CTAGSDIRS => "@ctag_deps",
-                                        CSCOPEDIRS => "@cscope_deps");
+    my @config;
+    foreach my $spec (@config_headers)
+      {
+        my ($out, @ins) = split_config_file_spec ($spec);
+       foreach my $in (@ins)
+         {
+            # If the config header source is in this directory,
+           # require it.
+           push @config, basename ($in)
+              if $relative_dir eq dirname ($in);
+          }
+      }
 
+    define_variable ('am__tagged_files',
+                     '$(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)'
+                     . "@config", INTERNAL);
+
+    if (rvar('am__tagged_files')->value_as_list_recursive
+          || var ('ETAGS_ARGS') || var ('SUBDIRS'))
+      {
+       $output_rules .= &file_contents ('tags', new Automake::Location);
        set_seen 'TAGS_DEPENDENCIES';
-    }
-    elsif (reject_var ('TAGS_DEPENDENCIES',
-                      "it doesn't make sense to define 'TAGS_DEPENDENCIES'"
-                      . " without\nsources or 'ETAGS_ARGS'"))
-    {
-    }
+      }
     else
-    {
+      {
+        reject_var ('TAGS_DEPENDENCIES',
+                   "it doesn't make sense to define 'TAGS_DEPENDENCIES'"
+                   . " without\nsources or 'ETAGS_ARGS'");
        # Every Makefile must define some sort of TAGS rule.
        # 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 and cscope.
-       $output_rules .= "ctags: CTAGS\nCTAGS:\n\n";
-       $output_rules .= "cscope cscopelist:\n\n";
-    }
+       # to fail because some subdirectory failed.  Ditto ctags and
+        # cscope.
+        $output_rules .=
+          "tags TAGS:\n\n" .
+          "ctags CTAGS:\n\n" .
+          "cscope cscopelist:\n\n";
+      }
 }
 
 
@@ -3742,26 +3665,6 @@ sub user_phony_rule ($)
 }
 
 
-# $BOOLEAN
-# &for_dist_common ($A, $B)
-# -------------------------
-# Subroutine for &handle_dist: sort files to dist.
-#
-# We put README first because it then becomes easier to make a
-# Usenet-compliant shar file (in these, README must be first).
-#
-# FIXME: do more ordering of files here.
-sub for_dist_common
-{
-    return 0
-       if $a eq $b;
-    return -1
-       if $a eq 'README';
-    return 1
-       if $b eq 'README';
-    return $a cmp $b;
-}
-
 # handle_dist
 # -----------
 # Handle 'dist' target.
@@ -3872,7 +3775,7 @@ sub handle_dist ()
   # Files to distributed.  Don't use ->value_as_list_recursive
   # as it recursively expands '$(dist_pkgdata_DATA)' etc.
   my @dist_common = split (' ', rvar ('DIST_COMMON')->variable_value);
-  @dist_common = uniq (sort for_dist_common (@dist_common));
+  @dist_common = uniq @dist_common;
   variable_delete 'DIST_COMMON';
   define_pretty_variable ('DIST_COMMON', TRUE, INTERNAL, @dist_common);
 
@@ -4135,8 +4038,8 @@ sub handle_configure ($$$@)
   define_pretty_variable ('am__configure_deps', TRUE, INTERNAL,
                          @configuredeps);
 
-  my $automake_options = '--' . (global_option 'cygnus' ? 'cygnus' : $strictness_name)
-                        (global_option 'no-dependencies' ? ' --ignore-deps' : '');
+  my $automake_options = '--' . $strictness_name .
+                        (global_option 'no-dependencies' ? ' --ignore-deps' : '');
 
   $output_rules .= file_contents
     ('configure',
@@ -4225,6 +4128,7 @@ sub handle_configure ($$$@)
            file_contents ('remake-hdr',
                           new Automake::Location,
                           FILES            => "@files",
+                          'FIRST-HDR'      => ($hdr_index == 1),
                           CONFIG_H         => $cn_sans_dir,
                           CONFIG_HIN       => $ins[0],
                           CONFIG_H_DEPS    => "@ins",
@@ -4243,6 +4147,9 @@ sub handle_configure ($$$@)
   # Distribute and define mkinstalldirs only if it is already present
   # in the package, for backward compatibility (some people may still
   # use $(mkinstalldirs)).
+  # TODO: start warning about this in Automake 1.14, and have
+  # TODO: Automake 2.0 drop it (and the mkinstalldirs script
+  # TODO: as well).
   my $mkidpath = "$config_aux_dir/mkinstalldirs";
   if (-f $mkidpath)
     {
@@ -4599,6 +4506,32 @@ sub handle_all ($)
       }
 }
 
+# Generate helper targets for user recursion, where needed.
+sub handle_user_recursion ()
+{
+  return unless @extra_recursive_targets;
+
+  define_pretty_variable ('am__extra_recursive_targets', TRUE, INTERNAL,
+                          map { "$_-recursive" } @extra_recursive_targets);
+  my $aux = var ('SUBDIRS') ? 'recursive' : 'am';
+  foreach my $target (@extra_recursive_targets)
+    {
+      # This allows the default target's rules to be overridden in
+      # Makefile.am.
+      user_phony_rule ($target);
+      depend ("$target", "$target-$aux");
+      depend ("$target-am", "$target-local");
+      # Every user-defined recursive target 'foo' *must* have a valid
+      # associated 'foo-local' rule; we define it as an empty rule by
+      # default, so that the user can transparently extend it in his
+      # own Makefile.am.
+      pretty_print_rule ("$target-local:");
+      # $target-recursive might as well be undefined, so do not add
+      # it here; it's taken care of in subdirs.am anyway.
+      depend (".PHONY", "$target-am", "$target-local");
+    }
+}
+
 
 # &do_check_merge_target ()
 # -------------------------
@@ -4609,25 +4542,16 @@ sub do_check_merge_target ()
   push @check_tests, 'check-local'
     if user_phony_rule 'check-local';
 
-  # In --cygnus mode, check doesn't depend on all.
-  if (option 'cygnus')
+  # The check target must depend on the local equivalent of
+  # 'all', to ensure all the primary targets are built.  Then it
+  # must build the local check rules.
+  $output_rules .= "check-am: all-am\n";
+  if (@check)
     {
-      # Just run the local check rules.
-      pretty_print_rule ('check-am:', "\t\t", @check);
-    }
-  else
-    {
-      # The check target must depend on the local equivalent of
-      # 'all', to ensure all the primary targets are built.  Then it
-      # must build the local check rules.
-      $output_rules .= "check-am: all-am\n";
-      if (@check)
-        {
-         pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t  ",
-                            @check);
-         depend ('.MAKE', 'check-am');
-       }
+      pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t  ", @check);
+      depend ('.MAKE', 'check-am');
     }
+
   if (@check_tests)
     {
       pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t  ",
@@ -4818,9 +4742,7 @@ sub handle_tests_dejagnu
 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';
+  my ($pfx, $generic, $am_exeext);
   if ($test_suffix eq '')
     {
       $pfx = '';
@@ -4837,13 +4759,12 @@ sub handle_per_suffix_test
                                                     : '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.
+  # test scripts.  By default, it's assumed that no protocol is used, so
+  # we fall back to the old behaviour, implemented by the 'test-driver'
+  # auxiliary script.
   if (! var "${pfx}LOG_DRIVER")
     {
-      require_conf_file ($parallel_tests_option->{position}, FOREIGN,
-                        'test-driver');
+      require_conf_file ("parallel-tests", FOREIGN, 'test-driver');
       define_variable ("${pfx}LOG_DRIVER",
                        "\$(SHELL) $am_config_aux_dir/test-driver",
                        INTERNAL);
@@ -4902,8 +4823,7 @@ sub handle_tests
       push (@check_tests, 'check-TESTS');
       my $check_deps = "@check";
       $output_rules .= &file_contents ('check', new Automake::Location,
-                                      COLOR => !! option 'color-tests',
-                                      PARALLEL_TESTS => !! option 'parallel-tests',
+                                      SERIAL_TESTS => !! option 'serial-tests',
                                        CHECK_DEPS => $check_deps);
 
       # Tests that are known programs should have $(EXEEXT) appended.
@@ -4912,7 +4832,7 @@ sub handle_tests
       append_exeext { exists $known_programs{$_[0]} } 'XFAIL_TESTS'
        if (var ('XFAIL_TESTS'));
 
-      if (my $parallel_tests = option 'parallel-tests')
+      if (! option 'serial-tests')
         {
          define_variable ('TEST_SUITE_LOG', 'test-suite.log', INTERNAL);
          my $suff = '.test';
@@ -4962,7 +4882,7 @@ sub handle_tests
                if ($val =~ /(\$\((top_)?srcdir\))\//o)
                  {
                    msg ('error', $subvar->rdef ($cond)->location,
-                        "parallel-tests: using '$1' in TESTS is currently broken: '$val'");
+                        "using '$1' in TESTS is currently broken: '$val'");
                  }
 
                foreach my $test_suffix (@test_suffixes)
@@ -5035,8 +4955,6 @@ sub handle_emacs_lisp
 
   require_variables ($elfiles[0][0], "Emacs Lisp sources seen", TRUE,
                     'EMACS', 'lispdir');
-  require_conf_file ($elfiles[0][0], FOREIGN, 'elisp-comp');
-  &define_variable ('elisp_comp', "$am_config_aux_dir/elisp-comp", INTERNAL);
 }
 
 # Handle Python
@@ -5177,7 +5095,7 @@ sub scan_autoconf_config_files ($$)
       # Handle $local:$input syntax.
       my ($local, @rest) = split (/:/);
       @rest = ("$local.in",) unless @rest;
-      # Keep in sync with 'conffile-leading-dot.test'.
+      # Keep in sync with test 'conffile-leading-dot.sh'.
       msg ('unsupported', $where,
            "omit leading './' from config file names such as '$local';"
            . "\nremake rules might be subtly broken otherwise")
@@ -5227,15 +5145,15 @@ sub scan_autoconf_traces ($)
                AC_REQUIRE_AUX_FILE => 1,
                AC_SUBST_TRACE => 1,
                AM_AUTOMAKE_VERSION => 1,
-                AM_PROG_MKDIR_P => 0, # FIXME: to be removed in 1.13
+                AM_PROG_MKDIR_P => 0,
                AM_CONDITIONAL => 2,
+               AM_EXTRA_RECURSIVE_TARGETS => 1,
                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,
                _AM_COND_IF => 1,
                _AM_COND_ELSE => 1,
@@ -5383,10 +5301,10 @@ sub scan_autoconf_traces ($)
 
          $seen_automake_version = 1;
        }
-      elsif ($macro eq 'AM_PROG_MKDIR_P') # FIXME: to be removed in 1.13
+      elsif ($macro eq 'AM_PROG_MKDIR_P')
        {
          msg 'obsolete', $where, <<'EOF';
-The 'AM_PROG_MKDIR_P' macro is deprecated, and will soon be removed.
+The 'AM_PROG_MKDIR_P' macro is deprecated, and its use is discouraged.
 You should use the Autoconf-provided 'AC_PROG_MKDIR_P' macro instead,
 and use '$(MKDIR_P)' instead of '$(mkdir_p)'in your Makefile.am files.
 EOF
@@ -5395,6 +5313,13 @@ EOF
        {
          $configure_cond{$args[1]} = $where;
        }
+      elsif ($macro eq 'AM_EXTRA_RECURSIVE_TARGETS')
+       {
+          # Empty leading/trailing fields might be produced by split,
+          # hence the grep is really needed.
+          push @extra_recursive_targets,
+               grep (/./, (split /\s+/, $args[1]));
+       }
       elsif ($macro eq 'AM_GNU_GETTEXT')
        {
          $seen_gettext = $where;
@@ -5412,7 +5337,7 @@ EOF
            {
               msg 'obsolete', $where, <<'EOF';
 AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated.  For more info, see:
-http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation
+http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
 EOF
              $package_version = $args[2];
              $package_version_location = $where;
@@ -5436,10 +5361,6 @@ EOF
        {
          $seen_cc_c_o = $where;
        }
-      elsif ($macro eq 'AM_SILENT_RULES')
-        {
-         set_global_option ('silent-rules', $where);
-       }
       elsif ($macro eq '_AM_COND_IF')
         {
          cond_stack_if ('', $args[1], $where);
@@ -5596,26 +5517,6 @@ sub scan_autoconf_files ()
 
 ################################################################
 
-# Set up for Cygnus mode.
-sub check_cygnus
-{
-  my $cygnus = option 'cygnus';
-  return unless $cygnus;
-
-  # This feature is deprecated, will be removed in the next
-  # Automake major release.
-  msg 'obsolete', $cygnus->get,
-      "support for Cygnus-style trees is deprecated";
-
-  set_strictness ('foreign');
-  set_option ('no-installinfo', $cygnus);
-  set_option ('no-dependencies', $cygnus);
-  set_option ('no-dist', $cygnus);
-
-  err_ac "'AM_MAINTAINER_MODE' required when --cygnus specified"
-    if !$seen_maint_mode;
-}
-
 # Do any extra checking for GNU standards.
 sub check_gnu_standards
 {
@@ -6026,76 +5927,9 @@ sub resolve_linker
 sub saw_extension
 {
     my ($ext) = @_;
-    if (! defined $extension_seen{$ext})
-    {
-       $extension_seen{$ext} = 1;
-    }
-    else
-    {
-       ++$extension_seen{$ext};
-    }
-}
-
-# Return the number of files seen for a given language.  Knows about
-# special cases we care about.  FIXME: this is hideous.  We need
-# something that involves real language objects.  For instance yacc
-# and yaccxx could both derive from a common yacc class which would
-# know about the strange ylwrap requirement.  (Or better yet we could
-# just not support legacy yacc!)
-sub count_files_for_language
-{
-    my ($name) = @_;
-
-    my @names;
-    if ($name eq 'yacc' || $name eq 'yaccxx')
-    {
-       @names = ('yacc', 'yaccxx');
-    }
-    elsif ($name eq 'lex' || $name eq 'lexxx')
-    {
-       @names = ('lex', 'lexxx');
-    }
-    else
-    {
-       @names = ($name);
-    }
-
-    my $r = 0;
-    foreach $name (@names)
-    {
-       my $lang = $languages{$name};
-       foreach my $ext (@{$lang->extensions})
-       {
-           $r += $extension_seen{$ext}
-               if defined $extension_seen{$ext};
-       }
-    }
-
-    return $r
-}
-
-# Called to ask whether source files have been seen . If HEADERS is 1,
-# headers can be included.
-sub saw_sources_p
-{
-    my ($headers) = @_;
-
-    # count all the sources
-    my $count = 0;
-    foreach my $val (values %extension_seen)
-    {
-       $count += $val;
-    }
-
-    if (!$headers)
-    {
-       $count -= count_files_for_language ('header');
-    }
-
-    return $count > 0;
+    $extension_seen{$ext} = 1;
 }
 
-
 # register_language (%ATTRIBUTE)
 # ------------------------------
 # Register a single language.
@@ -6139,7 +5973,7 @@ sub register_language (%)
   # Update the pattern of known extensions.
   accept_extensions (@{$lang->extensions});
 
-  # Upate the $suffix_rule map.
+  # Update the suffix rules map.
   foreach my $suffix (@{$lang->extensions})
     {
       foreach my $dest (&{$lang->output_extensions} ($suffix))
@@ -6157,12 +5991,11 @@ sub derive_suffix ($$)
 {
   my ($source_ext, $obj) = @_;
 
-  while (! $extension_map{$source_ext}
-        && $source_ext ne $obj
-        && exists $suffix_rules->{$source_ext}
-        && exists $suffix_rules->{$source_ext}{$obj})
+  while (!$extension_map{$source_ext} && $source_ext ne $obj)
     {
-      $source_ext = $suffix_rules->{$source_ext}{$obj}[0];
+      my $new_source_ext = next_in_suffix_chain ($source_ext, $obj);
+      last if not defined $new_source_ext;
+      $source_ext = $new_source_ext;
     }
 
   return $source_ext;
@@ -6729,7 +6562,7 @@ sub read_am_file ($$)
                # otherwise OSF make will implicitly copy the included
                # file in the build tree during "make distdir" to satisfy
                # the dependency.
-               # (subdircond2.test and subdircond3.test will fail.)
+               # (subdir-am-cond.sh and subdir-ac-cond.sh will fail)
                push_dist_common ("\$\(top_srcdir\)/$path");
              }
            else
@@ -6740,7 +6573,7 @@ sub read_am_file ($$)
                # otherwise OSF make will implicitly copy the included
                # file in the build tree during "make distdir" to satisfy
                # the dependency.
-               # (subdircond2.test and subdircond3.test will fail.)
+               # (subdir-am-cond.sh and subdir-ac-cond.sh will fail)
                push_dist_common ("\$\(srcdir\)/$path");
                $path = $relative_dir . "/" . $path if $relative_dir ne '.';
              }
@@ -6861,8 +6694,6 @@ sub transform_token ($$$)
 #   - replaces %KEY% with $VAL,
 #   - enables/disables ?KEY? and ?!KEY?,
 #   - replaces %?KEY% with TRUE or FALSE.
-#   - replaces %KEY?IFTRUE%, %KEY:IFFALSE%, and %KEY?IFTRUE:IFFALSE% with
-#     IFTRUE / IFFALSE, as appropriate.
 sub transform ($$)
 {
   my ($token, $transform) = @_;
@@ -6874,11 +6705,6 @@ sub transform ($$)
     {
       return transform_token ($token, $transform, $1);
     }
-  # %KEY?IFTRUE%, %KEY:IFFALSE%, and %KEY?IFTRUE:IFFALSE%.
-  elsif ($token =~ /^%([\w\-]+)(?:\?([^?:%]+))?(?::([^?:%]+))?%$/)
-    {
-      return transform_token ($token, $transform, $1) ? ($2 || '') : ($3 || '');
-    }
   # %?KEY%.
   elsif ($token =~ /^%\?([\w\-]+)%$/)
     {
@@ -6909,8 +6735,7 @@ sub preprocess_file ($%)
 
   # Complete %transform with global options.
   # Note that %transform goes last, so it overrides global options.
-  %transform = ('CYGNUS'      => !! option 'cygnus',
-                'MAINTAINER-MODE'
+  %transform = ( 'MAINTAINER-MODE'
                 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
 
                 'XZ'          => !! option 'dist-xz',
@@ -6923,7 +6748,6 @@ sub preprocess_file ($%)
 
                 'INSTALL-INFO' =>  ! option 'no-installinfo',
                 'INSTALL-MAN'  =>  ! option 'no-installman',
-                'HAVE-MANS'    => !! var ('MANS'),
                 'CK-NEWS'      => !! option 'check-news',
 
                 'SUBDIRS'      => !! var ('SUBDIRS'),
@@ -6956,7 +6780,6 @@ sub preprocess_file ($%)
 
   # Substitute Automake template tokens.
   s/(?: % \?? [\w\-]+ %
-      | % [\w\-]+ (?:\?[^?:%]+)? (?::[^?:%]+)? %
       | \? !? [\w\-]+ \?
     )/transform($&, \%transform)/gex;
   # transform() may have added some ##%-comments to strip.
@@ -7586,7 +7409,7 @@ sub push_required_file
     }
   # 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
+  # script 'test-driver-is-distributed.sh').  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)
@@ -8044,7 +7867,6 @@ sub generate_makefile ($$)
     if var 'DIST_SUBDIRS' && ! var 'SUBDIRS';
 
   # Check first, because we might modify some state.
-  check_cygnus;
   check_gnu_standards;
   check_gnits_standards;
 
@@ -8079,6 +7901,7 @@ sub generate_makefile ($$)
   handle_data;
   handle_headers;
   handle_subdirs;
+  handle_user_recursion;
   handle_tags;
   handle_minor_options;
   # Must come after handle_programs so that %known_programs is up-to-date.
@@ -8229,7 +8052,6 @@ Dependency tracking:
       --include-deps     enable dependency tracking code
 
 Flavors:
-      --cygnus           assume program is part of Cygnus-style tree
       --foreign          set strictness to foreign
       --gnits            set strictness to gnits
       --gnu              set strictness to gnu
@@ -8287,7 +8109,6 @@ EOF
 sub parse_arguments ()
 {
   my $strict = 'gnu';
-  my $cygnus = 0;
   my $ignore_deps = 0;
   my @warnings = ();
 
@@ -8300,7 +8121,6 @@ sub parse_arguments ()
      '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; },
@@ -8316,7 +8136,6 @@ sub parse_arguments ()
 
   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)
     {