From: Akim Demaille Date: Wed, 5 Sep 2001 07:06:02 +0000 (+0000) Subject: * lib/Autom4te/General.pm (&getopt): Work around the `-' Getopt bug. X-Git-Tag: AUTOCONF-2.52f~171 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3f9e418ab787e17aea66d5dcbaa7939cd161e4d;p=thirdparty%2Fautoconf.git * 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. --- diff --git a/ChangeLog b/ChangeLog index dba605d10..aa2130117 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-09-05 Akim Demaille + + * 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 CVS GNU M4 doesn't like `undefine(undefined)'. diff --git a/bin/autoheader.in b/bin/autoheader.in index 7e3421865..9c43aa91b 100644 --- a/bin/autoheader.in +++ b/bin/autoheader.in @@ -104,17 +104,11 @@ END sub parse_args () { 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, 'f|force' => \$force, 'W|warning' => \@warning); - push @ARGV, '-' - if $stdin; - if (! @ARGV) { my $configure_ac = find_configure_ac; diff --git a/bin/autom4te.in b/bin/autom4te.in index c501b41d8..947e93f40 100644 --- a/bin/autom4te.in +++ b/bin/autom4te.in @@ -42,7 +42,6 @@ use Data::Dumper; use Autom4te::General; use Autom4te::Struct; use Carp; -use Getopt::Long; use IO::File; use strict; diff --git a/bin/autoscan.in b/bin/autoscan.in index ce7b5f727..930dbd61c 100644 --- a/bin/autoscan.in +++ b/bin/autoscan.in @@ -22,14 +22,12 @@ BEGIN { - my $prefix = "@prefix@"; my $perllibdir = $ENV{'autom4te_perllibdir'} || "@datadir@"; unshift @INC, "$perllibdir"; } use File::Basename; use File::Find; -use Getopt::Long; use IO::File; use Autom4te::General; use strict; @@ -71,21 +69,13 @@ my $log = new IO::File ">$me.log" or die "$me: cannot open $me.log: $!\n"; # Autoconf and lib files. -my $autoconf = $ENV{'AUTOCONF'} || '@autoconf_name@'; -my $datadir = $ENV{"AC_MACRODIR"} || "@datadir@"; +my $autom4te = $ENV{'AUTOM4TE'} || '@autom4te-name@'; +my $autoconf = "$autom4te --language=autoconf"; +my @include = ('@datadir@'); - -## ------------------------ ## -## Command line interface. ## -## ------------------------ ## - - -# print_usage () -# -------------- -# Display usage (--help). -sub print_usage () -{ - print "Usage: $0 [OPTION] ... [SRCDIR] +# $help +# ----- +$help = "Usage: $0 [OPTION] ... [SRCDIR] Examine source files in the directory tree rooted at SRCDIR, or the 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 preliminary `configure.ac' for that package. - -h, --help print this help, then exit - -V, --version print version number, then exit - -v, --verbose verbosely report processing - -Library directories: - -A, --autoconf-dir=ACDIR Autoconf's files location (rarely needed) - -l, --localdir=DIR location of `aclocal.m4' and `acconfig.h' + -h, --help print this help, then exit + -V, --version print version number, then exit + -v, --verbose verbosely report processing + -d, --debug don't remove temporary files + -I, --include=DIR look for input files in DIR. Accumulates Report bugs to .\n"; - exit 0; -} - -# print_version () -# ---------------- -# Display version (--version). -sub print_version -{ - print "autoscan (@PACKAGE_NAME@) @VERSION@ +# $version +# -------- +$version = "autoscan (@PACKAGE_NAME@) @VERSION@ Written by David J. MacKenzie. Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc. 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"; - exit 0; -} + + +## ------------------------ ## +## Command line interface. ## +## ------------------------ ## + # parse_args () # ------------- # Process any command line arguments. sub parse_args () { - my $srcdir; - 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; + getopt ("I|include|A|autoconf-dir|m|macrodir=s" => \@include); die "$me: too many arguments Try `$me --help' for more information.\n" - if (@ARGV > 1); - ($srcdir) = @ARGV; - $srcdir = "." - if !defined $srcdir; + if @ARGV > 1; + + my $srcdir = $ARGV[0] || "."; - print "srcdir=$srcdir\n" if $verbose; + verbose "srcdir = $srcdir"; chdir $srcdir || die "$me: cannot cd to $srcdir: $!\n"; } @@ -170,7 +149,7 @@ sub init_tables () my $tables_are_consistent = 1; foreach my $kind (@kinds) { - my $file = "$datadir/autoscan/$kind"; + my $file = find_file ("autoscan/$kind", @include); my $table = new IO::File $file or die "$me: cannot open $file: $!\n"; while ($_ = $table->getline) @@ -189,7 +168,7 @@ sub init_tables () # consistency checks. if (!defined $2 && exists $macro{$kind}{$word}) { - warn ("$datadir/autoscan/$kind:$.: " + warn ("$file:$.: " . "ignoring implicit call to the generic macro for $word\n"); $tables_are_consistent = 0; } @@ -213,8 +192,8 @@ sub init_tables () ## ----------------------- ## -# scan_c_file(FILENAME) -# --------------------- +# scan_c_file($FILENAME) +# ---------------------- sub scan_c_file ($) { my ($filename) = @_; @@ -277,8 +256,8 @@ sub scan_c_file ($) } -# scan_makefile(MAKEFILE-NAME) -# ---------------------------- +# scan_makefile($MAKEFILE-NAME) +# ----------------------------- sub scan_makefile ($) { 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 ($) { my ($filename) = @_; @@ -477,8 +456,8 @@ sub output_libraries ($) } -# output (CONFIGURE_SCAN) -# ----------------------- +# output ($CONFIGURE_SCAN) +# ------------------------ # Print a proto configure.ac. 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 # in CONFIGURE_AC. sub check_configure_ac ($) @@ -539,9 +518,9 @@ sub check_configure_ac ($) join (' -t ', '', 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 = - 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"; while ($_ = $traces->getline) @@ -592,6 +571,10 @@ sub check_configure_ac ($) ## -------------- ## parse_args; +$autoconf .= " --debug" if $debug; +$autoconf .= " --verbose" if $verbose; +$autoconf .= join (' --include=', '', @include); + my $configure_ac = find_configure_ac; init_tables; scan_files; diff --git a/bin/autoupdate.in b/bin/autoupdate.in index 7b60f7b06..af3198a1d 100644 --- a/bin/autoupdate.in +++ b/bin/autoupdate.in @@ -33,6 +33,7 @@ use strict; # Lib files. my $autom4te = $ENV{'AUTOM4TE'} || '@autom4te-name@'; +my $autoconf = "$autom4te --language=autoconf"; # We need to find m4sugar. my @include = ('@datadir@'); my $force = 0; @@ -42,35 +43,32 @@ my $m4 = $ENV{"M4"} || "@M4@"; # $HELP # ----- -$help = <<"END"; -Usage: $0 [OPTION] ... [TEMPLATE-FILE...] +$help = "Usage: $0 [OPTION] ... [TEMPLATE-FILE...] -Update the TEMPLATE-FILE... if given, or \`configure.ac\' if present, -or else \`configure.in\', to the syntax of the current version of +Update the TEMPLATE-FILE... if given, or `configure.ac' if present, +or else `configure.in', to the syntax of the current version of Autoconf. The original files are backed up. Operation modes: -h, --help print this help, then exit -V, --version print version number, then exit -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 -f, --force consider all the files are obsolete Report bugs to . -END +"; # $VERSION # -------- -$version = <<"END"; -autoupdate (@PACKAGE_NAME@) @VERSION@ +$version = "autoupdate (@PACKAGE_NAME@) @VERSION@ Written by David J. MacKenzie and Akim Demaille. Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -END - +"; ## ---------- ## ## Routines. ## @@ -83,16 +81,10 @@ END sub parse_args () { 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, 'f|force' => \$force); - push @ARGV, '-' - if $update_stdin; - if (! @ARGV) { my $configure_ac = find_configure_ac; @@ -109,8 +101,8 @@ sub parse_args () my @m4_builtins; -# HANDLE_M4_SYMBOLS () -# -------------------- +# &handle_m4_symbols () +# --------------------- # Create the following $tmp files: # m4.m4 -- enable the m4 builtins. # unm4.m4 -- disable the m4 builtins. @@ -243,11 +235,10 @@ sub handle_autoconf_macros () ## -------------- ## parse_args; -my $autoconf = "$autom4te --language=autoconf "; -$autoconf .= join (' --include=', '', @include); $autoconf .= " --debug" if $debug; $autoconf .= " --force" if $force; $autoconf .= " --verbose" if $verbose; +$autoconf .= join (' --include=', '', @include); mktmpdir ('au'); handle_m4_macros; diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 0f5cff589..f7fba22ae 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -1061,15 +1061,10 @@ Print the version number of Autoconf and exit. Print the names of the files it examines and the potentially interesting symbols it finds in them. This output can be voluminous. -@item --autoconf-dir=@var{dir} -@itemx -A @var{dir} -@evindex AC_MACRODIR -Override the location where the installed Autoconf data files are looked -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. +@item --include=@var{dir} +@itemx -I @var{dir} +Also look for input files in @var{dir}. Multiple invocations +accumulate. Latest directories are looking in first. @end table @node ifnames Invocation diff --git a/lib/Autom4te/General.pm b/lib/Autom4te/General.pm index 930646b6a..b34554595 100644 --- a/lib/Autom4te/General.pm +++ b/lib/Autom4te/General.pm @@ -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 (%) { my (%option) = @_; 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, "h|help" => sub { print $help; exit 0 }, "V|version" => sub { print $version; exit 0 }, @@ -170,6 +176,9 @@ sub getopt (%) Getopt::Long::Configure ("bundling"); GetOptions (%option) or exit 1; + + push @ARGV, '-' + if $stdin; } diff --git a/man/autoheader.1 b/man/autoheader.1 index 508afb478..a9b670f4c 100644 --- a/man/autoheader.1 +++ b/man/autoheader.1 @@ -1,5 +1,5 @@ .\" 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 autoheader \- Create a template header for configure .SH SYNOPSIS diff --git a/man/autom4te.1 b/man/autom4te.1 index a13567812..b291fd452 100644 --- a/man/autom4te.1 +++ b/man/autom4te.1 @@ -1,5 +1,5 @@ .\" 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 autom4te \- Generate files and scripts thanks to M4 .SH SYNOPSIS diff --git a/man/autoscan.1 b/man/autoscan.1 index a47db24d5..eefcc48a9 100644 --- a/man/autoscan.1 +++ b/man/autoscan.1 @@ -1,5 +1,5 @@ .\" 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 autoscan \- Generate a preliminary configure.in .SH SYNOPSIS @@ -20,13 +20,12 @@ print version number, then exit .TP \fB\-v\fR, \fB\-\-verbose\fR verbosely report processing -.SS "Library directories:" .TP -\fB\-A\fR, \fB\-\-autoconf\-dir\fR=\fIACDIR\fR -Autoconf's files location (rarely needed) +\fB\-d\fR, \fB\-\-debug\fR +don't remove temporary files .TP -\fB\-l\fR, \fB\-\-localdir\fR=\fIDIR\fR -location of `aclocal.m4' and `acconfig.h' +\fB\-I\fR, \fB\-\-include\fR=\fIDIR\fR +look for input files in DIR. Accumulates .SH AUTHOR Written by David J. MacKenzie. .PP diff --git a/man/autoupdate.1 b/man/autoupdate.1 index 4c1478c07..45b1df6fb 100644 --- a/man/autoupdate.1 +++ b/man/autoupdate.1 @@ -1,5 +1,5 @@ .\" 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 autoupdate \- Update a configure.in to a newer Autoconf .SH SYNOPSIS