From: Akim Demaille Date: Fri, 31 Aug 2001 13:33:10 +0000 (+0000) Subject: * lib/Autom4te/General.pm ($version, $help, &getopt): New. X-Git-Tag: AUTOCONF-2.52d~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7e99feee5b060bc0dd895525a18b1f0c71fc8a0;p=thirdparty%2Fautoconf.git * lib/Autom4te/General.pm ($version, $help, &getopt): New. * bin/autoupdate.in, bin/autoheader.in, bin/autom4te.in: Use them. * bin/autom4te.in ($autoconf): Pass --force. `print $out' doesn't print `$_' but `$out'. * tests/tools.at (Syntax of the Perl scripts): Pass the lib dir. (autoheader): Pass --force since the test suite goes too fast for the time stamps. Adjust to the new autoheader messages. --- diff --git a/ChangeLog b/ChangeLog index 05e863eda..b8fd59a9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2001-08-31 Akim Demaille + + * lib/Autom4te/General.pm ($version, $help, &getopt): New. + * bin/autoupdate.in, bin/autoheader.in, bin/autom4te.in: Use them. + * bin/autom4te.in ($autoconf): Pass --force. + `print $out' doesn't print `$_' but `$out'. + * tests/tools.at (Syntax of the Perl scripts): Pass the lib dir. + (autoheader): Pass --force since the test suite goes too fast for + the time stamps. + Adjust to the new autoheader messages. + 2001-08-31 Akim Demaille * bin/autoheader.in: Handle the acconfig.h etc. junk files. diff --git a/bin/autoheader.in b/bin/autoheader.in index 52e6712f0..f7fe1be86 100644 --- a/bin/autoheader.in +++ b/bin/autoheader.in @@ -53,17 +53,9 @@ my $m4 = $ENV{"M4"} || "@M4@"; my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~'; -## ---------- ## -## Routines. ## -## ---------- ## - - -# print_usage () -# -------------- -# Display usage (--help). -sub print_usage () -{ - print <<"END"; +# $HELP +# ----- +$help = <<"END"; Usage: $0 [OPTION] ... [TEMPLATE-FILE] Create a template file of C \`#define\' statements for \`configure\' to @@ -90,16 +82,11 @@ Library directories: Report bugs to . END - exit 0; -} -# print_version () -# ---------------- -# Display version (--version). -sub print_version -{ - print < sub { push @ARGV, "-" } my $stdin = grep /^-$/, @ARGV; @ARGV = grep !/^-$/, @ARGV; - Getopt::Long::config ("bundling"); - Getopt::Long::GetOptions ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir, - 'l|localdir=s' => \$localdir, - 'd|debug' => \$debug, - 'h|help' => \&print_usage, - 'V|version' => \&print_version, - 'v|verbose' => \$verbose, - 'f|force' => \$force, - 'W|warning' => \@warning) - or exit 1; + getopt ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir, + 'l|localdir=s' => \$localdir, + 'f|force' => \$force, + 'W|warning' => \@warning); push @ARGV, '-' if $stdin; @@ -180,8 +164,9 @@ END # Set up autoconf. $autoconf .= " --include=$autoconf_dir --include=$localdir"; -$autoconf .= ' --verbose' if $verbose; $autoconf .= ' --debug' if $debug; +$autoconf .= ' --force' if $force; +$autoconf .= ' --verbose' if $verbose; # ----------------------- # # Real work starts here. # @@ -219,7 +204,7 @@ if ($config_h_top) my $in = new IO::File ($config_h_top); while ($_ = $in->getline) { - print $out; + print $out $_; } } @@ -231,7 +216,7 @@ if ($acconfig_h) { last if /\@BOTTOM\@/; next if /\@TOP\@/; - print $out; + print $out $_; } } @@ -248,7 +233,7 @@ if ($acconfig_h) my $dump = 0; while ($_ = $in->getline) { - print $out if $dump; + print $out $_ if $dump; $dump = 1 if /\@BOTTOM\@/; } } @@ -259,7 +244,7 @@ if ($config_h_bot) my $in = new IO::File ($config_h_bot); while ($_ = $in->getline) { - print $out; + print $out $_; } } diff --git a/bin/autom4te.in b/bin/autom4te.in index 3c362de29..34d78622a 100644 --- a/bin/autom4te.in +++ b/bin/autom4te.in @@ -230,7 +230,6 @@ sub load package Autom4te; use Autom4te::General; -use Getopt::Long; use File::Basename; use IO::File; use strict; @@ -352,21 +351,9 @@ my %m4_builtin_alternate_name; @m4_builtin_alternate_name{"m4wrap", "m4_wrap"} = ("m4_wrap", "m4wrap"); - - - -## ---------- ## -## Routines. ## -## ---------- ## - - -# print_usage () -# -------------- -# Display usage (--help). -sub print_usage () -{ - # Quotes are backslahed to help Emacs' font-lock-mode. - print <. EOF - exit 0; -} - -# print_version () -# ---------------- -# Display version (--version). -sub print_version -{ - print < \&print_usage, - "V|version" => \&print_version, - - "s|language=s" => \$language, - "v|verbose" => \$verbose, - "d|debug" => \$debug, - ) - or exit 1; + Getopt::Long::Configure ("pass_through"); + getopt ("s|language=s" => \$language); Getopt::Long::Configure ("defaults"); unshift @ARGV, @{$language{$language}} if $language; @@ -504,8 +479,7 @@ sub parse_args () if $debug; # Process the arguments for real this time. - Getopt::Long::Configure ("bundling"); - GetOptions + getopt ( # Operation modes: "o|output=s" => \$output, @@ -525,8 +499,7 @@ sub parse_args () # by hand. "t|trace=s" => \@trace, "p|preselect=s" => \@preselect, - ) - or exit 1; + ); die "$me: too few arguments Try `$me --help' for more information.\n" diff --git a/bin/autoupdate.in b/bin/autoupdate.in index d0999c66f..e9bfd859f 100644 --- a/bin/autoupdate.in +++ b/bin/autoupdate.in @@ -27,7 +27,6 @@ BEGIN unshift @INC, "$perllibdir"; } -use Getopt::Long; use File::Basename; use Autom4te::General; use strict; @@ -40,17 +39,9 @@ my $localdir = '.'; my $m4 = $ENV{"M4"} || "@M4@"; -## ---------- ## -## Routines. ## -## ---------- ## - - -# print_usage () -# -------------- -# Display usage (--help). -sub print_usage () -{ - print <<"END"; +# $HELP +# ----- +$help = <<"END"; Usage: $0 [OPTION] ... [TEMPLATE-FILE...] Update the TEMPLATE-FILE... if given, or \`configure.ac\' if present, @@ -73,16 +64,10 @@ Environment variables: Report bugs to . END - exit 0; -} - -# print_version () -# ---------------- -# Display version (--version). -sub print_version -{ - print < sub { push @ARGV, "-" } my $update_stdin = grep /^-$/, @ARGV; @ARGV = grep !/^-$/, @ARGV; - Getopt::Long::config ("bundling"); - Getopt::Long::GetOptions ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir, - 'l|localdir=s' => \$localdir, - 'd|debug' => \$debug, - 'h|help' => \&print_usage, - 'V|version' => \&print_version, - 'v|verbose' => \$verbose) - or exit 1; + getopt ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir, + 'l|localdir=s' => \$localdir); push @ARGV, '-' if $update_stdin; diff --git a/lib/Autom4te/General.pm b/lib/Autom4te/General.pm index f0b22cf38..95893dbf2 100644 --- a/lib/Autom4te/General.pm +++ b/lib/Autom4te/General.pm @@ -20,7 +20,6 @@ package Autom4te::General; use 5.005; use Exporter; -use Getopt::Long; use File::Basename; use File::stat; use IO::File; @@ -30,26 +29,32 @@ use strict; use vars qw (@ISA @EXPORT); @ISA = qw (Exporter); -@EXPORT = qw (&find_configure_ac &find_file &mktmpdir &mtime +@EXPORT = qw (&find_configure_ac &find_file &getopt &mktmpdir &mtime &uniq &update_file &verbose &xsystem - $me $verbose $debug $tmp); + $debug $help $me $tmp $verbose $version); # Variable we share with the main package. Be sure to have a single # copy of them: using `my' together with multiple inclusion of this # package would introduce several copies. -use vars qw ($me); -$me = basename ($0); - -use vars qw ($verbose); -$verbose = 0; - use vars qw ($debug); $debug = 0; +use vars qw ($help); +$help = undef; + +use vars qw ($me); +$me = basename ($0); + # Our tmp dir. use vars qw ($tmp); $tmp = undef; +use vars qw ($verbose); +$verbose = 0; + +use vars qw ($version); +$version = undef; + # END # --- @@ -148,6 +153,26 @@ sub find_file ($@) } +# getopt (%OPTIONS) +# ----------------- +sub getopt (%) +{ + my (%option) = @_; + use Getopt::Long; + + %option = (%option, + "h|help" => sub { print $help; exit 0 }, + "V|version" => sub { print $version; exit 0 }, + + "v|verbose" => \$verbose, + "d|debug" => \$debug, + ); + Getopt::Long::Configure ("bundling"); + GetOptions (%option) + or exit 1; +} + + # mktmpdir ($SIGNATURE) # --------------------- # Create a temporary directory which name is based on $SIGNATURE. diff --git a/tests/tools.at b/tests/tools.at index ac1de13e7..dc59e1f05 100644 --- a/tests/tools.at +++ b/tests/tools.at @@ -97,10 +97,14 @@ AT_SETUP([Syntax of the Perl scripts]) # | % perl -c ./autom4te # | ./autom4te syntax OK # Ignore it, it might change between releases. -AT_CHECK([$PERL -c ../bin/autom4te], 0, [], [ignore]) -AT_CHECK([$PERL -c ../bin/autoheader], 0, [], [ignore]) -AT_CHECK([$PERL -c ../bin/autoscan], 0, [], [ignore]) -AT_CHECK([$PERL -c ../bin/autoupdate], 0, [], [ignore]) +AT_CHECK([autom4te_perllibdir=$top_srcdir/lib $PERL -c ../bin/autom4te], + 0, [], [ignore]) +AT_CHECK([autom4te_perllibdir=$top_srcdir/lib $PERL -c ../bin/autoheader], + 0, [], [ignore]) +AT_CHECK([autom4te_perllibdir=$top_srcdir/lib $PERL -c ../bin/autoscan], + 0, [], [ignore]) +AT_CHECK([autom4te_perllibdir=$top_srcdir/lib $PERL -c ../bin/autoupdate], + 0, [], [ignore]) AT_CLEANUP @@ -386,27 +390,28 @@ AT_DATA([acconfig.h], # 1. Check that `acconfig.h' is still honored. AT_DATA([configure.ac], [[AC_INIT -AC_CONFIG_HEADERS(config.h) +AC_CONFIG_HEADERS(config.h:config.hin) AC_DEFINE(this, "whatever you want.") ]]) -AT_CHECK([autoheader -