From 96a7481d17110362d5683d60968c5e86973ca5ed Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Thu, 22 Dec 2011 19:19:28 +0100
Subject: [PATCH] Makefile: Fix parallel distcheck
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Running β€œmake -jN distcheck” for any N > 1 would reliably break when
building the RPC client wrappers. This was due to wrong dependencies in
Makefile.am, fixed by this patch.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Bernardo Dal Seno <bdalseno@google.com>
Signed-off-by: Michael Hanselmann <hansmi@google.com>
---
 Makefile.am | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index b645caba9..11a4d22ce 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -156,17 +156,27 @@ CLEANFILES = \
 # BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
 # it'll cause the target to rebuild every time.
 BUILT_SOURCES = \
+  $(built_base_sources) \
+	$(BUILT_PYTHON_SOURCES) \
+	$(PYTHON_BOOTSTRAP)
+
+built_base_sources = \
 	ganeti \
 	stamp-srclinks \
-	$(all_dirfiles) \
-	$(PYTHON_BOOTSTRAP) \
-	$(BUILT_PYTHON_SOURCES)
+	$(all_dirfiles)
 
-BUILT_PYTHON_SOURCES = \
+built_python_base_sources = \
 	lib/_autoconf.py \
-	lib/_vcsversion.py \
+	lib/_vcsversion.py
+
+BUILT_PYTHON_SOURCES = \
+	$(built_python_base_sources) \
 	lib/_generated_rpc.py
 
+# Generating the RPC wrappers depends on many things, so make sure it's built at
+# the end of the built sources
+lib/_generated_rpc.py: | $(built_base_sources) $(built_python_base_sources)
+
 # these are all built from the underlying %.in sources
 BUILT_EXAMPLES = \
 	doc/examples/ganeti-kvm-poweroff.initd \
@@ -1029,8 +1039,8 @@ lib/_vcsversion.py: Makefile vcs-version | lib/.dir
 	  echo "VCS_VERSION = '$$VCSVER'"; \
 	} > $@
 
-lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC) | lib/.dir
-	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) $< > $@
+lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
+	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
 
 $(REPLACE_VARS_SED): Makefile
 	set -e; \
-- 
GitLab