From: Akim Demaille Date: Sat, 3 Nov 2001 12:01:35 +0000 (+0000) Subject: * lib/Autom4te/General.pm: (&catfile, &canonfile) X-Git-Tag: AUTOCONF-2.52g~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8993e7a7fafb1988e7cbff4f2ed95b7ee0368d01;p=thirdparty%2Fautoconf.git * 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. --- diff --git a/ChangeLog b/ChangeLog index c5a83e574..536869489 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2001-11-03 Akim Demaille + + * 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 * lib/Autom4te/General.pm (@export_vars, @export_subs) diff --git a/NEWS b/NEWS index 3c161205a..62ed56e24 100644 --- a/NEWS +++ b/NEWS @@ -48,6 +48,12 @@ 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 271929773..0adeff4f9 100644 --- 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. diff --git a/bin/autoreconf.in b/bin/autoreconf.in index 062ab8274..156a97d32 100644 --- a/bin/autoreconf.in +++ b/bin/autoreconf.in @@ -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); diff --git a/doc/autoconf.texi b/doc/autoconf.texi index a735fd537..72dd4cb0a 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -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 diff --git a/lib/Autom4te/General.pm b/lib/Autom4te/General.pm index 6230fe386..52cf402a6 100644 --- a/lib/Autom4te/General.pm +++ b/lib/Autom4te/General.pm @@ -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; } diff --git a/man/autoreconf.1 b/man/autoreconf.1 index cec0092d7..e7e667523 100644 --- a/man/autoreconf.1 +++ b/man/autoreconf.1 @@ -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,