autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

autoreconf and aging aclocal input files (was: YYSTYPE_IS_TRIVIAL)


From: Paul Eggert
Subject: autoreconf and aging aclocal input files (was: YYSTYPE_IS_TRIVIAL)
Date: Thu, 25 Apr 2002 13:07:47 -0700 (PDT)

> From: Akim Demaille <address@hidden>
> Date: 25 Apr 2002 12:27:50 +0200

> +           # To make sure aclocal.m4 is younger, we change the
> +           # modification times of the local M4 files to be
> +           # slightly older than it.
> ...
> +                   debug "making $file younger than aclocal.m4";
> +                   utime $aclocal_m4_mtime - 1, $aclocal_m4_mtime - 1,
> +                     $file;

This goes a bit too far.  We don't need to make the files younger than
aclocal.m4; we need merely to make sure that they are no older than
aclocal.m4.  `make' thinks that a file is out-of-date only if it is
older than any of its prerequisites (or if it does not exist).  This
behavior is required by POSIX, and it is has been true of Unix `make'
for decades; I think we can rely on it.  (The original `make' behaved
differently, but that's one of the first bugs that Stu Feldman fixed
back in the 1970s.)

It may sound like I'm quibbling over a 1-second difference, but `make'
should work correctly even on faster machines that can do quite a few
things in 1 second.  These days, GNU `make' uses nanosecond resolution
on file time stamps, on systems that supports them: going back in time
by a billion nanoseconds could break parallel makes.

Come to think of it, utime can "go back in time" up to a 1e9 - 1
nanoseconds, since it doesn't set the nanosecond part of the time
stamp, so we have the problem even if we don't go back in time.

Here is a proposed patch to address these two issues.

I hope you don't mind my rewriting ">" to be "<" here.  Perhaps it's
time for my semiannual speech on the subject.  This is style advice
that I learned long ago from D. Val Schorre, whom Knuth credits with
the first to propose goto-less programming.  Here's the advice:

  Use <, not >.
  (Similarly for <= and >=.)

It may sound silly at first, but it really does make code a bit more
readable if textual order reflects semantic order.


2002-04-25  Paul Eggert  <address@hidden>

        * bin/autoreconf.in (autoreconf): Don't age aclocal.m4's input
        files to be 1 second older; just set them to be the same time.
        Also, sleep 1 second after the first aclocal, to work around
        problems with sub-second time stamps on the input files.

--- autoreconf.in.~1.96.~       2002-04-25 12:24:05.000000000 -0700
+++ autoreconf.in       2002-04-25 12:44:54.220400000 -0700
@@ -288,6 +288,16 @@ sub autoreconf ($)
     }
   else
     {
+      # Some filesystems have sub-second time stamps, and if so we may
+      # run into trouble later, after we rerun autoconf and set the
+      # time stamps of input files to be no greater than aclocal.m4,
+      # because the time-stamp-setting operation (utime) has a
+      # resolution of only 1 second.  Work around the problem by
+      # ensuring that there is at least a one-second window before the
+      # time stamp of aclocal.m4t in which no file time stamps can
+      # fall.
+      sleep 1;
+
       xsystem ("$aclocal $aclocal_flags --output=aclocal.m4t");
       # aclocal may produce no output.
       update_file ('aclocal.m4t', 'aclocal.m4')
@@ -449,7 +459,7 @@ sub autoreconf ($)
              # aclocal.m4.
              #
              # Why is not always the case?  Because we already run
-             # aclocal a first (before tracing), which, for instance,
+             # aclocal at first (before tracing), which, for instance,
              # can find Gettext's macros in .../share/aclocal, so we
              # may have had the right aclocal.m4 already.  Then
              # gettextize is run, and installs locally these M4
@@ -457,11 +467,11 @@ sub autoreconf ($)
              # the _same_ aclocal.m4, and doesn't change its
              # timestamp.  But later, Automake's Makefile expresses
              # that aclocal.m4 depends on these local files, which
-             # are younger, so it triggers aclocal again.
+             # are newer, so it triggers aclocal again.
              #
-             # To make sure aclocal.m4 is younger, we change the
+             # To make sure aclocal.m4 is no older, we change the
              # modification times of the local M4 files to be
-             # slightly older than it.
+             # not newer than it.
              #
              # First, where are the local files?
              my $aclocal_local_dir = '.';
@@ -469,16 +479,15 @@ sub autoreconf ($)
                {
                  $aclocal_local_dir = $1;
                }
-             # All the local files younger than aclocal.m4 are to be
-             # grown older than it.
+             # All the local files newer than aclocal.m4 are to be
+             # made not newer than it.
              my $aclocal_m4_mtime = mtime ('aclocal.m4');
              for my $file (glob ("$aclocal_local_dir/*.m4"), 'acinclude.m4')
                {
-                 if (mtime ($file) >= $aclocal_m4_mtime)
+                 if ($aclocal_m4_mtime < mtime ($file))
                    {
-                     debug "making $file younger than aclocal.m4";
-                     utime $aclocal_m4_mtime - 1, $aclocal_m4_mtime - 1,
-                       $file;
+                     debug "aging $file to be not newer than aclocal.m4";
+                     utime $aclocal_m4_mtime, $aclocal_m4_mtime, $file;
                    }
                }
            }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]