Index: automake/aclocal.in
===================================================================
RCS file: /sources/automake/automake/aclocal.in,v
retrieving revision 1.140
diff -u -r1.140 aclocal.in
--- automake/aclocal.in	14 Oct 2006 17:40:25 -0000	1.140
+++ automake/aclocal.in	19 Mar 2007 21:04:23 -0000
@@ -8,7 +8,7 @@
 # aclocal - create aclocal.m4 by scanning configure.ac
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006  Free Software Foundation, Inc.
+# 2005, 2006, 2007  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
@@ -77,6 +77,12 @@
 # Option --force.
 my $force_output = 0;
 
+# Option --clean.
+my $clean = 0;
+
+# Files to remove with --clean.
+my @files_installed;
+
 # Modification time of the youngest dependency.
 my $greatest_mtime = 0;
 
@@ -248,6 +254,11 @@
 	    if $res;
 	  unlink_tmp;
 	}
+      elsif ($clean)
+	{
+	  # Remember that we must remove this file once we're finished.
+	  push (@files_installed, $dest);
+	}
       elsif (!$dry_run)
 	{
 	  xsystem ('cp', $src, $dest);
@@ -773,6 +784,14 @@
       return 0;
     }
 
+  # We are now about to output `$output_file'.  If we're in clean mode, we
+  # shall just stop here.
+  if ($clean)
+    {
+      push (@files_installed, $output_file);
+      return 1;
+    }
+
   # Nothing to output?!
   # FIXME: Shouldn't we diagnose this?
   return 1 if ! length ($output);
@@ -861,6 +880,7 @@
                               changed (implies --install and --dry-run)
       --dry-run             pretend to, but do not actually update any file
       --force               always update output file
+  -c, --clean               remove the files that would otherwise be generated
       --help                print this help, then exit
   -I DIR                    add directory to search list for .m4 files
       --install             copy third-party files to the first -I directory
@@ -915,6 +935,7 @@
      'diff:s'		=> \$diff_command,
      'dry-run'		=> \$dry_run,
      'force'		=> \$force_output,
+     'clean'		=> \$clean,
      'I=s'		=> \@user_includes,
      'install'          => \$install,
      'output=s'		=> \$output_file,
@@ -986,6 +1007,11 @@
       $dry_run = 1;
     }
 
+  if ($clean && $install)
+    {
+      fatal "Cannot install and clean at the same time.";
+    }
+
   if ($install && !@user_includes)
     {
       fatal ("--install should copy macros in the directory indicated by the"
@@ -1050,7 +1076,16 @@
     last if write_aclocal ($output_file, keys %macro_traced);
     last if $dry_run;
   }
-check_acinclude;
+check_acinclude unless $clean;
+
+if ($clean)
+  {
+    foreach my $cleanfile (@files_installed)
+      {
+	unlink $cleanfile or fatal "Failed to remove `$cleanfile': $!"
+	  unless not -e $cleanfile;
+      }
+  }
 
 exit $exit_code;
 
Index: automake/automake.in
===================================================================
RCS file: /sources/automake/automake/automake.in,v
retrieving revision 1.1641
diff -u -r1.1641 automake.in
--- automake/automake.in	16 Oct 2006 05:24:17 -0000	1.1641
+++ automake/automake.in	19 Mar 2007 21:04:25 -0000
@@ -7,7 +7,7 @@
 
 # automake - create Makefile.in from Makefile.am
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007  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
@@ -291,6 +291,12 @@
 # TRUE if we should copy missing files; otherwise symlink if possible.
 my $copy_missing = 0;
 
+# TRUE if we shoud remove files that would otherwise be installed (--clean).
+my $clean = 0;
+
+# List of files to be removed when we're finished (--clean).
+my @files_installed;
+
 # TRUE if we should always update files that we know about.
 my $force_missing = 0;
 
@@ -7062,7 +7068,7 @@
       # The default auxiliary directory is the first
       # of ., .., or ../.. that contains install-sh.
       # Assume . if install-sh doesn't exist yet.
-      for my $dir (qw (. .. ../..))
+      for my $dir (qw(. .. ../..))
 	{
 	  if (-f "$dir/install-sh")
 	    {
@@ -7290,6 +7296,7 @@
     $macro = rvar ($macro) unless ref $macro;
     if ($config_libobj_dir)
       {
+	# FIXME: Do we need to put @files in @files_installed when --clean?
 	require_file_internal ($macro->rdef ($cond)->location, $mystrict,
 			       $config_libobj_dir, @files);
       }
@@ -7306,6 +7313,7 @@
 {
     my ($where, $mystrict, @files) = @_;
     require_file_internal ($where, $mystrict, $config_aux_dir, @files);
+    push (@files_installed, map { $_ = $config_aux_dir . '/' . $_ } @files);
 }
 
 
@@ -7526,10 +7534,17 @@
   # defined or overridden variables.
   $output_vars .= output_variables;
 
-  check_typos;
-
   my ($out_file) = $output_directory . '/' . $makefile_in;
 
+  if ($clean && -e $out_file)
+    {
+      unlink ($out_file)
+	or fatal "cannot remove $out_file: $!\n";
+      return;
+    }
+
+  check_typos;
+
   if ($exit_code != 0)
     {
       verb "not writing $out_file because of earlier errors";
@@ -7599,6 +7614,7 @@
       --version            print version number, then exit
   -v, --verbose            verbosely list files processed
       --no-force           only update Makefile.in's that are out of date
+      --clean              remove files that would otherwise be created
   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY
 
 Dependency tracking:
@@ -7715,6 +7731,7 @@
      'o|output-dir=s'	=> \$output_directory,
      'a|add-missing' 	=> \$add_missing,
      'c|copy' 	        => \$copy_missing,
+     'clean' 	        => \$clean,
      'v|verbose' 	=> sub { setup_channel 'verb', silent => 0; },
      'W|warnings=s'     => \&parse_warnings,
      # These long options (--Werror and --Wno-error) for backward
@@ -7854,6 +7871,15 @@
       }
   }
 
+if ($clean)
+  {
+    foreach my $cleanfile (@files_installed)
+      {
+	unlink $cleanfile or fatal "Failed to remove `$cleanfile': $!"
+	  unless not -e $cleanfile;
+      }
+  }
+
 exit $exit_code;
 
 
