From cfad144f894b306fc300f5d03ea52a32d4624db0 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 17 Nov 2010 08:08:41 +0200
Subject: [PATCH] Additional fixes for parallel make

Add some additional dependencies to constrain the build order to prevent
parallel make from failing.  In the case of src/Makefile, this is likely to be
too complicated to be worth maintaining, so just add .NOTPARALLEL to get the
old for-loop-like behavior.

More fine-tuning might be necessary for some platforms or configurations.
---
 src/Makefile                 | 4 ++++
 src/interfaces/Makefile      | 2 ++
 src/interfaces/ecpg/Makefile | 3 ++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/Makefile b/src/Makefile
index 0d4a6ee65b9..4469d2cdf2c 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -26,6 +26,10 @@ SUBDIRS = \
 	makefiles \
 	test/regress
 
+# There are too many interdependencies between the subdirectories, so
+# don't attempt parallel make here.
+.NOTPARALLEL:
+
 $(recurse)
 
 install: install-local
diff --git a/src/interfaces/Makefile b/src/interfaces/Makefile
index 2c034bc7923..9fe368eed50 100644
--- a/src/interfaces/Makefile
+++ b/src/interfaces/Makefile
@@ -15,3 +15,5 @@ include $(top_builddir)/src/Makefile.global
 SUBDIRS = libpq ecpg
 
 $(recurse)
+
+all-ecpg-recurse: all-libpq-recurse
diff --git a/src/interfaces/ecpg/Makefile b/src/interfaces/ecpg/Makefile
index d955ceed1c9..ca434c8ce22 100644
--- a/src/interfaces/ecpg/Makefile
+++ b/src/interfaces/ecpg/Makefile
@@ -6,7 +6,8 @@ SUBDIRS = include pgtypeslib ecpglib compatlib preproc
 
 $(recurse)
 
-all-compatlib-recursive: all-ecpglib-recursive
+all-compatlib-recurse: all-ecpglib-recurse
+all-ecpglib-recurse: all-pgtypeslib-recurse
 
 clean distclean maintainer-clean:
 	$(MAKE) -C test clean