Index: autoconf/bin/autoconf.as
===================================================================
RCS file: /sources/autoconf/autoconf/bin/autoconf.as,v
retrieving revision 1.24
diff -u -r1.24 autoconf.as
--- autoconf/bin/autoconf.as	4 Jan 2007 16:43:06 -0000	1.24
+++ autoconf/bin/autoconf.as	19 Mar 2007 21:04:17 -0000
@@ -33,6 +33,7 @@
   -v, --verbose             verbosely report processing
   -d, --debug               don't remove temporary files
   -f, --force               consider all files obsolete
+      --clean               remove all files otherwise installed by autoconf
   -o, --output=FILE         save output in FILE (stdout is the default)
   -W, --warnings=CATEGORY   report the warnings falling in CATEGORY [syntax]
 
@@ -82,6 +83,7 @@
 autom4te_options=
 outfile=
 verbose=false
+clean=false
 
 # Parse command line.
 while test $# -gt 0 ; do
@@ -99,6 +101,9 @@
        verbose=:
        autom4te_options="$autom4te_options $1"; shift ;;
 
+    --clean )
+       clean=:; shift ;;
+
     # Arguments passed as is to autom4te.
     --debug      | -d   | \
     --force      | -f   | \
@@ -175,6 +180,10 @@
 # Unless specified, the output is stdout.
 test -z "$outfile" && outfile=-
 
+if $clean && test x"$outfile" != x-; then
+  exec rm -f "$outfile"
+fi
+
 # Run autom4te with expansion.
 eval set x $autom4te_options \
   --language=autoconf --output=\$outfile "$traces" \$infile
Index: autoconf/bin/autoheader.in
===================================================================
RCS file: /sources/autoconf/autoconf/bin/autoheader.in,v
retrieving revision 1.147
diff -u -r1.147 autoheader.in
--- autoconf/bin/autoheader.in	4 Jan 2007 16:43:06 -0000	1.147
+++ autoconf/bin/autoheader.in	19 Mar 2007 21:04:17 -0000
@@ -70,6 +70,7 @@
   -h, --help               print this help, then exit
   -V, --version            print version number, then exit
   -v, --verbose            verbosely report processing
+      --clean              remove the files that would otherwise be created
   -d, --debug              don\'t remove temporary files
   -f, --force              consider all files obsolete
   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY
@@ -195,6 +196,13 @@
 ($config_h, $config_h_in) = split (':', $config_h, 2);
 $config_h_in ||= "$config_h.in";
 
+if ($clean)
+  {
+    unlink $config_h_in or error "error: Cannot remove `$config_h_in': $!"
+      unless not -f $config_h_in;
+    exit 0;
+  }
+
 # %SYMBOL might contain things like `F77_FUNC(name,NAME)', but we keep
 # only the name of the macro.
 %symbol = map { s/\(.*//; $_ => 1 } keys %symbol;
Index: autoconf/bin/autoreconf.in
===================================================================
RCS file: /sources/autoconf/autoconf/bin/autoreconf.in,v
retrieving revision 1.137
diff -u -r1.137 autoreconf.in
--- autoconf/bin/autoreconf.in	4 Jan 2007 16:43:06 -0000	1.137
+++ autoconf/bin/autoreconf.in	19 Mar 2007 21:04:17 -0000
@@ -74,6 +74,7 @@
   -d, --debug              don't remove temporary files
   -f, --force              consider all files obsolete
   -i, --install            copy missing auxiliary files
+  -c, --clean              remove auxiliary files
       --no-recursive       don't rebuild sub-packages
   -s, --symlink            with -i, install symbolic links instead of copies
   -m, --make               when applicable, re-run ./configure && make
@@ -150,10 +151,15 @@
 	  'I|include=s'          => \@include,
 	  'B|prepend-include=s'	 => \@prepend_include,
 	  'i|install'            => \$install,
+	  # --clean is already handled by getopt, accept a short version:
+	  'c'                    => \$clean,
 	  's|symlink'            => \$symlink,
 	  'm|make'               => \$make,
 	  'recursive!'           => \$recursive);
 
+  error "Cannot install and clean at the same time."
+    if ($install && $clean);
+
   # Split the warnings as a list of elements instead of a list of
   # lists.
   @warning = map { split /,/ } @warning;
@@ -196,6 +202,15 @@
       $automake   .= ' --copy' unless $symlink;
       $libtoolize .= ' --copy' unless $symlink;
     }
+  elsif ($clean)
+    {
+      # Don't tell autoconf and aclocal to --clean: we need them to do their
+      # work before we can actually remove their files.
+      $autoheader .= ' --clean';
+      $automake   .= ' --clean';
+      $autopoint  .= ' --clean';
+      $libtoolize .= ' --clean';
+    }
   # --force;
   if ($force)
     {
@@ -304,12 +319,50 @@
     }
 }
 
