]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/Autom4te/General.pm: (&catfile, &canonfile)
authorAkim Demaille <akim@epita.fr>
Sat, 3 Nov 2001 12:01:35 +0000 (12:01 +0000)
committerAkim Demaille <akim@epita.fr>
Sat, 3 Nov 2001 12:01:35 +0000 (12:01 +0000)
(&file_name_is_absolute): New, wrappers around routines from
File::Spec.
Use and export them.
(&find_configure_ac): Optionally take a directory where to look at.
* bin/autoreconf.in (&parse_args): Trim the configure.ac part of
the arguments.
Default @ARGV to `.', not find_configure_ac.
(&autoreconf): Argument is a directory.
Trace AC_CONFIG_SUBDIRS and schedule the subdirs for autoreconf'ing.
* doc/autoconf.texi (autoreconf Invocation): Update.

ChangeLog
NEWS
TODO
bin/autoreconf.in
doc/autoconf.texi
lib/Autom4te/General.pm
man/autoreconf.1

index c5a83e574788a5586d9a29125ae26b57d5b1c94e..536869489456e40ec5f24f4c31de4a991a2e27e6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2001-11-03  Akim Demaille  <akim@epita.fr>
+
+       * lib/Autom4te/General.pm: (&catfile, &canonfile)
+       (&file_name_is_absolute): New, wrappers around routines from
+       File::Spec.
+       Use and export them.
+       (&find_configure_ac): Optionally take a directory where to look at.
+       * bin/autoreconf.in (&parse_args): Trim the configure.ac part of
+       the arguments.
+       Default @ARGV to `.', not find_configure_ac.
+       (&autoreconf): Argument is a directory.
+       Trace AC_CONFIG_SUBDIRS and schedule the subdirs for autoreconf'ing.
+       * doc/autoconf.texi (autoreconf Invocation): Update.
+
 2001-11-03  Akim Demaille  <akim@epita.fr>
 
        * lib/Autom4te/General.pm (@export_vars, @export_subs)
diff --git a/NEWS b/NEWS
index 3c161205a582d9d905b9ae5b1ae3c705f2790d81..62ed56e24ade613230113b6658fb96c3da7fcec6 100644 (file)
--- a/NEWS
+++ b/NEWS
   Runs gettextize and libtoolize when appropriate.
 - autoreconf
   --m4dir is no longer supported.
+- autoreconf
+  Now runs only in the specified directories, defaulting to `.',
+  but understands AC_CONFIG_SUBDIRS for dependent directories.
+  Before, it used to run on all the `configure.ac' found in the
+  current tree.
+  Independent packages are properly updated.
 
 ** Bug fixes
 
diff --git a/TODO b/TODO
index 2719297732f5d6017a61483bc43946829d02ecb9..0adeff4f9e7b97cc5675df4132d6ba588977e097 100644 (file)
--- a/TODO
+++ b/TODO
@@ -651,23 +651,6 @@ with autoconf scripts.
 
 ------------------------------------------------------------------------------
 
-autoreconf doesn't support having (in the same tree) both directories
-that are parts of a larger package (sharing aclocal.m4 and
-acconfig.h), and directories that are independent packages (each with
-their own ac*).  It assumes that they are all part of the same
-package, if you use --localdir, or that each directory is a separate
-package, if you don't use it.
-
-autoreconf should automatically figure out which ac* files to use--the
-closest ones up the tree from each directory, probably, unless
-overridden by --localdir.
-
-Also, autoreconf recurses on all subdirectories containing a
-configure.in, not just those given by an AC_CONFIG_SUBDIRS directive.
-This may not be a problem in practice.
-
-------------------------------------------------------------------------------
-
 Copyright 1994, 1995, 1996, 1999, 2000, 2001 Free Software
 Foundation, Inc.
 
index 062ab8274f15d5a7bdec41d8d24c7a5dc8eb0596..156a97d329b0e0dd1685bbc91436d1ab58022f9a 100644 (file)
@@ -43,12 +43,12 @@ use strict;
 
 # $HELP
 # -----
