* 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 <akim@epita.fr>
+
+ * 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 <akim@epita.fr>
* bin/autoheader.in: Handle the acconfig.h etc. junk files.
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
Report bugs to <bug-autoconf\@gnu.org>.
END
- exit 0;
-}
-# print_version ()
-# ----------------
-# Display version (--version).
-sub print_version
-{
- print <<END;
+# $VERSION
+# --------
+$version = <<"END";
autoheader (@PACKAGE_NAME@) @VERSION@
Written by Roland McGrath.
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
- exit 0;
-}
+
+
+## ---------- ##
+## Routines. ##
+## ---------- ##
# parse_args ()
# If fixed some day, use this: '' => 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;
# 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. #
my $in = new IO::File ($config_h_top);
while ($_ = $in->getline)
{
- print $out;
+ print $out $_;
}
}
{
last if /\@BOTTOM\@/;
next if /\@TOP\@/;
- print $out;
+ print $out $_;
}
}
my $dump = 0;
while ($_ = $in->getline)
{
- print $out if $dump;
+ print $out $_ if $dump;
$dump = 1 if /\@BOTTOM\@/;
}
}
my $in = new IO::File ($config_h_bot);
while ($_ = $in->getline)
{
- print $out;
+ print $out $_;
}
}
package Autom4te;
use Autom4te::General;
-use Getopt::Long;
use File::Basename;
use IO::File;
use strict;
@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;
+# $HELP
+# -----
+$help = << "EOF";
Usage: $0 [OPTION] ... [FILES]
Run GNU M4 on the FILES, avoiding useless runs. If tracing, the output
Report bugs to <bug-autoconf\@gnu.org>.
EOF
- exit 0;
-}
-
-# print_version ()
-# ----------------
-# Display version (--version).
-sub print_version
-{
- print <<EOF;
+# $VERSION
+# --------
+$version = <<"EOF";
autom4te (@PACKAGE_NAME@) @VERSION@
Written by Akim Demaille.
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
EOF
- exit 0;
-}
+
+## ---------- ##
+## Routines. ##
+## ---------- ##
# load_configuration ()
# We want to look for the early options, which should not be found
# in the configuration file. Prepend to the user arguments.
- Getopt::Long::Configure ("bundling", "pass_through");
- GetOptions (
- "h|help" => \&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;
if $debug;
# Process the arguments for real this time.
- Getopt::Long::Configure ("bundling");
- GetOptions
+ getopt
(
# Operation modes:
"o|output=s" => \$output,
# 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"
unshift @INC, "$perllibdir";
}
-use Getopt::Long;
use File::Basename;
use Autom4te::General;
use strict;
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,
Report bugs to <bug-autoconf\@gnu.org>.
END
- exit 0;
-}
-
-# print_version ()
-# ----------------
-# Display version (--version).
-sub print_version
-{
- print <<END;
+# $VERSION
+# --------
+$version = <<"END";
autoupdate (@PACKAGE_NAME@) @VERSION@
Written by David J. MacKenzie and Akim Demaille.
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
- exit 0;
-}
+
+
+## ---------- ##
+## Routines. ##
+## ---------- ##
# parse_args ()
# If fixed some day, use this: '' => 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;
use 5.005;
use Exporter;
-use Getopt::Long;
use File::Basename;
use File::stat;
use IO::File;
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
# ---
}
+# 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.
# | % 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
# 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 -<configure.ac], 0,
-[[/* config.h.in. Generated automatically from Standard input by autoheader. */
+AT_CHECK_AUTOHEADER([], [], [], [ignore])
+AT_CHECK([cat config.hin], 0,
+[[/* config.hin. Generated from configure.ac by autoheader. */
/* Define this to whatever you want. */
#undef this
-]], ignore)
+]])
# 2. Check that missing templates are a fatal error.
AT_DATA([configure.ac],
[[AC_INIT
-AC_CONFIG_HEADERS(config.h)
+AC_CONFIG_HEADERS(config.h:config.hin)
AC_DEFINE(that, "whatever you want.")
]])
-AT_CHECK([autoheader -<configure.ac], 1, [],
-[autoheader: No template for symbol `that'
-])
+# The test suite goes too fast for the cache time stamps...
+# Pass --force.
+AT_CHECK_AUTOHEADER([--force], [1], [], [ignore])
# 3. Check TOP and BOTTOM.
AT_DATA([configure.ac],
[[AC_INIT
-AC_CONFIG_HEADERS(config.h)
+AC_CONFIG_HEADERS(config.h:config.hin)
AH_TOP([Top1 from configure.ac.])
AH_TOP([Top2 from configure.ac.])
AH_VERBATIM([Middle], [Middle from configure.ac.])
# together.
# Ignore STDERR which is the longuish complaint against autoheader junk
# files.
-AT_CHECK([autoheader -<configure.ac], 0,
-[[/* config.h.in. Generated automatically from Standard input by autoheader. */
+AT_CHECK_AUTOHEADER([--force], [], [], [ignore])
+AT_CHECK([cat config.hin], 0,
+[[/* config.hin. Generated from configure.ac by autoheader. */
/* Top from acconfig.h. */
-
/* Middle from acconfig.h. */
Top1 from configure.ac.
Bottom2 from configure.ac.
/* Bottom from acconfig.h. */
-]], [ignore])
-
+]])
AT_CLEANUP