+# &run_make ([TARGET])
+# ------------
+# Run make in the current directory.  config.status is run first
+# in order to recreate the Makefile unless we're in --clean mode.
+# Return true on success, false if something went wrong.
+sub run_make (;$)
+{
+  my ($target) = @_;
+  $target = '' if not defined $target;
+
+  # Regenerate the Makefile first -- unless we're --clean mode.
+  if (!$clean)
+    {
+      if (!-f 'config.status')
+	{
+	  verb 'no config.status: cannot re-make';
+	  return 0;
+	}
+      else
+	{
+	  xsystem ('./config.status --recheck');
+	  xsystem ('./config.status');
+	}
+    }
+  if (!-f 'Makefile')
+    {
+      verb 'no Makefile: cannot re-make' unless $clean;
+      return 0;
+    }
+  else
+    {
+      xsystem ("make $target");
+    }
+  return 1;
+}
+
 # &autoreconf_current_directory
 # -----------------------------
 sub autoreconf_current_directory ()
 {
   my $configure_ac = find_configure_ac;
 
+  run_make ('maintainer-clean') if ($make && $clean);
+
   # ---------------------- #
   # Is it using Autoconf?  #
   # ---------------------- #
@@ -345,7 +398,7 @@
   # will fail: the Gettext macros are missing.
   #
   # Therefore, we can't use the traces to decide if we use Gettext or
-  # not.  I guess that once Gettext move to 2.5x we will be able to,
+  # not.  I guess that once Gettext moves to 2.5x we will be able to,
   # but in the meanwhile forget it.
   #
   # We can only grep for AM_GNU_GETTEXT_VERSION in configure.ac.  You
@@ -359,7 +412,7 @@
     {
       verb "$configure_ac: not using Gettext";
     }
-  elsif (!$install)
+  elsif (!$install && !$clean)
     {
       verb "$configure_ac: not running autopoint: --install not given";
     }
@@ -519,20 +572,21 @@
   # Running libtoolize.  #
   # -------------------- #
 
+  if ($uses_libltdl)
+    {
+      $libtoolize .= " --ltdl";
+    }
+
   if (!$uses_libtool)
     {
       verb "$configure_ac: not using Libtool";
     }
   elsif ($install)
     {
-      if ($uses_libltdl)
-	{
-	  $libtoolize .= " --ltdl";
-	}
       xsystem ($libtoolize);
       $rerun_aclocal = 1;
     }
-  else
+  elsif (!$clean)
     {
       verb "$configure_ac: not running libtoolize: --install not given";
     }
@@ -569,6 +623,7 @@
   # latter runs the former, and (ii) autoconf is stricter than
   # autoheader.  So all in all, autoconf should give better error
   # messages.
+  $autoconf .= ' --clean' if $clean;
   xsystem ($autoconf);
 
 
@@ -588,7 +643,7 @@
     {
       verb "$configure_ac: not using Autoheader";
     }
-  else
+  elsif (!$clean)
     {
       xsystem ($autoheader);
     }
@@ -610,31 +665,23 @@
       xsystem ($automake);
     }
 
+  # ---------------------- #
+  # Finalize the cleanup.  #
+  # ---------------------- #
+
+  if ($clean)
+    {
+      run_aclocal ($aclocal, '--clean ' . $aclocal_flags);
+      xsystem ($libtoolize);
+      xsystem ($autoheader);
+    }
+
 
   # -------------- #
   # Running make.  #
   # -------------- #
 
-  if ($make)
-    {
-      if (!-f "config.status")
-	{
-	  verb "no config.status: cannot re-make";
-	}
-      else
-	{
-	  xsystem ("./config.status --recheck");
-	  xsystem ("./config.status");
-	  if (!-f "Makefile")
-	    {
-	      verb "no Makefile: cannot re-make";
-	    }
-	  else
-	    {
-	      xsystem ("make");
-	    }
-	}
-    }
+  run_make () if ($make);
 }
 
 
Index: autoconf/lib/Autom4te/General.pm
===================================================================
RCS file: /sources/autoconf/autoconf/lib/Autom4te/General.pm,v
retrieving revision 1.37
diff -u -r1.37 General.pm
--- autoconf/lib/Autom4te/General.pm	25 Aug 2006 21:21:19 -0000	1.37
+++ autoconf/lib/Autom4te/General.pm	19 Mar 2007 21:04:19 -0000
@@ -1,5 +1,6 @@
 # autoconf -- create `configure' using m4 macros
-# Copyright (C) 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2004, 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
@@ -50,7 +51,7 @@
 
 # Variables we define and export.
 my @export_vars =
-  qw ($debug $force $help $me $tmp $verbose $version);
+  qw ($debug $force $clean $help $me $tmp $verbose $version);
 
 # Functions we define and export.
 my @export_subs =
@@ -94,6 +95,16 @@
 use vars qw ($force);
 $force = undef;
 
+=item C<$clean>
+
+Set this variable to 1 to remove all files that would otherwise be
+created.
+
+=cut
+
+use vars qw ($clean);
+$clean = undef;
+
 =item C<$help>
 
 Set to the help message associated to the option C<--help>.
@@ -261,6 +272,7 @@
 	     "v|verbose"  => sub { ++$verbose },
 	     "d|debug"    => sub { ++$debug },
 	     'f|force'    => \$force,
+	     'clean'      => \$clean,
 
 	     # User options last, so that they have precedence.
 	     %option);