-$help = "Usage: $0 [OPTION] ... [CONFIGURE-AC] ...
+$help = "Usage: $0 [OPTION] ... [CONFIGURE-AC or DIRECTORY] ...
 
 Run `autoconf' (and `autoheader', `aclocal', `automake', `gettextize',
 and `libtoolize' where appropriate) repeatedly to remake the GNU Build
-System files in the directory tree driven by CONFIGURE-AC (defaulting
-to `./configure.ac').
+System files in the DIRECTORIES or the directory trees driven by
+CONFIGURE-AC (defaulting to `.').
 
 By default, it only remakes those files that are older than their
 predecessors.  If you install new versions of the GNU Build System,
@@ -118,8 +118,12 @@ sub parse_args ()
          'i|install'                                        => \$install,
          's|symlink'                                        => \$symlink);
 
-  push @ARGV, find_configure_ac
-    unless @ARGV;
+  # Even if the user specified a configure.ac, trim to get the
+  # directory, and look for configure.ac again.  Because (i) the code
+  # is simpler, and (ii) we are still able to diagnose simultaneous
+  # presence of configure.ac and configure.in.
+  @ARGV = map { /configure\.(ac|in)$/ ? dirname ($_) : $_ } @ARGV;
+  push @ARGV, '.' unless @ARGV;
 
   if ($verbose && $debug)
     {
@@ -175,17 +179,20 @@ sub parse_args ()
 }
 
 
-# &autoreconf ($CONFIGURE_AC_PATH)
-# --------------------------------
-# Reconf the directory of $CONFIGURE_AC_PATH.
+# &autoreconf ($DIRECTORY)
+# ------------------------
+# Reconf the $DIRECTORY.
 sub autoreconf ($)
 {
-  my ($configure_ac_path) = @_;
-  my ($configure_ac, $subdir) = fileparse ($configure_ac_path);
-  verbose "working in $subdir, on $configure_ac";
-  chdir $subdir
-    or die "$me: cannot chdir to $subdir: $!\n";
+  my ($directory) = @_;
 
+  verbose "working in `$directory'";
+  chdir $directory
+    or die "$me: cannot chdir to $directory: $!\n";
+
+  my $configure_ac = find_configure_ac;
+  die "$me: cannot find `configure.ac' in `$directory'\n"
+    unless $configure_ac;
 
   # ---------------------- #
   # Is it using Autoconf?  #
@@ -219,18 +226,21 @@ sub autoreconf ($)
   my $uses_libtool;
   my $uses_autoheader;
   my $uses_aclocal;
+  my @subdir;
   my $traces = new Autom4te::XFile
     ("$autoconf"
      . join (' --trace=', '',
             'AC_INIT', 'AM_GNU_GETTEXT', 'AM_PROG_LIBTOOL',
-            'AC_CONFIG_HEADERS')
-     . " |");
+            'AC_CONFIG_HEADERS',
+            'AC_CONFIG_SUBDIRS:AC_CONFIG_SUBDIRS:\$1')
+     . ' |');
   while ($_ = $traces->getline)
     {
-      $uses_autoconf = 1   if /AC_INIT/;
-      $uses_gettext = 1    if /AM_GNU_GETTEXT/;
-      $uses_libtool = 1    if /AM_PROG_LIBTOOL/;
-      $uses_autoheader = 1 if /AC_CONFIG_HEADERS/;
+      $uses_autoconf = 1          if /AC_INIT/;
+      $uses_gettext = 1           if /AM_GNU_GETTEXT/;
+      $uses_libtool = 1           if /AM_PROG_LIBTOOL/;
+      $uses_autoheader = 1        if /AC_CONFIG_HEADERS/;
+      push @ARGV, split (' ', $1) if /AC_CONFIG_SUBDIRS:(.*)/;
     }
 
 
@@ -381,5 +391,6 @@ parse_args;
 
 # Autoreconf all the given configure.ac.  A while loop, not a for,
 # since the list can change at runtime because of AC_CONFIG_SUBDIRS.
+print STDERR "@ARGV\n";
 autoreconf (shift @ARGV)
   while (@ARGV);
