[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
64-fyi-more-general-pm.patch
From: |
Akim Demaille |
Subject: |
64-fyi-more-general-pm.patch |
Date: |
Fri, 31 Aug 2001 15:30:33 +0200 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* 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.
Index: bin/autoheader.in
--- bin/autoheader.in Fri, 31 Aug 2001 08:52:55 +0200 akim
+++ bin/autoheader.in Fri, 31 Aug 2001 09:13:08 +0200 akim
@@ -29,17 +29,12 @@
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 @@
## ---------- ##
-# $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 @@ sub parse_args ()
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 @@ sub parse_args ()
# 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
Index: bin/autom4te.in
--- bin/autom4te.in Fri, 31 Aug 2001 00:55:01 +0200 akim
+++ bin/autom4te.in Fri, 31 Aug 2001 08:57:16 +0200 akim
@@ -44,7 +44,6 @@
use Carp;
use Getopt::Long;
use IO::File;
-use File::Spec;
use strict;
# List of requests.
@@ -361,46 +360,6 @@ sub load
## ---------- ##
-# $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 @@ sub parse_args ()
# 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";
Index: bin/autoupdate.in
--- bin/autoupdate.in Fri, 31 Aug 2001 00:55:01 +0200 akim
+++ bin/autoupdate.in Fri, 31 Aug 2001 09:39:41 +0200 akim
@@ -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 $localdir = '.';
# m4.
my $m4 = $ENV{"M4"} || "@M4@";
-my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
## ---------- ##
@@ -372,30 +368,10 @@ sub parse_args ()
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;
Index: lib/Autom4te/General.pm
--- lib/Autom4te/General.pm Thu, 30 Aug 2001 20:46:39 +0200 akim
+++ lib/Autom4te/General.pm Fri, 31 Aug 2001 09:13:59 +0200 akim
@@ -28,8 +28,8 @@
use vars qw (@ISA @EXPORT);
@ISA = qw (Exporter);
address@hidden = qw (&find_configure_ac &mktmpdir &mtime
- &uniq &verbose &xsystem
address@hidden = 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.
@@ -165,6 +207,56 @@ sub uniq (@)
}
}
return wantarray ? @res : "@res";
+}
+
+
+# &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";
+ }
}
Index: tests/atspecific.m4
--- tests/atspecific.m4 Fri, 31 Aug 2001 00:55:01 +0200 akim
+++ tests/atspecific.m4 Fri, 31 Aug 2001 09:36:26 +0200 akim
@@ -61,19 +61,23 @@ m4_define([AT_CONFIGURE_AC],
]])])
-# 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,
Index: tests/tools.at
--- tests/tools.at Thu, 30 Aug 2001 20:46:39 +0200 akim
+++ tests/tools.at Fri, 31 Aug 2001 09:33:58 +0200 akim
@@ -98,6 +98,7 @@
# | ./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])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 64-fyi-more-general-pm.patch,
Akim Demaille <=