mirror of
git://git.sv.gnu.org/autoconf
synced 2024-12-03 02:00:36 +08:00
* lib/Autom4te/General.pm: Use carp' and
croak', not `warn' and
`die'. (&END): New. * bin/autoconf.in, bin/autom4te.in, bin/autoupdate.in: Remove your `END', as `Autom4te::General::END' will be triggered. * bin/autoupdate.in, bin/autoscan.in: Improve error messages accuracy. * bin/autoupdate.in (File::Compare, File::Copy): Use them instead of system to run `mv', `rm', and `cmp'.
This commit is contained in:
parent
f0cd6d6a75
commit
ca7d52c867
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2001-08-01 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* lib/Autom4te/General.pm: Use `carp' and `croak', not `warn' and
|
||||
`die'.
|
||||
(&END): New.
|
||||
* bin/autoconf.in, bin/autom4te.in, bin/autoupdate.in: Remove your
|
||||
`END', as `Autom4te::General::END' will be triggered.
|
||||
* bin/autoupdate.in, bin/autoscan.in: Improve error messages accuracy.
|
||||
* bin/autoupdate.in (File::Compare, File::Copy): Use them instead of
|
||||
system to run `mv', `rm', and `cmp'.
|
||||
|
||||
2001-08-01 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* lib/Autom4te/General.pm (&unique): New.
|
||||
|
@ -280,39 +280,6 @@ map { s/:.*//;s/\W// } @m4_builtins;
|
||||
## ---------- ##
|
||||
|
||||
|
||||
# END
|
||||
# ---
|
||||
# Exit nonzero whenever closing STDOUT fails.
|
||||
sub END
|
||||
{
|
||||
use POSIX qw (_exit);
|
||||
|
||||
my ($q) = ($?);
|
||||
|
||||
# FIXME: Heelp! Can't find a means to properly catch system's
|
||||
# exit status (without hair I mean).
|
||||
# my $status = $? >> 8;
|
||||
|
||||
if (!$debug && defined $tmp && -d $tmp)
|
||||
{
|
||||
if (<$tmp/*>)
|
||||
{
|
||||
unlink <$tmp/*>
|
||||
or warn ("$me: cannot empty $tmp: $!\n"), _exit (1);
|
||||
}
|
||||
rmdir $tmp
|
||||
or warn ("$me: cannot remove $tmp: $!\n"), _exit (1);
|
||||
}
|
||||
|
||||
# This is required if the code might send any output to stdout
|
||||
# E.g., even --version or --help. So it's best to do it unconditionally.
|
||||
close STDOUT
|
||||
or (warn "$me: closing standard output: $!\n"), _exit (1);
|
||||
|
||||
($!, $?) = (0, $q);
|
||||
}
|
||||
|
||||
|
||||
# $FILENAME
|
||||
# find_file ($FILENAME)
|
||||
# ---------------------
|
||||
|
@ -77,16 +77,6 @@ my $log = new IO::File ">$me.log"
|
||||
my $autoconf = find_peer ('autoconf', "@bindir@", 'autoconf-name');
|
||||
my $datadir = $ENV{"AC_MACRODIR"} || "@datadir@";
|
||||
|
||||
# Exit nonzero whenever closing STDOUT fails.
|
||||
sub END
|
||||
{
|
||||
use POSIX qw (_exit);
|
||||
# This is required if the code might send any output to stdout
|
||||
# E.g., even --version or --help. So it's best to do it unconditionally.
|
||||
close STDOUT
|
||||
or (warn "$me: closing standard output: $!\n"), _exit (1);
|
||||
}
|
||||
|
||||
|
||||
## ------------------------ ##
|
||||
## Command line interface. ##
|
||||
@ -555,7 +545,7 @@ sub check_configure_ac ($)
|
||||
verbose "running: $autoconf -A $datadir $trace_option $configure_ac";
|
||||
my $traces =
|
||||
new IO::File "$autoconf -A $datadir $trace_option $configure_ac|"
|
||||
or die "$me: cannot create read traces: $!\n";
|
||||
or die "$me: cannot open traces reading pipe: $!\n";
|
||||
|
||||
while ($_ = $traces->getline)
|
||||
{
|
||||
@ -583,7 +573,7 @@ sub check_configure_ac ($)
|
||||
}
|
||||
|
||||
$traces->close
|
||||
or die "$me: cannot close: $!\n";
|
||||
or die "$me: cannot close traces reading pipe: $!\n";
|
||||
|
||||
# Report the missing macros.
|
||||
foreach my $macro (sort keys %needed_macros)
|
||||
|
@ -33,6 +33,8 @@ BEGIN
|
||||
|
||||
use Getopt::Long;
|
||||
use File::Basename;
|
||||
use File::Compare;
|
||||
use File::Copy;
|
||||
use Autom4te::General;
|
||||
use strict;
|
||||
|
||||
@ -50,36 +52,6 @@ my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
|
||||
## ---------- ##
|
||||
|
||||
|
||||
# END
|
||||
# ---
|
||||
# Exit nonzero whenever closing STDOUT fails.
|
||||
sub END
|
||||
{
|
||||
use POSIX qw (_exit);
|
||||
|
||||
my ($q) = ($?);
|
||||
|
||||
# FIXME: Heelp! Can't find a means to properly catch system's
|
||||
# exit status (without hair I mean).
|
||||
# my $status = $? >> 8;
|
||||
|
||||
if (!$debug && -d $tmp)
|
||||
{
|
||||
unlink <$tmp/*>
|
||||
or warn ("$me: cannot empty $tmp: $!\n"), _exit (1);
|
||||
rmdir $tmp
|
||||
or warn ("$me: cannot remove $tmp: $!\n"), _exit (1);
|
||||
}
|
||||
|
||||
# This is required if the code might send any output to stdout
|
||||
# E.g., even --version or --help. So it's best to do it unconditionally.
|
||||
close STDOUT
|
||||
or (warn "$me: closing standard output: $!\n"), _exit (1);
|
||||
|
||||
($!, $?) = (0, $q);
|
||||
}
|
||||
|
||||
|
||||
# print_usage ()
|
||||
# --------------
|
||||
# Display usage (--help).
|
||||
@ -191,18 +163,18 @@ foreach (@m4_builtins)
|
||||
print M4SAVE_M4 "define([_au_$_], defn([$_]))\n";
|
||||
}
|
||||
close M4SAVE_M4
|
||||
or die "$me: cannot close: $!\n";
|
||||
or die "$me: cannot close $tmp/m4save.m4: $!\n";
|
||||
close UNM4_M4
|
||||
or die "$me: cannot close: $!\n";
|
||||
or die "$me: cannot close $tmp/unm4.m4: $!\n";
|
||||
close M4_M4
|
||||
or die "$me: cannot close: $!\n";
|
||||
or die "$me: cannot close $tmp/m4.m4: $!\n";
|
||||
|
||||
|
||||
# @AU_MACROS & AC_MACROS -- AU and AC macros and yet another useful comment.
|
||||
open MACROS, ("$autoconf "
|
||||
. "--trace AU_DEFUN:'AU:\$f:\$1' --trace define:'AC:\$f:\$1' "
|
||||
. "-i /dev/null |")
|
||||
or die "$me: cannot open: $!\n";
|
||||
or die "$me: cannot open definitions reading pipe: $!\n";
|
||||
my (%ac_macros, %au_macros);
|
||||
while (<MACROS>)
|
||||
{
|
||||
@ -219,7 +191,8 @@ while (<MACROS>)
|
||||
}
|
||||
}
|
||||
close MACROS
|
||||
or die "$me: cannot close: $!\n";
|
||||
or die ($! ? "$me: cannot close definitions reading pipe: $!\n"
|
||||
: "$me: definitions reading pipe failed with exit status: $?\n");
|
||||
# Don't keep AU macros in @AC_MACROS.
|
||||
delete $ac_macros{$_}
|
||||
foreach (keys %au_macros);
|
||||
@ -253,9 +226,9 @@ foreach (sort keys %ac_macros)
|
||||
print DISABLE_M4 "_au_undefine([$_])\n";
|
||||
}
|
||||
close DISABLE_M4
|
||||
or die "$me: cannot close: $!\n";
|
||||
or die "$me: cannot close $tmp/disable.m4: $!\n";
|
||||
close AC_M4
|
||||
or die "$me: cannot close: $!\n";
|
||||
or die "$me: cannot close $tmp/ac.m4: $!\n";
|
||||
|
||||
|
||||
|
||||
@ -284,7 +257,7 @@ foreach my $file (@ARGV)
|
||||
divert(-1) -*- Autoconf -*-
|
||||
changequote([, ])
|
||||
|
||||
# Move all the builtins into the \`_au_' pseudo namespace
|
||||
# Move all the builtins into the `_au_' pseudo namespace
|
||||
include([$tmp/m4save.m4])
|
||||
|
||||
# _au_defun(NAME, BODY)
|
||||
@ -309,7 +282,7 @@ foreach my $file (@ARGV)
|
||||
# above). But since AU macros might use AU macros, which should
|
||||
# enable/disable only for the outter AU macros.
|
||||
#
|
||||
# \`_au_enabled' is used to this end, condionning whether we really
|
||||
# `_au_enabled' is used to this end, condionning whether we really
|
||||
# enable/disable.
|
||||
|
||||
|
||||
@ -385,43 +358,34 @@ EOF
|
||||
print INPUT_M4;
|
||||
}
|
||||
close FILE
|
||||
or die "$me: cannot close: $!\n";
|
||||
or die "$me: cannot close $file: $!\n";
|
||||
close INPUT_M4
|
||||
or die "$me: cannot close: $!\n";
|
||||
or die "$me: cannot close $tmp/input.m4: $!\n";
|
||||
|
||||
# Now ask m4 to perform the update.
|
||||
print STDERR "$me: running $m4 $tmp/input.m4\n"
|
||||
if $verbose;
|
||||
if (system ("$m4 $tmp/input.m4 >$tmp/updated"))
|
||||
{
|
||||
# Exit status of system() is in the upper byte.
|
||||
$! >>= 8;
|
||||
die "$me: cannot update \`$filename'\n";
|
||||
};
|
||||
|
||||
if ("$file" eq "$tmp/stdin")
|
||||
{
|
||||
system ("cat $tmp/updated");
|
||||
}
|
||||
elsif (! system ("cmp -s $tmp/updated $file"))
|
||||
{
|
||||
# File didn't change, so don't update its mod time.
|
||||
print STDERR "$me: \`$file' is unchanged\n"
|
||||
xsystem ("$m4 $tmp/input.m4");
|
||||
}
|
||||
else
|
||||
{
|
||||
# Back up and install the new one.
|
||||
if (system ("mv $file $file${SIMPLE_BACKUP_SUFFIX} && "
|
||||
. "mv $tmp/updated $file") == 0)
|
||||
xsystem ("$m4 $tmp/input.m4 >$tmp/updated");
|
||||
if (compare ("$tmp/updated", "$file") == 0)
|
||||
{
|
||||
print STDERR "$me: \`$file' is updated\n";
|
||||
# File didn't change, so don't update its mod time.
|
||||
print STDERR "$me: `$file' is unchanged\n"
|
||||
}
|
||||
else
|
||||
{
|
||||
die "$me: cannot update \`$file'\n";
|
||||
# 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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
|
@ -41,6 +41,43 @@ $verbose = 0;
|
||||
use vars qw ($debug);
|
||||
$debug = 0;
|
||||
|
||||
# Our tmp dir.
|
||||
use vars qw ($tmp);
|
||||
$tmp = undef;
|
||||
|
||||
|
||||
# END
|
||||
# ---
|
||||
# Exit nonzero whenever closing STDOUT fails.
|
||||
# Ideally we should `exit ($? >> 8)', unfortunately, for some reason
|
||||
# I don't understand, whenever we `exit (1)' somewhere in the code,
|
||||
# we arrive here with `$? = 29'. I suspect some low level END routine
|
||||
# might be responsible. In this case, be sure to exit 1, not 29.
|
||||
sub END
|
||||
{
|
||||
my $exit_status = $? ? 1 : 0;
|
||||
|
||||
use POSIX qw (_exit);
|
||||
|
||||
if (!$debug && defined $tmp && -d $tmp)
|
||||
{
|
||||
if (<$tmp/*>)
|
||||
{
|
||||
unlink <$tmp/*>
|
||||
or carp ("$me: cannot empty $tmp: $!\n"), _exit (1);
|
||||
}
|
||||
rmdir $tmp
|
||||
or carp ("$me: cannot remove $tmp: $!\n"), _exit (1);
|
||||
}
|
||||
|
||||
# This is required if the code might send any output to stdout
|
||||
# E.g., even --version or --help. So it's best to do it unconditionally.
|
||||
close STDOUT
|
||||
or (carp "$me: closing standard output: $!\n"), _exit (1);
|
||||
|
||||
_exit ($exit_status);
|
||||
}
|
||||
|
||||
|
||||
# $CONFIGURE_AC
|
||||
# &find_configure_ac ()
|
||||
@ -51,8 +88,8 @@ sub find_configure_ac ()
|
||||
{
|
||||
if (-f 'configure.in')
|
||||
{
|
||||
warn "warning: `configure.ac' and `configure.in' both present.\n";
|
||||
warn "warning: proceeding with `configure.ac'.\n";
|
||||
carp "warning: `configure.ac' and `configure.in' both present.\n";
|
||||
carp "warning: proceeding with `configure.ac'.\n";
|
||||
}
|
||||
return 'configure.ac';
|
||||
}
|
||||
@ -102,10 +139,6 @@ sub find_peer ($$$)
|
||||
}
|
||||
|
||||
|
||||
# Our tmp dir.
|
||||
use vars qw ($tmp);
|
||||
$tmp = undef;
|
||||
|
||||
# mktmpdir ($SIGNATURE)
|
||||
# ---------------------
|
||||
# Create a temporary directory which name is based on $SIGNATURE.
|
||||
|
Loading…
Reference in New Issue
Block a user