index a735fd5378a44b357ecc87aa9f8784a9b4cc24d2..72dd4cb0aee75d2809ab07064a0ff20d4ba7434b 100644 (file)
@@ -1371,37 +1371,25 @@ AUTOMAKE|:::::|automake|:::::|$missing_dir
 
 @node autoreconf Invocation
 @section Using @code{autoreconf} to Update @code{configure} Scripts
-@cindex @code{autoreconf}
-
-@c FIXME: Now completely outdated.
-
-If you have a lot of Autoconf-generated @code{configure} scripts, the
-@code{autoreconf} program can save you some work.  It runs
-@code{autoconf} (and @code{autoheader}, where appropriate) repeatedly to
-remake the Autoconf @code{configure} scripts and configuration header
-templates in the directory tree rooted at the current directory.  By
-default, it only remakes those files that are older than their
-@file{configure.ac} or (if present) @file{aclocal.m4}.  Since
-@code{autoheader} does not change the timestamp of its output file if
-the file wouldn't be changing, this is not necessarily the minimum
-amount of work.  If you install a new version of Autoconf, you can make
-@code{autoreconf} remake @emph{all} of the files by giving it the
+@cindex @command{autoreconf}
+
+Installing the various components of the @sc{gnu} Build System can be
+tedious: running @command{gettextize}, @command{automake} etc. in each
+directory.  It may be needed either because some tools such as
+@command{automake} have been updated on your system, or because some of
+the sources such as @file{configure.ac} have been updated, or finally,
+simply in order to install the @sc{gnu} Build System in a fresh tree.
+
+It runs @command{autoconf}, @command{autoheader}, @command{aclocal},
+@command{automake}, @command{libtoolize}, and @command{gettextize} (when
+appropriate) repeatedly to update the @sc{gnu} Build System in specified
+directories, and their subdirectories (@pxref{Subdirectories}).  By
+default, it only remakes those files that are older than their sources.
+
+If you install a new version of some tools, you can make
+@command{autoreconf} remake @emph{all} of the files by giving it the
 @option{--force} option.
 
-If you give @code{autoreconf} the @option{--autoconf-dir=@var{dir}} or
-@option{--localdir=@var{dir}} options, it passes them down to
-@code{autoconf} and @code{autoheader} (with relative paths adjusted
-properly).
-
-@code{autoreconf} does not support having, in the same directory tree,
-both directories that are parts of a larger package (sharing
-@file{aclocal.m4} and @file{acconfig.h}) and directories that are
-independent packages (each with their own @file{aclocal.m4} and
-@file{acconfig.h}).  It assumes that they are all part of the same
-package if you use @option{--localdir}, or that each directory is a
-separate package if you don't use it.  This restriction may be removed
-in the future.
-
 @xref{Automatic Remaking}, for @file{Makefile} rules to automatically
 remake @code{configure} scripts when their source files change.  That
 method handles the timestamps of configuration header templates
@@ -1409,7 +1397,7 @@ properly, but does not pass @option{--autoconf-dir=@var{dir}} or
 @option{--localdir=@var{dir}}.
 
 @noindent
-@code{autoreconf} accepts the following options:
+@command{autoreconf} accepts the following options:
 
 @table @option
 @item --help
index 6230fe3865e28ca91bb7afd649c9eccae22ab133..52cf402a6b69401ed31acee71917fc7c25d72dfc 100644 (file)
@@ -21,6 +21,7 @@ package Autom4te::General;
 use 5.005_03;
 use Exporter;
 use File::Basename;
+use File::Spec;
 use File::stat;
 use IO::File;
 use Carp;
@@ -36,7 +37,8 @@ my @export_vars =
 
 # Functions we define and export.
 my @export_subs =
-  qw (&backname &debug &find_configure_ac &find_file
+  qw (&backname &catfile &canonpath &debug
+      &file_name_is_absolute &find_configure_ac &find_file
       &getopt &mktmpdir &mtime
       &uniq &update_file &up_to_date_p &verbose &xsystem);
 
@@ -131,8 +133,6 @@ sub END
 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
 sub backname ($)
 {
-  use File::Spec;
-
   my ($file) = @_;
   my $underscore = $_;
   my @res;
@@ -151,7 +151,27 @@ sub backname ($)
     }
 
   $_ = $underscore;
-  return File::Spec->canonpath (File::Spec->catfile (@res))
+  return canonpath (catfile (@res))
+}
+
+
+# $FILE
+# &catfile (@COMPONENT)
+# ---------------------
+sub catfile (@)
+{
+  my (@component) = @_;
+  return File::Spec->catfile (@component);
+}
+
+
+# $FILE
+# &canonpath ($FILE)
+# ------------------
+sub canonpath ($)
+{
+  my ($file) = @_;
+  return File::Spec->canonpath ($file);
 }
 
 
