mirror of
git://git.sv.gnu.org/autoconf
synced 2025-03-19 14:40:24 +08:00
* lib/Autom4te/General.pm (&find_file, &update_file): New.
* bin/autoupdate.in, bin/autoheader.in: Adjust. Drop AC_MACRODIR dead for real. * tests/atspecific.m4 (AT_CHECK_AUTOHEADER): Now autoheader says `autoheader: `config.hin' is created'. * tests/tools.at (Syntax of the Perl scripts): Check autoheader.
This commit is contained in:
parent
d7d052d158
commit
aa8dfa178d
@ -1,3 +1,12 @@
|
||||
2001-08-31 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* lib/Autom4te/General.pm (&find_file, &update_file): New.
|
||||
* bin/autoupdate.in, bin/autoheader.in: Adjust.
|
||||
Drop AC_MACRODIR dead for real.
|
||||
* tests/atspecific.m4 (AT_CHECK_AUTOHEADER): Now autoheader says
|
||||
`autoheader: `config.hin' is created'.
|
||||
* tests/tools.at (Syntax of the Perl scripts): Check autoheader.
|
||||
|
||||
2001-08-31 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* bin/autoheader.in: Rewrite in Perl.
|
||||
|
@ -29,17 +29,12 @@ eval 'exec @PERL@ -S $0 ${1+"$@"}'
|
||||
|
||||
BEGIN
|
||||
{
|
||||
my $datadir = ($ENV{'autom4te_perllibdir'}
|
||||
|| $ENV{'AC_MACRODIR'}
|
||||
|| '@datadir@');
|
||||
unshift @INC, "$datadir";
|
||||
my $perllibdir = $ENV{'autom4te_perllibdir'} || '@datadir@';
|
||||
unshift @INC, "$perllibdir";
|
||||
}
|
||||
|
||||
use Getopt::Long;
|
||||
use File::Basename;
|
||||
use File::Compare;
|
||||
use File::Copy;
|
||||
use File::Spec;
|
||||
use IO::File;
|
||||
use Autom4te::General;
|
||||
use strict;
|
||||
@ -66,46 +61,6 @@ my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
|
||||
## ---------- ##
|
||||
|
||||
|
||||
# $FILENAME
|
||||
# find_file ($FILENAME)
|
||||
# ---------------------
|
||||
# We match exactly the behavior of GNU m4: first look in the current
|
||||
# directory (which includes the case of absolute file names), and, if
|
||||
# the file is not absolute, just fail. Otherwise, look in the path.
|
||||
#
|
||||
# If the file is flagged as optional (ends with `?'), then return undef
|
||||
# if absent.
|
||||
sub find_file ($)
|
||||
{
|
||||
my ($filename) = @_;
|
||||
my $optional = 0;
|
||||
|
||||
$optional = 1
|
||||
if $filename =~ s/\?$//;
|
||||
|
||||
return File::Spec->canonpath ($filename)
|
||||
if -e $filename;
|
||||
|
||||
if (File::Spec->file_name_is_absolute ($filename))
|
||||
{
|
||||
die "$me: no such file or directory: $filename\n"
|
||||
unless $optional;
|
||||
return undef;
|
||||
}
|
||||
|
||||
foreach my $path (@include)
|
||||
{
|
||||
return File::Spec->canonpath (File::Spec->catfile ($path, $filename))
|
||||
if -e File::Spec->catfile ($path, $filename)
|
||||
}
|
||||
|
||||
die "$me: no such file or directory: $filename\n"
|
||||
unless $optional;
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
# print_usage ()
|
||||
# --------------
|
||||
# Display usage (--help).
|
||||
@ -202,9 +157,9 @@ mktmpdir ('ah');
|
||||
parse_args;
|
||||
|
||||
# Preach.
|
||||
my $config_h_top = find_file ("config.h.top?");
|
||||
my $config_h_bot = find_file ("config.h.bot?");
|
||||
my $acconfig_h = find_file ("acconfig.h?");
|
||||
my $config_h_top = find_file ("config.h.top?", @include);
|
||||
my $config_h_bot = find_file ("config.h.bot?", @include);
|
||||
my $acconfig_h = find_file ("acconfig.h?", @include);
|
||||
if ($config_h_top || $config_h_bot || $acconfig_h)
|
||||
{
|
||||
my $msg = << "END";
|
||||
@ -297,31 +252,6 @@ $out->close;
|
||||
# done
|
||||
# fi
|
||||
|
||||
if (compare ("$tmp/config.hin", "$config_h_in") == 0)
|
||||
{
|
||||
# File didn't change, so don't update its mod time.
|
||||
print STDERR "$me: `$config_h_in' is unchanged\n"
|
||||
}
|
||||
else
|
||||
{
|
||||
# Back up and install the new one.
|
||||
if (-f $config_h_in)
|
||||
{
|
||||
move ("$config_h_in", "$config_h_in$SIMPLE_BACKUP_SUFFIX")
|
||||
or die "$me: cannot not backup $config_h_in: $!\n";
|
||||
}
|
||||
move ("$tmp/config.hin", "$config_h_in")
|
||||
or die "$me: cannot not update $config_h_in: $!\n";
|
||||
# print STDERR "$me: `$config_h_in' is updated\n";
|
||||
}
|
||||
|
||||
update_file ("$tmp/config.hin", "$config_h_in");
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(exit $status); exit $status
|
||||
|
@ -44,7 +44,6 @@ use Autom4te::Struct;
|
||||
use Carp;
|
||||
use Getopt::Long;
|
||||
use IO::File;
|
||||
use File::Spec;
|
||||
use strict;
|
||||
|
||||
# List of requests.
|
||||
@ -361,46 +360,6 @@ my %m4_builtin_alternate_name;
|
||||
## ---------- ##
|
||||
|
||||
|
||||
# $FILENAME
|
||||
# find_file ($FILENAME)
|
||||
# ---------------------
|
||||
# We match exactly the behavior of GNU m4: first look in the current
|
||||
# directory (which includes the case of absolute file names), and, if
|
||||
# the file is not absolute, just fail. Otherwise, look in the path.
|
||||
#
|
||||
# If the file is flagged as optional (ends with `?'), then return undef
|
||||
# if absent.
|
||||
sub find_file ($)
|
||||
{
|
||||
my ($filename) = @_;
|
||||
my $optional = 0;
|
||||
|
||||
$optional = 1
|
||||
if $filename =~ s/\?$//;
|
||||
|
||||
return File::Spec->canonpath ($filename)
|
||||
if -e $filename;
|
||||
|
||||
if (File::Spec->file_name_is_absolute ($filename))
|
||||
{
|
||||
die "$me: no such file or directory: $filename\n"
|
||||
unless $optional;
|
||||
return undef;
|
||||
}
|
||||
|
||||
foreach my $path (@include)
|
||||
{
|
||||
return File::Spec->canonpath (File::Spec->catfile ($path, $filename))
|
||||
if -e File::Spec->catfile ($path, $filename)
|
||||
}
|
||||
|
||||
die "$me: no such file or directory: $filename\n"
|
||||
unless $optional;
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
# print_usage ()
|
||||
# --------------
|
||||
# Display usage (--help).
|
||||
@ -605,7 +564,7 @@ Try `$me --help' for more information.\n"
|
||||
# We don't want to depend upon m4's --include to find the top level
|
||||
# files. Try to get a canonical name, as it's part of the key for
|
||||
# caching. And some files are optional.
|
||||
@ARGV = grep { defined $_ } map { find_file ($_) } @ARGV;
|
||||
@ARGV = grep { defined $_ } map { find_file ($_, @include) } @ARGV;
|
||||
}
|
||||
|
||||
|
||||
@ -1064,7 +1023,7 @@ sub up_to_date_p ($)
|
||||
('include' => '$1',
|
||||
'm4_include' => '$1'));
|
||||
my $deps = new IO::File ("$tmp/dependencies");
|
||||
push @dep, map { chomp; find_file ($_) } $deps->getlines;
|
||||
push @dep, map { chomp; find_file ($_, @include) } $deps->getlines;
|
||||
|
||||
# If $FILE is younger than one of its dependencies, it is outdated.
|
||||
verbose "$file is the youngest cache file";
|
||||
|
@ -23,15 +23,12 @@
|
||||
|
||||
BEGIN
|
||||
{
|
||||
my $prefix = "@prefix@";
|
||||
my $perllibdir = $ENV{'autom4te_perllibdir'} || "@datadir@";
|
||||
unshift @INC, "$perllibdir";
|
||||
}
|
||||
|
||||
use Getopt::Long;
|
||||
use File::Basename;
|
||||
use File::Compare;
|
||||
use File::Copy;
|
||||
use Autom4te::General;
|
||||
use strict;
|
||||
|
||||
@ -41,7 +38,6 @@ my $autoconf = $ENV{'AUTOCONF'} || '@autoconf-name@';
|
||||
my $localdir = '.';
|
||||
# m4.
|
||||
my $m4 = $ENV{"M4"} || "@M4@";
|
||||
my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
|
||||
|
||||
|
||||
## ---------- ##
|
||||
@ -372,30 +368,10 @@ EOF
|
||||
or die "$me: cannot close $tmp/input.m4: $!\n";
|
||||
|
||||
# Now ask m4 to perform the update.
|
||||
if ("$file" eq "$tmp/stdin")
|
||||
{
|
||||
xsystem ("$m4 --include=$autoconf_dir $tmp/input.m4");
|
||||
}
|
||||
else
|
||||
{
|
||||
xsystem ("$m4 --include=$autoconf_dir $tmp/input.m4 >$tmp/updated");
|
||||
if (compare ("$tmp/updated", "$file") == 0)
|
||||
{
|
||||
# File didn't change, so don't update its mod time.
|
||||
print STDERR "$me: `$file' is unchanged\n"
|
||||
}
|
||||
else
|
||||
{
|
||||
# Back up and install the new one.
|
||||
move ("$file", "$file$SIMPLE_BACKUP_SUFFIX")
|
||||
or die "$me: cannot not backup $file: $!\n";
|
||||
move ("$tmp/updated", "$file")
|
||||
or die "$me: cannot not update $file: $!\n";
|
||||
print STDERR "$me: `$file' is updated\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xsystem ("$m4 --include=$autoconf_dir $tmp/input.m4 >$tmp/updated");
|
||||
update_file ("$tmp/updated",
|
||||
"$file" eq "$tmp/stdin" ? '-' : "$file");
|
||||
}
|
||||
exit 0;
|
||||
|
||||
|
||||
|
@ -28,8 +28,8 @@ use strict;
|
||||
use vars qw (@ISA @EXPORT);
|
||||
|
||||
@ISA = qw (Exporter);
|
||||
@EXPORT = qw (&find_configure_ac &mktmpdir &mtime
|
||||
&uniq &verbose &xsystem
|
||||
@EXPORT = qw (&find_configure_ac &find_file &mktmpdir &mtime
|
||||
&uniq &update_file &verbose &xsystem
|
||||
$me $verbose $debug $tmp);
|
||||
|
||||
# Variable we share with the main package. Be sure to have a single
|
||||
@ -104,6 +104,48 @@ sub find_configure_ac ()
|
||||
}
|
||||
|
||||
|
||||
# $FILENAME
|
||||
# find_file ($FILENAME, @INCLUDE)
|
||||
# -------------------------------
|
||||
# We match exactly the behavior of GNU m4: first look in the current
|
||||
# directory (which includes the case of absolute file names), and, if
|
||||
# the file is not absolute, just fail. Otherwise, look in the path.
|
||||
#
|
||||
# If the file is flagged as optional (ends with `?'), then return undef
|
||||
# if absent.
|
||||
sub find_file ($@)
|
||||
{
|
||||
use File::Spec;
|
||||
|
||||
my ($filename, @include) = @_;
|
||||
my $optional = 0;
|
||||
|
||||
$optional = 1
|
||||
if $filename =~ s/\?$//;
|
||||
|
||||
return File::Spec->canonpath ($filename)
|
||||
if -e $filename;
|
||||
|
||||
if (File::Spec->file_name_is_absolute ($filename))
|
||||
{
|
||||
die "$me: no such file or directory: $filename\n"
|
||||
unless $optional;
|
||||
return undef;
|
||||
}
|
||||
|
||||
foreach my $path (@include)
|
||||
{
|
||||
return File::Spec->canonpath (File::Spec->catfile ($path, $filename))
|
||||
if -e File::Spec->catfile ($path, $filename)
|
||||
}
|
||||
|
||||
die "$me: no such file or directory: $filename\n"
|
||||
unless $optional;
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
# mktmpdir ($SIGNATURE)
|
||||
# ---------------------
|
||||
# Create a temporary directory which name is based on $SIGNATURE.
|
||||
@ -168,6 +210,56 @@ sub uniq (@)
|
||||
}
|
||||
|
||||
|
||||
# &update_file ($FROM, $TO)
|
||||
# -------------------------
|
||||
# Rename $FROM as $TO, preserving $TO timestamp if it has not changed.
|
||||
# Recognize `$TO = -' standing for stdin.
|
||||
sub update_file ($$)
|
||||
{
|
||||
my ($from, $to) = @_;
|
||||
my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
|
||||
use File::Compare;
|
||||
use File::Copy;
|
||||
|
||||
if ($to eq '-')
|
||||
{
|
||||
my $in = new IO::File ("$from");
|
||||
my $out = new IO::File (">-");
|
||||
while ($_ = $in->getline)
|
||||
{
|
||||
print $out $_;
|
||||
}
|
||||
$in->close;
|
||||
remove ($from)
|
||||
or die "$me: cannot not remove $from: $!\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (-f "$to" && compare ("$from", "$to") == 0)
|
||||
{
|
||||
# File didn't change, so don't update its mod time.
|
||||
print STDERR "$me: `$to' is unchanged\n";
|
||||
return
|
||||
}
|
||||
|
||||
if (-f "$to")
|
||||
{
|
||||
# Back up and install the new one.
|
||||
move ("$to", "$to$SIMPLE_BACKUP_SUFFIX")
|
||||
or die "$me: cannot not backup $to: $!\n";
|
||||
move ("$from", "$to")
|
||||
or die "$me: cannot not rename $from as $to: $!\n";
|
||||
print STDERR "$me: `$to' is updated\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
move ("$from", "$to")
|
||||
or die "$me: cannot not rename $from as $to: $!\n";
|
||||
print STDERR "$me: `$to' is created\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# verbose
|
||||
# -------
|
||||
sub verbose (@)
|
||||
|
@ -61,19 +61,23 @@ AC_STATE_SAVE(after)
|
||||
]])])
|
||||
|
||||
|
||||
# AT_CHECK_AUTOCONF(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
|
||||
# -----------------------------------------------------------
|
||||
# AT_CHECK_AUTOCONF(ARGS, [EXIT-STATUS = 0], STDOUT, STDERR)
|
||||
# ----------------------------------------------------------
|
||||
m4_define([AT_CHECK_AUTOCONF],
|
||||
[AT_CLEANUP_FILES(configure.in configure autom4te.cache)dnl
|
||||
AT_CHECK([autoconf --include=$srcdir $1],
|
||||
m4_default([$2], [0]), [$3], [$4])])
|
||||
[$2], [$3], [$4])])
|
||||
|
||||
|
||||
# AT_CHECK_AUTOHEADER
|
||||
# -------------------
|
||||
# AT_CHECK_AUTOHEADER(ARGS, [EXIT-STATUS = 0],
|
||||
# STDOUT, [STDERR = `autoheader: `config.hin' is created'])
|
||||
# -----------------------------------------------------------------------------
|
||||
m4_define([AT_CHECK_AUTOHEADER],
|
||||
[AT_CLEANUP_FILES(config.hin)dnl
|
||||
AT_CHECK([autoheader --localdir=$srcdir], 0, [], [])])
|
||||
AT_CHECK([autoheader --localdir=$srcdir $1], [$2],
|
||||
[$3],
|
||||
m4_default([$4], [[autoheader: `config.hin' is created
|
||||
]]))])
|
||||
|
||||
|
||||
# AT_CHECK_CONFIGURE(END-COMMAND,
|
||||
|
@ -98,6 +98,7 @@ AT_SETUP([Syntax of the Perl scripts])
|
||||
# | ./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])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user