Thanks, I installed the attached patch, which has the more-usual approach of a uniquely-named temporary.
From 28b4fdb0ea4c540f1b7bcb90675e365e3aa11beb Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 23 Aug 2014 07:55:28 -0700
Subject: [PATCH] build: fix race in parallel builds

Reported by Friedrich Beckmann in: http://bugs.gnu.org/18301
* lib/am/texi-vers.am (?DIRSTAMP?): Put the process-ID into the
temporary file name.  Use a similar temporary in the source dir.
---
 lib/am/texi-vers.am | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/am/texi-vers.am b/lib/am/texi-vers.am
index bddf382..e98bb82 100644
--- a/lib/am/texi-vers.am
+++ b/lib/am/texi-vers.am
@@ -31,25 +31,25 @@ DIST_COMMON += %VTEXI% %STAMPVTI%
 ## %STAMPVTI% is distributed and %DIRSTAMP% isn't: a distributed file
 ## should never be dependent upon a non-distributed built file.
 ## Therefore we ensure that %DIRSTAMP% exists in the rule.
+## Use cp + mv so that the update of %VTEXI% is atomic even if
+## the source directory is on a different file system.
 ?DIRSTAMP?     @test -f %DIRSTAMP% || $(MAKE) $(AM_MAKEFLAGS) %DIRSTAMP%
        @(dir=.; test -f ./%TEXI% || dir=$(srcdir); \
        set `$(SHELL) %MDDIR%mdate-sh $$dir/%TEXI%`; \
        echo "@set UPDATED $$1 $$2 $$3"; \
        echo "@set UPDATED-MONTH $$2 $$3"; \
        echo "@set EDITION $(VERSION)"; \
-       echo "@set VERSION $(VERSION)") > %VTI%.tmp
-## Use cp and rm here because some older "mv"s can't move across
-## filesystems.  Furthermore, GNU "mv" in the AmigaDOS environment
-## can't handle this.
-       @cmp -s %VTI%.tmp %VTEXI% \
-         || (echo "Updating %VTEXI%"; \
-             cp %VTI%.tmp %VTEXI%)
-       -@rm -f %VTI%.tmp
+       echo "@set VERSION $(VERSION)") > %VTI%.tmp$$$$ && \
+       (cmp -s %VTI%.tmp$$$$ %VTEXI% \
+         || (echo "Updating %VTEXI%" && \
+             cp %VTI%.tmp$$$$ %VTEXI%.tmp$$$$ && \
+             mv %VTEXI%.tmp$$$$ %VTEXI%)) && \
+       rm -f %VTI%.tmp$$$$ %VTEXI%.$$$$
        @cp %VTEXI% $@
 
 mostlyclean-am: mostlyclean-%VTI%
 mostlyclean-%VTI%:
-       -rm -f %VTI%.tmp
+       -rm -f %VTI%.tmp* %VTEXI%.tmp*
 
 maintainer-clean-am: maintainer-clean-%VTI%
 maintainer-clean-%VTI%:
-- 
1.9.3

Reply via email to