From 333c18a898e9042938be0e5709ec46ff0ead0797 Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Sat, 2 Oct 2010 18:58:56 +0200 Subject: [PATCH] Fix timestamp issues by ensuring configure takes at least a second. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * m4/sanity.m4 (AM_SANITY_CHECK): If we didn't sleep here, start a sleep in the background and wait for it to finish before creating config.status, hopefully fixing all spurious testsuite failures involving botched time stamps. * NEWS: Update. Reports by Ludovic Courtès, Peter Breitenlohner, and others. --- ChangeLog | 10 ++++++++++ NEWS | 8 ++++++++ configure | 22 ++++++++++++++++++++-- m4/sanity.m4 | 26 +++++++++++++++++++++----- 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5fd2c7680..7c9cc877f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-10-02 Ralf Wildenhues + + Fix timestamp issues by ensuring configure takes at least a second. + * m4/sanity.m4 (AM_SANITY_CHECK): If we didn't sleep here, + start a sleep in the background and wait for it to finish + before creating config.status, hopefully fixing all spurious + testsuite failures involving botched time stamps. + * NEWS: Update. + Reports by Ludovic Courtès, Peter Breitenlohner, and others. + 2009-09-06 Ralf Wildenhues Avoid sleeping for one second most of the time in sanity check. diff --git a/NEWS b/NEWS index cd427fbed..d26dfd068 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,13 @@ New in 1.11.0a: +* Miscellaneous changes: + + - Automake's early configure-time sanity check now tries to avoid sleeping + for a second, which slowed down cached configure runs noticeably. In that + case, it will check back at the end of the configure script to ensure that + at least one second has passed, to avoid time stamp issues with makefile + rules rerunning autotools programs. + Bugs fixed in 1.11.0a: * Bugs introduced by 1.11: diff --git a/configure b/configure index 5dd8a9af3..86bd8f51a 100755 --- a/configure +++ b/configure @@ -1875,14 +1875,14 @@ esac # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( + am_has_slept=no for am_try in 1 2; do - echo timestamp > conftest.file + echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi - rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then @@ -1898,6 +1898,7 @@ if ( fi # Just in case. sleep 1 + am_has_slept=yes done test "$2" = conftest.file ) @@ -1910,6 +1911,16 @@ Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! + +fi +rm -f conftest.file + test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. @@ -2868,6 +2879,13 @@ LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs +if test -n "$am_sleep_pid"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 +$as_echo_n "checking that generated files are newer than configure... " >&6; } + wait $am_sleep_pid + { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 +$as_echo "done" >&6; } + fi : ${CONFIG_STATUS=./config.status} diff --git a/m4/sanity.m4 b/m4/sanity.m4 index db87c8bb1..94e1e51f6 100644 --- a/m4/sanity.m4 +++ b/m4/sanity.m4 @@ -1,13 +1,13 @@ # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008, 2009 +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008, 2009, 2010 # 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 6 +# serial 7 # AM_SANITY_CHECK # --------------- @@ -32,14 +32,14 @@ esac # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( + am_has_slept=no for am_try in 1 2; do - echo timestamp > conftest.file + echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi - rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then @@ -55,6 +55,7 @@ if ( fi # Just in case. sleep 1 + am_has_slept=yes done test "$[2]" = conftest.file ) @@ -65,4 +66,19 @@ else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi -AC_MSG_RESULT(yes)]) +AC_MSG_RESULT(yes) +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! + AC_CONFIG_COMMANDS_PRE( + [if test -n "$am_sleep_pid"; then + AC_MSG_CHECKING([that generated files are newer than configure]) + wait $am_sleep_pid + AC_MSG_RESULT([done]) + fi]) +fi +rm -f conftest.file +]) -- 2.47.2