DISTFILES containing a directory and files in that directory.
[platform/upstream/automake.git] / aclocal.in
index acb05d2..cc52528 100644 (file)
@@ -8,11 +8,11 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
 # aclocal - create aclocal.m4 by scanning configure.ac
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006  Free Software Foundation, Inc.
+# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
+# the Free Software Foundation; either version 3, or (at your option)
 # any later version.
 
 # This program is distributed in the hope that it will be useful,
@@ -21,9 +21,7 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Written by Tom Tromey <tromey@redhat.com>, and
 # Alexandre Duret-Lutz <adl@gnu.org>.
@@ -49,6 +47,9 @@ use Cwd;
 
 # Some globals.
 
+# We do not operate in threaded mode.
+$perl_threads = 0;
+
 # Include paths for searching macros.  We search macros in this order:
 # user-supplied directories first, then the directory containing the
 # automake macros, and finally the system-wide directories for
@@ -144,9 +145,38 @@ my $serial_number_rx = '^\d+(?:\.\d+)*$';
 # 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.  Handle signals.
+sub unlink_tmp
+{
+  my ($sig) = @_;
+
+  if ($sig)
+    {
+      verb "caught SIG$sig, bailing out";
+    }
+  if (defined $erase_me && -e $erase_me && !unlink ($erase_me))
+    {
+      fatal "could not remove `$erase_me': $!";
+    }
+  undef $erase_me;
+
+  # reraise default handler.
+  if ($sig)
+    {
+      $SIG{$sig} = 'DEFAULT';
+      kill $sig => $$;
+    }
+}
+
+$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 ()
 {
@@ -180,7 +210,7 @@ sub reset_maps ()
 sub install_file ($$)
 {
   my ($src, $dest) = @_;
-  my $diff_dest = $dest;
+  my $diff_dest;
 
   if ($force_output
       || !exists $file_contents{$dest}
@@ -189,21 +219,48 @@ sub install_file ($$)
       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)
        {
@@ -608,7 +665,9 @@ sub trace_used_macros ()
   my $traces = ($ENV{AUTOM4TE} || 'autom4te');
   $traces .= " --language Autoconf-without-aclocal-m4 ";
   # All candidate files.
-  $traces .= join (' ', grep { exists $files{$_} } @file_order) . " ";
+  $traces .= join (' ',
+                  (map { "'$_'" }
+                   (grep { exists $files{$_} } @file_order))) . " ";
   # All candidate macros.
   $traces .= join (' ',
                   (map { "--trace='$_:\$f::\$n::\$1'" }
@@ -739,8 +798,13 @@ sub write_aclocal ($@)
       # Do not use "$output_file" here for the same reason we do not
       # use it in the header below.  autom4te will output the name of
       # the file in the diagnostic anyway.
-      $output = "m4_if(m4_PACKAGE_VERSION, [$ac_version],,
-[m4_fatal([this file was generated for autoconf $ac_version], [63])])
+      $output = "m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [$ac_version],,
+[m4_warning([this file was generated for autoconf $ac_version.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically `autoreconf'.])])
 
 $output";
     }
@@ -754,7 +818,7 @@ $output";
   $output = "# generated automatically by aclocal $VERSION -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006  Free Software Foundation, Inc.
+# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -843,12 +907,13 @@ sub version()
 {
   print <<EOF;
 aclocal (GNU $PACKAGE) $VERSION
+Copyright (C) 2009 Free Software Foundation, Inc.
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+
 Written by Tom Tromey <tromey\@redhat.com>
        and Alexandre Duret-Lutz <adl\@gnu.org>.
-
-Copyright (C) 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions.  There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 EOF
   exit 0;
 }