Subject: texi-vers.am: Problem with parallel builds due to vti.tmp

From: Friedrich Beckmann <[email-masked]>
Date: Wed, 20 Aug 2014 11:17:59 +0200

Package: automake
Version: 1.11.6-1

I encounter a problem with automake during parallel builds for the debian pspp package. When I run the build
process non-parallel then it works. The problem only occurs sometimes when I do a parallel build. The build
is a debian package build. Here are the relevant sections from the build.log and Makefile.in: 

======== snippet from pspp_0.8.3-3_amd64.build ============
make[4]: Entering directory `/home/fritz/pspp/new/pspp-0.8.3'
make[4]: »doc/.dirstamp« ist bereits aktualisiert.
make[4]: Leaving directory `/home/fritz/pspp/new/pspp-0.8.3'
Updating ./doc/version.texi
Updating ./doc/version.texi
cp: Aufruf von stat für „vti.tmp“ nicht möglich: Datei oder Verzeichnis nicht gefunden
make[3]: *** [doc/stamp-vti] Fehler 1
make[3]: Leaving directory `/home/fritz/pspp/new/pspp-0.8.3'
make[2]: *** [pdf-recursive] Fehler 1
make[2]: *** Warte auf noch nicht beendete Prozesse…
================================================================

The build log shows „Updating ./doc/version.texi“ two times. This message is generated when
the stamp-vti target is build. So obviously the parallel build results in two parallel processes to build
stamp-vti. 

================ Relevant section from Makefile.in ======================
$(srcdir)/doc/version.texi:  $(srcdir)/doc/stamp-vti
$(srcdir)/doc/stamp-vti: doc/pspp.texinfo $(top_srcdir)/configure
        test -f doc/$(am__dirstamp) || $(MAKE) $(AM_MAKEFLAGS) doc/$(am__dirstamp)
        @(dir=.; test -f ./doc/pspp.texinfo || dir=$(srcdir); \
        set `$(SHELL) $(top_srcdir)/build-aux/mdate-sh $$dir/doc/pspp.texinfo`; \
        echo "@set UPDATED $$1 $$2 $$3"; \
        echo "@set UPDATED-MONTH $$2 $$3"; \
        echo "@set EDITION $(VERSION)"; \
        echo "@set VERSION $(VERSION)") > vti.tmp
        @cmp -s vti.tmp $(srcdir)/doc/version.texi \
          || (echo "Updating $(srcdir)/doc/version.texi"; \
              cp vti.tmp $(srcdir)/doc/version.texi)
        -@rm -f vti.tmp
================================================================

I think the problem is due to the file „vti.tmp“ which is generated and removed during the build. When
one process has already deleted the file and the other process wants to delete it, then the error message
in the build log: "cp: Aufruf von stat für „vti.tmp“ nicht möglich: Datei oder Verzeichnis nicht gefunden“
will show up. This means that the file vti.tmp is not found for the copy action.

A possible solution could be based on unique temporary files, instead of vti.tmp.  The relevant automake file
is http://git.savannah.gnu.org/cgit/automake.git/tree/lib/am/texi-vers.am. I think the relevant part of the file
did not change since version 1.11.6. Attached is the full build.log. 
The bug report in the pspp project is here: https://savannah.gnu.org/bugs/?43029

Friedrich