summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-08-23 07:55:28 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2014-08-23 07:55:54 -0700
commit74cdef7897da220bf062957ff9699815681441ef (patch)
treefc7bfa5b6ef1539f64c6d44b28d1a1827b1aa8ef
parent49035b4d4f65132bd5426ec57e499152b52ba2c2 (diff)
downloadautomake-74cdef7897da220bf062957ff9699815681441ef.tar.gz
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.
-rw-r--r--lib/am/texi-vers.am18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/am/texi-vers.am b/lib/am/texi-vers.am
index bddf3827d..e98bb8234 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%: