+2006-08-04 Alexandre Duret-Lutz <adl@gnu.org>
+
+ * aclocal.in (install_file): Cannot use /dev/null while diffing
+ new files, because Tru64's diff do not handle /dev/null. So
+ create an empty destination file before running diff on a new
+ file, and erase it afterward. Fall back to using /dev/null only
+ if we cannot create this file.
+ Report and initial patch from Ralf Wildenhues.
+ (unlink_tmp): New function.
+ * test/acloca18.test: Make sure the empty file has been erased.
+
2006-08-04 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* automake.in (handle_LIBOBJS_or_ALLOCA): With subdir-objects,
# Autoconf version
# Set by trace_used_macros.
my $ac_version;
+
+# If set, names a temporary file that must be erased on abnormal exit.
+my $erase_me;
\f
################################################################
+# Erase temporary file ERASE_ME.
+sub unlink_tmp
+{
+ if (defined $erase_me && -e $erase_me && !unlink ($erase_me))
+ {
+ fatal "could not remove `$erase_me': $!";
+ }
+ undef $erase_me;
+}
+
+$SIG{'INT'} = $SIG{'TERM'} = $SIG{'QUIT'} = $SIG{'HUP'} = 'unlink_tmp';
+END { unlink_tmp }
+
# Check macros in acinclude.m4. If one is not used, warn.
sub check_acinclude ()
{
sub install_file ($$)
{
my ($src, $dest) = @_;
- my $diff_dest = $dest;
+ my $diff_dest;
if ($force_output
|| !exists $file_contents{$dest}
if (-e $dest)
{
msg 'note', "overwriting `$dest' with `$src'";
+ $diff_dest = $dest;
}
else
{
msg 'note', "installing `$dest' from `$src'";
- $diff_dest = '/dev/null';
}
if (@diff_command)
{
+ if (! defined $diff_dest)
+ {
+ # $dest does not exist. We create an empty one just to
+ # run diff, and we erase it afterward. Using the real
+ # the destination file (rather than a temporary file) is
+ # good when diff is run with options that display the
+ # file name.
+ #
+ # If creating $dest fails, fall back to /dev/null. At
+ # least one diff implementation (Tru64's) cannot deal
+ # with /dev/null. However working around this is not
+ # worth the trouble since nobody run aclocal on a
+ # read-only tree anyway.
+ $erase_me = $dest;
+ my $f = new IO::File "> $dest";
+ if (! defined $f)
+ {
+ undef $erase_me;
+ $diff_dest = '/dev/null';
+ }
+ else
+ {
+ $diff_dest = $dest;
+ $f->close;
+ }
+ }
my @cmd = (@diff_command, $diff_dest, $src);
$! = 0;
verb "running: @cmd";
my $res = system (@cmd);
Automake::FileUtils::handle_exec_errors "@cmd", 1
if $res;
+ unlink_tmp;
}
elsif (!$dry_run)
{
#! /bin/sh
-# Copyright (C) 2005 Free Software Foundation, Inc.
+# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
AC_DEFUN([AM_MACRO2], [echo macro2d >> foo])
EOF
rm -f foo
-$ACLOCAL --diff=diff >output
+$ACLOCAL --diff=diff >output 2>stderr
+cat stderr
cat output
grep '#serial 456' output
+test ! -f 4/m1.m4
+grep 'installing.*4/m1.m4' stderr