* lib/Autom4te/General.pm (&getopt): Work around the `-' Getopt bug.

* bin/autoheader.in, bin/autoupdate.in (&parse_args): Adjust.
* bin/autoscan.in: Use `getopt' and `find_files' etc.
Add -I, --include support.
* doc/autoconf.texi (autoscan Invocation): Adjust.
This commit is contained in:
Akim Demaille 2001-09-05 07:06:02 +00:00
parent 2d55f8a447
commit d3f9e418ab
11 changed files with 88 additions and 109 deletions

View File

@ -1,3 +1,12 @@
2001-09-05 Akim Demaille <akim@epita.fr>
* lib/Autom4te/General.pm (&getopt): Work around the `-' Getopt bug.
* bin/autoheader.in, bin/autoupdate.in (&parse_args): Adjust.
* bin/autoscan.in: Use `getopt' and `find_files' etc.
Add -I, --include support.
* doc/autoconf.texi (autoscan Invocation): Adjust.
2001-09-05 Akim Demaille <akim@epita.fr> 2001-09-05 Akim Demaille <akim@epita.fr>
CVS GNU M4 doesn't like `undefine(undefined)'. CVS GNU M4 doesn't like `undefine(undefined)'.

View File

@ -104,17 +104,11 @@ END
sub parse_args () sub parse_args ()
{ {
my $srcdir; my $srcdir;
# F*k. Getopt seems bogus and dies when given `-' with `bundling'.
# If fixed some day, use this: '' => sub { push @ARGV, "-" }
my $stdin = grep /^-$/, @ARGV;
@ARGV = grep !/^-$/, @ARGV;
getopt ('I|include|A|autoconf-dir|m|macrodir|l|localdir=s' => \@include, getopt ('I|include|A|autoconf-dir|m|macrodir|l|localdir=s' => \@include,
'f|force' => \$force, 'f|force' => \$force,
'W|warning' => \@warning); 'W|warning' => \@warning);
push @ARGV, '-'
if $stdin;
if (! @ARGV) if (! @ARGV)
{ {
my $configure_ac = find_configure_ac; my $configure_ac = find_configure_ac;

View File

@ -42,7 +42,6 @@ use Data::Dumper;
use Autom4te::General; use Autom4te::General;
use Autom4te::Struct; use Autom4te::Struct;
use Carp; use Carp;
use Getopt::Long;
use IO::File; use IO::File;
use strict; use strict;

View File

@ -22,14 +22,12 @@
BEGIN BEGIN
{ {
my $prefix = "@prefix@";
my $perllibdir = $ENV{'autom4te_perllibdir'} || "@datadir@"; my $perllibdir = $ENV{'autom4te_perllibdir'} || "@datadir@";
unshift @INC, "$perllibdir"; unshift @INC, "$perllibdir";
} }
use File::Basename; use File::Basename;
use File::Find; use File::Find;
use Getopt::Long;
use IO::File; use IO::File;
use Autom4te::General; use Autom4te::General;
use strict; use strict;
@ -71,21 +69,13 @@ my $log = new IO::File ">$me.log"
or die "$me: cannot open $me.log: $!\n"; or die "$me: cannot open $me.log: $!\n";
# Autoconf and lib files. # Autoconf and lib files.
my $autoconf = $ENV{'AUTOCONF'} || '@autoconf_name@'; my $autom4te = $ENV{'AUTOM4TE'} || '@autom4te-name@';
my $datadir = $ENV{"AC_MACRODIR"} || "@datadir@"; my $autoconf = "$autom4te --language=autoconf";
my @include = ('@datadir@');
# $help
## ------------------------ ## # -----
## Command line interface. ## $help = "Usage: $0 [OPTION] ... [SRCDIR]
## ------------------------ ##
# print_usage ()
# --------------
# Display usage (--help).
sub print_usage ()
{
print "Usage: $0 [OPTION] ... [SRCDIR]
Examine source files in the directory tree rooted at SRCDIR, or the Examine source files in the directory tree rooted at SRCDIR, or the
current directory if none is given. Search the source files for current directory if none is given. Search the source files for
@ -93,55 +83,44 @@ common portability problems, check for incompleteness of
`configure.ac', and create a file `$configure_scan' which is a `configure.ac', and create a file `$configure_scan' which is a
preliminary `configure.ac' for that package. preliminary `configure.ac' for that package.
-h, --help print this help, then exit -h, --help print this help, then exit
-V, --version print version number, then exit -V, --version print version number, then exit
-v, --verbose verbosely report processing -v, --verbose verbosely report processing
-d, --debug don't remove temporary files
Library directories: -I, --include=DIR look for input files in DIR. Accumulates
-A, --autoconf-dir=ACDIR Autoconf's files location (rarely needed)
-l, --localdir=DIR location of `aclocal.m4' and `acconfig.h'
Report bugs to <bug-autoconf\@gnu.org>.\n"; Report bugs to <bug-autoconf\@gnu.org>.\n";
exit 0;
}
# $version
# print_version () # --------
# ---------------- $version = "autoscan (@PACKAGE_NAME@) @VERSION@
# Display version (--version).
sub print_version
{
print "autoscan (@PACKAGE_NAME@) @VERSION@
Written by David J. MacKenzie. Written by David J. MacKenzie.
Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc. Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"; warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
exit 0;
}
## ------------------------ ##
## Command line interface. ##
## ------------------------ ##
# parse_args () # parse_args ()
# ------------- # -------------
# Process any command line arguments. # Process any command line arguments.
sub parse_args () sub parse_args ()
{ {
my $srcdir; getopt ("I|include|A|autoconf-dir|m|macrodir=s" => \@include);
Getopt::Long::config ("bundling");
Getopt::Long::GetOptions ("A|autoconf-dir|m|macrodir=s" => \$datadir,
"h|help" => \&print_usage,
"V|version" => \&print_version,
"v|verbose" => \$verbose)
or exit 1;
die "$me: too many arguments die "$me: too many arguments
Try `$me --help' for more information.\n" Try `$me --help' for more information.\n"
if (@ARGV > 1); if @ARGV > 1;
($srcdir) = @ARGV;
$srcdir = "."
if !defined $srcdir;
print "srcdir=$srcdir\n" if $verbose; my $srcdir = $ARGV[0] || ".";
verbose "srcdir = $srcdir";
chdir $srcdir || die "$me: cannot cd to $srcdir: $!\n"; chdir $srcdir || die "$me: cannot cd to $srcdir: $!\n";
} }
@ -170,7 +149,7 @@ sub init_tables ()
my $tables_are_consistent = 1; my $tables_are_consistent = 1;
foreach my $kind (@kinds) foreach my $kind (@kinds)
{ {
my $file = "$datadir/autoscan/$kind"; my $file = find_file ("autoscan/$kind", @include);
my $table = new IO::File $file my $table = new IO::File $file
or die "$me: cannot open $file: $!\n"; or die "$me: cannot open $file: $!\n";
while ($_ = $table->getline) while ($_ = $table->getline)
@ -189,7 +168,7 @@ sub init_tables ()
# consistency checks. # consistency checks.
if (!defined $2 && exists $macro{$kind}{$word}) if (!defined $2 && exists $macro{$kind}{$word})
{ {
warn ("$datadir/autoscan/$kind:$.: " warn ("$file:$.: "
. "ignoring implicit call to the generic macro for $word\n"); . "ignoring implicit call to the generic macro for $word\n");
$tables_are_consistent = 0; $tables_are_consistent = 0;
} }
@ -213,8 +192,8 @@ sub init_tables ()
## ----------------------- ## ## ----------------------- ##
# scan_c_file(FILENAME) # scan_c_file($FILENAME)
# --------------------- # ----------------------
sub scan_c_file ($) sub scan_c_file ($)
{ {
my ($filename) = @_; my ($filename) = @_;
@ -277,8 +256,8 @@ sub scan_c_file ($)
} }
# scan_makefile(MAKEFILE-NAME) # scan_makefile($MAKEFILE-NAME)
# ---------------------------- # -----------------------------
sub scan_makefile ($) sub scan_makefile ($)
{ {
my ($filename) = @_; my ($filename) = @_;
@ -317,8 +296,8 @@ sub scan_makefile ($)
} }
# scan_sh_file(SHELL-SCRIPT-NAME) # scan_sh_file($SHELL-SCRIPT-NAME)
# ------------------------------- # --------------------------------
sub scan_sh_file ($) sub scan_sh_file ($)
{ {
my ($filename) = @_; my ($filename) = @_;
@ -477,8 +456,8 @@ sub output_libraries ($)
} }
# output (CONFIGURE_SCAN) # output ($CONFIGURE_SCAN)
# ----------------------- # ------------------------
# Print a proto configure.ac. # Print a proto configure.ac.
sub output ($) sub output ($)
{ {
@ -524,8 +503,8 @@ sub output ($)
## --------------------------------------- ## ## --------------------------------------- ##
# check_configure_ac (CONFIGURE_AC) # check_configure_ac ($CONFIGURE_AC)
# --------------------------------- # ----------------------------------
# Use autoconf to check if all the suggested macros are included # Use autoconf to check if all the suggested macros are included
# in CONFIGURE_AC. # in CONFIGURE_AC.
sub check_configure_ac ($) sub check_configure_ac ($)
@ -539,9 +518,9 @@ sub check_configure_ac ($)
join (' -t ', '', join (' -t ', '',
uniq (sort (map { s/\(.*//; $_ } keys %needed_macros))); uniq (sort (map { s/\(.*//; $_ } keys %needed_macros)));
verbose "running: $autoconf -A $datadir $trace_option $configure_ac"; verbose "running: $autoconf $trace_option $configure_ac";
my $traces = my $traces =
new IO::File "$autoconf -A $datadir $trace_option $configure_ac|" new IO::File "$autoconf $trace_option $configure_ac|"
or die "$me: cannot open traces reading pipe: $!\n"; or die "$me: cannot open traces reading pipe: $!\n";
while ($_ = $traces->getline) while ($_ = $traces->getline)
@ -592,6 +571,10 @@ sub check_configure_ac ($)
## -------------- ## ## -------------- ##
parse_args; parse_args;
$autoconf .= " --debug" if $debug;
$autoconf .= " --verbose" if $verbose;
$autoconf .= join (' --include=', '', @include);
my $configure_ac = find_configure_ac; my $configure_ac = find_configure_ac;
init_tables; init_tables;
scan_files; scan_files;

View File

@ -33,6 +33,7 @@ use strict;
# Lib files. # Lib files.
my $autom4te = $ENV{'AUTOM4TE'} || '@autom4te-name@'; my $autom4te = $ENV{'AUTOM4TE'} || '@autom4te-name@';
my $autoconf = "$autom4te --language=autoconf";
# We need to find m4sugar. # We need to find m4sugar.
my @include = ('@datadir@'); my @include = ('@datadir@');
my $force = 0; my $force = 0;
@ -42,35 +43,32 @@ my $m4 = $ENV{"M4"} || "@M4@";
# $HELP # $HELP
# ----- # -----
$help = <<"END"; $help = "Usage: $0 [OPTION] ... [TEMPLATE-FILE...]
Usage: $0 [OPTION] ... [TEMPLATE-FILE...]
Update the TEMPLATE-FILE... if given, or \`configure.ac\' if present, Update the TEMPLATE-FILE... if given, or `configure.ac' if present,
or else \`configure.in\', to the syntax of the current version of or else `configure.in', to the syntax of the current version of
Autoconf. The original files are backed up. Autoconf. The original files are backed up.
Operation modes: Operation modes:
-h, --help print this help, then exit -h, --help print this help, then exit
-V, --version print version number, then exit -V, --version print version number, then exit
-v, --verbose verbosely report processing -v, --verbose verbosely report processing
-d, --debug don\'t remove temporary files -d, --debug don't remove temporary files
-I, --include=DIR look for input files in DIR. Accumulates -I, --include=DIR look for input files in DIR. Accumulates
-f, --force consider all the files are obsolete -f, --force consider all the files are obsolete
Report bugs to <bug-autoconf\@gnu.org>. Report bugs to <bug-autoconf\@gnu.org>.
END ";
# $VERSION # $VERSION
# -------- # --------
$version = <<"END"; $version = "autoupdate (@PACKAGE_NAME@) @VERSION@
autoupdate (@PACKAGE_NAME@) @VERSION@
Written by David J. MacKenzie and Akim Demaille. Written by David J. MacKenzie and Akim Demaille.
Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc. Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
END ";
## ---------- ## ## ---------- ##
## Routines. ## ## Routines. ##
@ -83,16 +81,10 @@ END
sub parse_args () sub parse_args ()
{ {
my $srcdir; my $srcdir;
# F*k. Getopt seems bogus and dies when given `-' with `bundling'.
# If fixed some day, use this: '' => sub { push @ARGV, "-" }
my $update_stdin = grep /^-$/, @ARGV;
@ARGV = grep !/^-$/, @ARGV;
getopt ('I|include|A|autoconf-dir|m|macrodir|l|localdir=s' => \@include, getopt ('I|include|A|autoconf-dir|m|macrodir|l|localdir=s' => \@include,
'f|force' => \$force); 'f|force' => \$force);
push @ARGV, '-'
if $update_stdin;
if (! @ARGV) if (! @ARGV)
{ {
my $configure_ac = find_configure_ac; my $configure_ac = find_configure_ac;
@ -109,8 +101,8 @@ sub parse_args ()
my @m4_builtins; my @m4_builtins;
# HANDLE_M4_SYMBOLS () # &handle_m4_symbols ()
# -------------------- # ---------------------
# Create the following $tmp files: # Create the following $tmp files:
# m4.m4 -- enable the m4 builtins. # m4.m4 -- enable the m4 builtins.
# unm4.m4 -- disable the m4 builtins. # unm4.m4 -- disable the m4 builtins.
@ -243,11 +235,10 @@ sub handle_autoconf_macros ()
## -------------- ## ## -------------- ##
parse_args; parse_args;
my $autoconf = "$autom4te --language=autoconf ";
$autoconf .= join (' --include=', '', @include);
$autoconf .= " --debug" if $debug; $autoconf .= " --debug" if $debug;
$autoconf .= " --force" if $force; $autoconf .= " --force" if $force;
$autoconf .= " --verbose" if $verbose; $autoconf .= " --verbose" if $verbose;
$autoconf .= join (' --include=', '', @include);
mktmpdir ('au'); mktmpdir ('au');
handle_m4_macros; handle_m4_macros;

View File

@ -1061,15 +1061,10 @@ Print the version number of Autoconf and exit.
Print the names of the files it examines and the potentially interesting Print the names of the files it examines and the potentially interesting
symbols it finds in them. This output can be voluminous. symbols it finds in them. This output can be voluminous.
@item --autoconf-dir=@var{dir} @item --include=@var{dir}
@itemx -A @var{dir} @itemx -I @var{dir}
@evindex AC_MACRODIR Also look for input files in @var{dir}. Multiple invocations
Override the location where the installed Autoconf data files are looked accumulate. Latest directories are looking in first.
for. You can also set the @code{AC_MACRODIR} environment variable to a
directory; this option overrides the environment variable.
This option is rarely needed and dangerous; it is only used when one
plays with different versions of Autoconf simultaneously.
@end table @end table
@node ifnames Invocation @node ifnames Invocation

View File

@ -153,13 +153,19 @@ sub find_file ($@)
} }
# getopt (%OPTIONS) # getopt (%OPTION)
# ----------------- # ----------------
# Handle the %OPTION, plus all the common options.
# Work around Getopt bugs wrt `-'.
sub getopt (%) sub getopt (%)
{ {
my (%option) = @_; my (%option) = @_;
use Getopt::Long; use Getopt::Long;
# F*k. Getopt seems bogus and dies when given `-' with `bundling'.
# If fixed some day, use this: '' => sub { push @ARGV, "-" }
my $stdin = grep /^-$/, @ARGV;
@ARGV = grep !/^-$/, @ARGV;
%option = (%option, %option = (%option,
"h|help" => sub { print $help; exit 0 }, "h|help" => sub { print $help; exit 0 },
"V|version" => sub { print $version; exit 0 }, "V|version" => sub { print $version; exit 0 },
@ -170,6 +176,9 @@ sub getopt (%)
Getopt::Long::Configure ("bundling"); Getopt::Long::Configure ("bundling");
GetOptions (%option) GetOptions (%option)
or exit 1; or exit 1;
push @ARGV, '-'
if $stdin;
} }

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.24. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.24.
.TH AUTOHEADER "1" "August 2001" "GNU Autoconf 2.52e" FSF .TH AUTOHEADER "1" "September 2001" "GNU Autoconf 2.52e" FSF
.SH NAME .SH NAME
autoheader \- Create a template header for configure autoheader \- Create a template header for configure
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.24. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.24.
.TH AUTOM4TE "1" "August 2001" "GNU Autoconf 2.52e" FSF .TH AUTOM4TE "1" "September 2001" "GNU Autoconf 2.52e" FSF
.SH NAME .SH NAME
autom4te \- Generate files and scripts thanks to M4 autom4te \- Generate files and scripts thanks to M4
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.24. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.24.
.TH AUTOSCAN "1" "August 2001" "GNU Autoconf 2.52e" FSF .TH AUTOSCAN "1" "September 2001" "GNU Autoconf 2.52e" FSF
.SH NAME .SH NAME
autoscan \- Generate a preliminary configure.in autoscan \- Generate a preliminary configure.in
.SH SYNOPSIS .SH SYNOPSIS
@ -20,13 +20,12 @@ print version number, then exit
.TP .TP
\fB\-v\fR, \fB\-\-verbose\fR \fB\-v\fR, \fB\-\-verbose\fR
verbosely report processing verbosely report processing
.SS "Library directories:"
.TP .TP
\fB\-A\fR, \fB\-\-autoconf\-dir\fR=\fIACDIR\fR \fB\-d\fR, \fB\-\-debug\fR
Autoconf's files location (rarely needed) don't remove temporary files
.TP .TP
\fB\-l\fR, \fB\-\-localdir\fR=\fIDIR\fR \fB\-I\fR, \fB\-\-include\fR=\fIDIR\fR
location of `aclocal.m4' and `acconfig.h' look for input files in DIR. Accumulates
.SH AUTHOR .SH AUTHOR
Written by David J. MacKenzie. Written by David J. MacKenzie.
.PP .PP

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.24. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.24.
.TH AUTOUPDATE "1" "August 2001" "GNU Autoconf 2.52e" FSF .TH AUTOUPDATE "1" "September 2001" "GNU Autoconf 2.52e" FSF
.SH NAME .SH NAME
autoupdate \- Update a configure.in to a newer Autoconf autoupdate \- Update a configure.in to a newer Autoconf
.SH SYNOPSIS .SH SYNOPSIS