@@ -165,23 +185,38 @@ sub debug (@)
 }
 
 
+# $BOOLEAN
+# &file_name_is_absolute ($FILE)
+# ------------------------------
+sub file_name_is_absolute ($)
+{
+  my ($file) = @_;
+  return File::Spec->file_name_is_absolute ($file);
+}
+
+
 # $CONFIGURE_AC
-# &find_configure_ac ()
-# ---------------------
-sub find_configure_ac ()
+# &find_configure_ac ([$DIRECTORY = `.'])
+# ---------------------------------------
+sub find_configure_ac (;$)
 {
-  if (-f 'configure.ac')
+  my ($directory) = @_;
+  $directory ||= '.';
+  my $configure_ac = canonpath (catfile ($directory, 'configure.ac'));
+  my $configure_in = canonpath (catfile ($directory, 'configure.in'));
+
+  if (-f $configure_ac)
     {
-      if (-f 'configure.in')
+      if (-f $configure_in)
        {
-         carp "warning: `configure.ac' and `configure.in' both present.\n";
-         carp "warning: proceeding with `configure.ac'.\n";
+         carp "$me: warning: `$configure_ac' and `$configure_in' both present.\n";
+         carp "$me: warning: proceeding with `$configure_ac'.\n";
        }
-      return 'configure.ac';
+      return $configure_ac;
     }
-  elsif (-f 'configure.in')
+  elsif (-f $configure_in)
     {
-      return 'configure.in';
+      return $configure_in;
     }
   return;
 }
@@ -198,18 +233,16 @@ sub find_configure_ac ()
 # if absent.
 sub find_file ($@)
 {
-  use File::Spec;
-
   my ($filename, @include) = @_;
   my $optional = 0;
 
   $optional = 1
     if $filename =~ s/\?$//;
 
-  return File::Spec->canonpath ($filename)
+  return canonpath ($filename)
     if -e $filename;
 
-  if (File::Spec->file_name_is_absolute ($filename))
+  if (file_name_is_absolute ($filename))
     {
       die "$me: no such file or directory: $filename\n"
        unless $optional;
@@ -218,8 +251,8 @@ sub find_file ($@)
 
   foreach my $path (reverse @include)
     {
-      return File::Spec->canonpath (File::Spec->catfile ($path, $filename))
-       if -e File::Spec->catfile ($path, $filename)
+      return canonpath (catfile ($path, $filename))
+       if -e catfile ($path, $filename);
     }
 
   die "$me: no such file or directory: $filename\n"
@@ -254,7 +287,7 @@ sub getopt (%)
   GetOptions (%option)
     or exit 1;
 
-    push @ARGV, '-'
+  push @ARGV, '-'
     if $stdin;
 }
 
index cec0092d71b2917005eb789343a962d18a1e12f2..e7e66752355992b33861f28413681a7c92bf171e 100644 (file)
@@ -4,12 +4,12 @@
 autoreconf \- Update generated configuration files
 .SH SYNOPSIS
 .B autoreconf
-[\fIOPTION\fR] ... [\fICONFIGURE-AC\fR] ...
+[\fIOPTION\fR] ... [\fICONFIGURE-AC or DIRECTORY\fR] ...
 .SH DESCRIPTION
 Run `autoconf' (and `autoheader', `aclocal', `automake', `gettextize',
 and `libtoolize' where appropriate) repeatedly to remake the GNU Build
-System files in the directory tree driven by CONFIGURE-AC (defaulting
-to `./configure.ac').
+System files in the DIRECTORIES or the directory trees driven by
+CONFIGURE-AC (defaulting to `.').
 .PP
 By default, it only remakes those files that are older than their
 predecessors.  If you install new versions of the GNU Build System,