Quoting Ralf Wildenhues <[EMAIL PROTECTED]>:
* Benoit Sigoure wrote on Sun, Jun 17, 2007 at 01:16:35AM CEST:
PS: autopoint (formerly gettextize)

Erm, both tools still exist (and have different semantics).

Hmm at least autoreconf only mentions autopoint so I won't deal with gettextize.

[SNIP]

I addressed all the problems you mentionned (and wrote the short documentation in Texinfo) in the attached patch.


FWIW, the Automake patch is malformed (missing lines at the end?) so you
may want to look into that before resending it to automake-patches.

??
Works for me...  oO

Cheers,

2007-06-17  Benoit Sigoure  <[EMAIL PROTECTED]>

        * bin/autoconf.as, bin/autoheader.in, bin/autoreconf.in: New option
        `--clean'.
        * NEWS: Mention it.
        * bin/autoreconf.in (&run_make): New.
        (&autoreconf_current_directory): Use it.  Honor the $clean variable.
        * lib/Autom4te/General.pm ($clean): New boolean value.
        (getopt): Handle `--clean'.
        * lib/Autom4te/FileUtils.pm ($SIMPLE_BACKUP_SUFFIX): Export it.
        * tests/torture.at: Test the new feature.

--
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

Index: NEWS
===================================================================
RCS file: /sources/autoconf/autoconf/NEWS,v
retrieving revision 1.430
diff -u -r1.430 NEWS
--- NEWS        21 May 2007 17:50:57 -0000      1.430
+++ NEWS        18 Jun 2007 22:06:47 -0000
@@ -1,5 +1,8 @@
 * Major changes in Autoconf 2.61b (????-??-??)
 
+** It is now possible to undo the work of autoconf, autoheader and
+   autoreconf with the --clean option.
+
 ** New macro AC_OPENMP.
 
 ** AC_C_BIGENDIAN now supports universal binaries a la Mac OS X.
Index: bin/autoconf.as
===================================================================
RCS file: /sources/autoconf/autoconf/bin/autoconf.as,v
retrieving revision 1.25
diff -u -r1.25 autoconf.as
--- bin/autoconf.as     17 May 2007 02:43:12 -0000      1.25
+++ bin/autoconf.as     18 Jun 2007 22:06:47 -0000
@@ -31,6 +31,7 @@
   -h, --help                print this help, then exit
   -V, --version             print version number, then exit
   -v, --verbose             verbosely report processing
+      --clean               remove files installed by autoconf
   -d, --debug               don't remove temporary files
   -f, --force               consider all files obsolete
   -o, --output=FILE         save output in FILE (stdout is the default)
@@ -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   | \
@@ -163,7 +168,11 @@
       AS_ECHO(["$as_me: no input file"]) >&2
       exit 1
     fi
-    test -z "$traces" && test -z "$outfile" && outfile=configure;;
+    test -z "$traces" && test -z "$outfile" && outfile=configure
+    if $clean && test x"$outfile" != x; then
+      rm -f "$outfile"
+    fi
+    ;;
   1)
     infile=$1 ;;
   *) exec >&2
@@ -175,6 +184,10 @@
 # Unless specified, the output is stdout.
 test -z "$outfile" && outfile=-
 
+if $clean; then
+  exec rm -rf autom4te.cache
+fi
+
 # Run autom4te with expansion.
 eval set x $autom4te_options \
   --language=autoconf --output=\$outfile "$traces" \$infile
Index: bin/autoheader.in
===================================================================
RCS file: /sources/autoconf/autoconf/bin/autoheader.in,v
retrieving revision 1.147
diff -u -r1.147 autoheader.in
--- bin/autoheader.in   4 Jan 2007 16:43:06 -0000       1.147
+++ bin/autoheader.in   18 Jun 2007 22:06:47 -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 files installed by autoheader
   -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,16 @@
 ($config_h, $config_h_in) = split (':', $config_h, 2);
 $config_h_in ||= "$config_h.in";
 
+if ($clean)
+  {
+    foreach my $f ($config_h, $config_h_in . $SIMPLE_BACKUP_SUFFIX)
+    {
+      unlink $f or error "error: Cannot remove `$f': $!"
+        unless not -f $f;
+    }
+    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: bin/autoreconf.in
===================================================================
RCS file: /sources/autoconf/autoconf/bin/autoreconf.in,v
retrieving revision 1.137
diff -u -r1.137 autoreconf.in
--- bin/autoreconf.in   4 Jan 2007 16:43:06 -0000       1.137
+++ bin/autoreconf.in   18 Jun 2007 22:06:47 -0000
@@ -71,6 +71,7 @@
   -h, --help               print this help, then exit
   -V, --version            print version number, then exit
   -v, --verbose            verbosely report processing
+  -c, --clean              remove auxiliary files
   -d, --debug              don't remove temporary files
   -f, --force              consider all files obsolete
   -i, --install            copy missing auxiliary files
@@ -150,10 +151,15 @@
          'I|include=s'          => [EMAIL PROTECTED],
          'B|prepend-include=s'  => [EMAIL PROTECTED],
          '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 in --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,25 @@
       xsystem ($automake);
     }
 
