automake-patches
[Top][All Lists]
Advanced

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

avoid a 1-second sleep in every configure script


From: Jim Meyering
Subject: avoid a 1-second sleep in every configure script
Date: Thu, 30 Jul 2009 16:20:52 +0200

Hi,

I noticed (by inspection, since I was looking at AM_SANITY_CHECK)
the unconditional 1-second sleep in coreutils' configure script,
and realized that it'd be easy to avoid it on modern systems:
either because configure was created more than a second before,
or because the file system supports subsecond time stamps.

The test below relies on stat, but works fine (penalty is the 1-second
sleep) if stat is not available or does not honor the --format option.

I deliberately chose not to use ls, because parsing
its output is not worth the trouble.

Jim

>From d658959e28eaa19e1ae8e6f68ad1a39ec049af51 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 30 Jul 2009 15:55:04 +0200
Subject: [PATCH] AM_SANITY_CHECK: avoid a 1-second sleep, if possible

* m4/sanity.m4 (AM_SANITY_CHECK): Use stat to compare timestamps.
Perform the 1-second sleep only if necessary.
---
 ChangeLog    |    6 ++++++
 m4/sanity.m4 |   18 ++++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bab1dcb..f8c392e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-07-30  Jim Meyering  <address@hidden>
+
+       AM_SANITY_CHECK: avoid a 1-second sleep, if possible
+       * m4/sanity.m4 (AM_SANITY_CHECK): Use stat to compare timestamps.
+       Perform the 1-second sleep only if necessary.
+
 2009-07-08  Jim Meyering  <address@hidden>

        manual: fix a trivial grammar error.
diff --git a/m4/sanity.m4 b/m4/sanity.m4
index 3d2f304..46beca9 100644
--- a/m4/sanity.m4
+++ b/m4/sanity.m4
@@ -1,21 +1,31 @@
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-

-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 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.

-# serial 5
+# serial 6

 # AM_SANITY_CHECK
 # ---------------
 AC_DEFUN([AM_SANITY_CHECK],
 [AC_MSG_CHECKING([whether build environment is sane])
-# Just in case
-sleep 1
+# We want conftest.file to have an mtime newer than configure.
+# On some file systems we may have to sleep a second to ensure that.
+# On others, with subsecond timestamp resolution, there is no need.
+# Compare time stamps, and sleep only if a stat failed or they're identical.
 echo timestamp > conftest.file
+am_sleep=0
+am_sanity_d1=`stat --format=%y conftest.file 2>/dev/null` || am_sleep=1
+am_sanity_d2=`stat --format=%y "$srcdir/configure" 2>/dev/null` || am_sleep=1
+if test $am_sleep = 1 || test "$am_sanity_d1" = "$am_sanity_d2"; then
+   sleep 1
+   echo timestamp > conftest.file
+fi
+
 # Reject unsafe characters in $srcdir or the absolute working directory
 # name.  Accept space and tab only in the latter.
 am_lf='
--
1.6.4.212.g4719




reply via email to

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