build: avoid parallel build failures
authorJim Meyering <meyering@redhat.com>
Wed, 11 Apr 2012 19:25:48 +0000 (21:25 +0200)
committerJim Meyering <meyering@redhat.com>
Thu, 12 Apr 2012 16:49:24 +0000 (18:49 +0200)
A parallel build would fail when two concurrent sub-make processes
tried to build lib/Automake/Config.pm.  The loser would complain that
  grep: lib/Automake/Config.pm-t: No such file or directory
  chmod: cannot access `lib/Automake/Config.pm-t': No such file or\
    directory
  make[1]: *** [lib/Automake/Config.pm] Error 1
* Makefile.am (update_mans): Don't build lib/Automake/Config.pm here.
Instead, depend on it from the two rules that use it:
($(srcdir)/doc/aclocal-$(APIVERSION).1): Depend on it.
($(srcdir)/doc/automake-$(APIVERSION).1): Likewise.

[ Note that technically, the above is incorrect, since it makes those
  distributed doc/*.1 files depend on generated aclocal and automake.
  That problem is addressed by the following commit. ]

However, that was not enough, since even then, a parallel build
would still fail, now with this:

  help2man: can't get `--help' info from automake-1.11a
  Try `--no-discard-stderr' if option outputs to stderr
  make: *** [doc/automake-1.11a.1] Error 1

a subsequent "make -j3" would create the missing file.
That was because help2man would invoke t/wrap/aclocal.in and
t/wrap/automake.in, each of which would require aclocal and
automake, yet those two files weren't guaranteed to be created.
Add explicit dependencies:
($(srcdir)/doc/aclocal-$(APIVERSION).1): Depend on aclocal.
($(srcdir)/doc/automake-$(APIVERSION).1): Depend on automake.

Makefile.am

index 991de4c..438ffe6 100644 (file)
@@ -459,7 +459,6 @@ MAINTAINERCLEANFILES += $(dist_man1_MANS)
 
 update_mans = \
   $(AM_V_GEN): \
-    && $(MAKE) $(AM_MAKEFLAGS) lib/Automake/Config.pm \
     && PATH="$(abs_builddir)/t/wrap$(PATH_SEPARATOR)$$PATH" \
     && export PATH \
     && $(HELP2MAN) --output=$@
@@ -469,9 +468,9 @@ $(srcdir)/doc/aclocal.1 $(srcdir)/doc/automake.1:
          && f=`echo $@ | sed 's|.*/||; s|\.1$$||; $(transform)'` \
          && echo ".so man1/$$f-$(APIVERSION).1" > $@
 
-$(srcdir)/doc/aclocal-$(APIVERSION).1: $(srcdir)/aclocal.in
+$(srcdir)/doc/aclocal-$(APIVERSION).1: $(srcdir)/aclocal.in aclocal lib/Automake/Config.pm
        $(update_mans) aclocal-$(APIVERSION)
-$(srcdir)/doc/automake-$(APIVERSION).1: $(srcdir)/automake.in
+$(srcdir)/doc/automake-$(APIVERSION).1: $(srcdir)/automake.in automake lib/Automake/Config.pm
        $(update_mans) automake-$(APIVERSION)