+  # ---------------------- #
+  # Finalize the cleanup.  #
+  # ---------------------- #
+
+  if ($clean)
+    {
+      run_aclocal ($aclocal, '--clean ' . $aclocal_flags);
+      xsystem ($libtoolize) if ($uses_libtool);
+      xsystem ($autoheader) if ($uses_autoheader);
+      system ('rm -rf autom4te.cache');
+      return;
+    }
+
 
   # -------------- #
   # 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: doc/autoconf.texi
===================================================================
RCS file: /sources/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1161
diff -u -r1.1161 autoconf.texi
--- doc/autoconf.texi   13 Jun 2007 16:52:24 -0000      1.1161
+++ doc/autoconf.texi   18 Jun 2007 22:06:55 -0000
@@ -1381,6 +1381,9 @@
 @itemx -v
 Report processing steps.
 
[EMAIL PROTECTED] --clean
+Remove the output file.
+
 @item --debug
 @itemx -d
 Don't remove the temporary files.
@@ -1578,6 +1581,12 @@
 commands it runs.  If given two or more times, pass @option{--verbose}
 to subordinate tools that support it.
 
[EMAIL PROTECTED] --clean
[EMAIL PROTECTED] -c
+Remove the auxiliary files in the package that would be installed by
[EMAIL PROTECTED]  This option can be used to undo the work of
[EMAIL PROTECTED] --install}.
+
 @item --debug
 @itemx -d
 Don't remove the temporary files.
@@ -3092,6 +3101,9 @@
 @itemx -v
 Report processing steps.
 
[EMAIL PROTECTED] --clean
+Remove the output file.
+
 @item --debug
 @itemx -d
 Don't remove the temporary files.
Index: lib/Autom4te/FileUtils.pm
===================================================================
RCS file: /sources/autoconf/autoconf/lib/Autom4te/FileUtils.pm,v
retrieving revision 1.12
diff -u -r1.12 FileUtils.pm
--- lib/Autom4te/FileUtils.pm   17 May 2006 02:17:58 -0000      1.12
+++ lib/Autom4te/FileUtils.pm   18 Jun 2007 22:06:55 -0000
@@ -49,7 +49,8 @@
 @EXPORT = qw (&contents
              &find_file &mtime
              &update_file &up_to_date_p
-             &xsystem &xqx &dir_has_case_matching_file &reset_dir_cache);
+             &xsystem &xqx &dir_has_case_matching_file &reset_dir_cache
+             $SIMPLE_BACKUP_SUFFIX);
 
 
 =item C<find_file ($file_name, @include)>
@@ -119,6 +120,17 @@
 }
 
 
+=item C<$SIMPLE_BACKUP_SUFFIX>
+
+Suffix to use for files backed up.  Defaults to `~'.  Can be overridden
+with the environment variable SIMPLE_BACKUP_SUFFIX.
+
+=cut
+
+use vars qw ($SIMPLE_BACKUP_SUFFIX);
+$SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
+
+
 =item C<update_file ($from, $to, [$force])>
 
 Rename C<$from> as C<$to>, preserving C<$to> timestamp if it has not
@@ -135,7 +147,6 @@
   my ($from, $to, $force) = @_;
   $force = 0
     unless defined $force;
-  my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
   use File::Compare;
   use File::Copy;
 
Index: lib/Autom4te/General.pm
===================================================================
RCS file: /sources/autoconf/autoconf/lib/Autom4te/General.pm,v
retrieving revision 1.37
diff -u -r1.37 General.pm
--- lib/Autom4te/General.pm     25 Aug 2006 21:21:19 -0000      1.37
+++ lib/Autom4te/General.pm     18 Jun 2007 22:06:55 -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);
Index: tests/torture.at
===================================================================
RCS file: /sources/autoconf/autoconf/tests/torture.at,v
retrieving revision 1.82
diff -u -r1.82 torture.at
--- tests/torture.at    12 Jun 2007 11:36:57 -0000      1.82
+++ tests/torture.at    18 Jun 2007 22:06:56 -0000
@@ -1179,3 +1179,39 @@
 AT_CHECK([test -f HeeHee.in])
 
 AT_CLEANUP
+
+## --------------------- ##
+## Unbootstrap (--clean) ##
+## --------------------- ##
+
+AT_SETUP([Unbootstrap with --clean])
+AT_KEYWORDS([autoreconf])
+
+# We use aclocal (via autoreconf).
+AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
+# We need a version of aclocal that is recent enough to support --clean
+AT_CHECK([aclocal --help | grep ' --clean' || exit 77], [], [ignore], [ignore])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_HEADERS(config.h:config.hin)
+AC_OUTPUT
+]])
+
+
+AT_DATA([config.hin], [])
+
+# Save the result of `find' to see whether we properly cleaned everything.
+AT_DATA([list.after], [])
+AT_DATA([list.before], [])
+
+# Save the list of files in the current directory.
+find . | sort >list.before
+
+AT_CHECK([autoreconf], [0], [ignore], [ignore])
+
+AT_CHECK([autoreconf --clean], [0], [ignore], [ignore])
+find . | sort >list.after
+AT_CMP([list.before], [list.after])
+
+AT_CLEANUP

Reply via email to