summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2018-04-09 20:42:02 +0000
committerTom Lane2018-04-09 20:42:10 +0000
commit3b8f6e75f3c8c6d192621f21624cc8cee04ec3cb (patch)
tree093376b0c64cc5d5d8aa537cd0862734c5214f93
parent468abb8f7a69c68341b6fc2797166d1079acb1b1 (diff)
Fix partial-build problems introduced by having more generated headers.
Commit 372728b0d created some problems for usages like building a subdirectory without having first done "make all" at the top level, or for proceeding directly to "make install" without "make all". The only reasonably clean way to fix this seems to be to force the submake-generated-headers rule to fire in *any* "make all" or "make install" command anywhere in the tree. To avoid lots of redundant work, as well as parallel make jobs possibly clobbering each others' output, we still need to be sure that the rule fires only once in a recursive build. For that, adopt the same MAKELEVEL hack previously used for "temp-install". But try to document it a bit better. The submake-errcodes mechanism previously used in src/port/ and src/common/ is subsumed by this, so we can get rid of those special cases. It was inadequate for src/common/ anyway after the aforesaid commit, and it always risked parallel attempts to build errcodes.h. Discussion: https://postgr.es/m/[email protected]
-rw-r--r--doc/src/sgml/Makefile2
-rw-r--r--src/Makefile5
-rw-r--r--src/Makefile.global.in39
-rw-r--r--src/backend/Makefile8
-rw-r--r--src/backend/jit/llvm/Makefile1
-rw-r--r--src/common/Makefile7
-rw-r--r--src/pl/plpython/Makefile3
-rw-r--r--src/port/Makefile7
-rw-r--r--src/test/modules/Makefile2
-rw-r--r--src/test/regress/GNUmakefile4
10 files changed, 36 insertions, 42 deletions
diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefile
index f122b4187f4..74aac01c395 100644
--- a/doc/src/sgml/Makefile
+++ b/doc/src/sgml/Makefile
@@ -17,6 +17,8 @@
# to want to use.
html:
+# We don't need the tree-wide headers or install support here.
+NO_GENERATED_HEADERS=yes
NO_TEMP_INSTALL=yes
subdir = doc/src/sgml
diff --git a/src/Makefile b/src/Makefile
index 0e56399cb9a..bcdbd9588aa 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -41,11 +41,6 @@ endif
$(recurse)
-# Update the commonly used headers before building the subdirectories;
-# otherwise, in a parallel build, several different sub-jobs will try to
-# remake them concurrently
-$(SUBDIRS:%=all-%-recurse): | submake-generated-headers
-
install: install-local
install-local: installdirs-local
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 19c9c1e11e8..20090b360e3 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -348,11 +348,39 @@ XGETTEXT = @XGETTEXT@
GZIP = gzip
BZIP2 = bzip2
+
+# Tree-wide build support
+
+# Just about every code subdirectory wants to have the generated headers
+# available before building, but we don't want parallel makes all trying
+# to build the same headers. These rules, together with the recursion rules
+# below, ensure that we update the generated headers once, if needed,
+# at the top level of any "make all" or "make install" request. If a
+# particular subdirectory knows this isn't needed in itself or its children,
+# it can set NO_GENERATED_HEADERS.
+
+all install: submake-generated-headers
+
+.PHONY: submake-generated-headers
+
+submake-generated-headers:
+ifndef NO_GENERATED_HEADERS
+ifeq ($(MAKELEVEL),0)
+ $(MAKE) -C $(top_builddir)/src/backend generated-headers
+endif
+endif
+
+
# Testing
+# In much the same way as above, these rules ensure that we build a temp
+# install tree just once in any recursive "make check". The additional test
+# on abs_top_builddir prevents doing anything foolish to the root directory.
+
check: temp-install
.PHONY: temp-install
+
temp-install:
ifndef NO_TEMP_INSTALL
ifneq ($(abs_top_builddir),)
@@ -544,10 +572,7 @@ submake-libpgfeutils:
$(MAKE) -C $(top_builddir)/src/common all
$(MAKE) -C $(top_builddir)/src/fe_utils all
-submake-generated-headers:
- $(MAKE) -C $(top_builddir)/src/backend generated-headers
-
-.PHONY: submake-libpq submake-libpgport submake-libpgfeutils submake-generated-headers
+.PHONY: submake-libpq submake-libpgport submake-libpgfeutils
##########################################################################
@@ -782,7 +807,9 @@ endif
# This function is only for internal use below. It should be called
# using $(eval). It will set up a target so that it recurses into
-# a given subdirectory. Note that to avoid a nasty bug in make 3.80,
+# a given subdirectory. For the tree-wide all/install/check cases,
+# ensure we do our one-time tasks before recursing (see targets above).
+# Note that to avoid a nasty bug in make 3.80,
# this function has to avoid using any complicated constructs (like
# multiple targets on a line) and also not contain any lines that expand
# to more than about 200 bytes. This is why we make it apply to just one
@@ -793,7 +820,7 @@ endif
define _create_recursive_target
.PHONY: $(1)-$(2)-recurse
$(1): $(1)-$(2)-recurse
-$(1)-$(2)-recurse: $(if $(filter check, $(3)), temp-install)
+$(1)-$(2)-recurse: $(if $(filter all install, $(3)), submake-generated-headers) $(if $(filter check, $(3)), temp-install)
$$(MAKE) -C $(2) $(3)
endef
# Note that the use of $$ on the last line above is important; we want
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 82a59eac2d7..1aaf1ec2f59 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -111,14 +111,6 @@ endif
endif # aix
-# Update the commonly used headers before building the subdirectories
-$(SUBDIRS:%=%-recursive): | generated-headers
-
-# src/port needs a convenient way to force just errcodes.h to get built
-submake-errcodes: $(top_builddir)/src/include/utils/errcodes.h
-
-.PHONY: submake-errcodes
-
$(top_builddir)/src/port/libpgport_srv.a: | submake-libpgport
diff --git a/src/backend/jit/llvm/Makefile b/src/backend/jit/llvm/Makefile
index d7a36d73717..e2db4cea65c 100644
--- a/src/backend/jit/llvm/Makefile
+++ b/src/backend/jit/llvm/Makefile
@@ -27,7 +27,6 @@ CFLAGS += $(LLVM_CFLAGS)
CXXFLAGS += $(LLVM_CXXFLAGS)
override CPPFLAGS := $(LLVM_CPPFLAGS) $(CPPFLAGS)
SHLIB_LINK += $(LLVM_LIBS)
-SHLIB_PREREQS += submake-generated-headers
# Because this module includes C++ files, we need to use a C++
# compiler for linking. Makefile.shlib uses $(COMPILER) to build
diff --git a/src/common/Makefile b/src/common/Makefile
index e9e75867f3c..1fc2c66225b 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -88,13 +88,6 @@ libpgcommon_srv.a: $(OBJS_SRV)
%_srv.o: %.c %.o
$(CC) $(CFLAGS) $(subst -DFRONTEND ,, $(CPPFLAGS)) -c $< -o $@
-$(OBJS_SRV): | submake-errcodes
-
-.PHONY: submake-errcodes
-
-submake-errcodes:
- $(MAKE) -C ../backend submake-errcodes
-
# Dependencies of keywords.o need to be managed explicitly to make sure
# that you don't get broken parsing code, even in a non-enable-depend build.
# Note that gram.h isn't required for the frontend version of keywords.o.
diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile
index d09910835d1..fb785496ea5 100644
--- a/src/pl/plpython/Makefile
+++ b/src/pl/plpython/Makefile
@@ -99,9 +99,6 @@ include $(top_srcdir)/src/Makefile.shlib
all: all-lib
-$(OBJS): | submake-generated-headers
-
-
install: all install-lib install-data
installdirs: installdirs-lib
diff --git a/src/port/Makefile b/src/port/Makefile
index f328b705e46..d7467fb0788 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -87,13 +87,6 @@ libpgport_srv.a: $(OBJS_SRV)
%_srv.o: %.c %.o
$(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
-$(OBJS_SRV): | submake-errcodes
-
-.PHONY: submake-errcodes
-
-submake-errcodes:
- $(MAKE) -C ../backend submake-errcodes
-
# Dependency is to ensure that path changes propagate
path.o: path.c pg_config_paths.h
diff --git a/src/test/modules/Makefile b/src/test/modules/Makefile
index a9b8377acfd..19d60a506e1 100644
--- a/src/test/modules/Makefile
+++ b/src/test/modules/Makefile
@@ -20,6 +20,4 @@ SUBDIRS = \
test_shm_mq \
worker_spi
-all: submake-generated-headers
-
$(recurse)
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index deef08dfc12..7ba4e9c5abb 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -65,8 +65,6 @@ include $(top_srcdir)/src/Makefile.shlib
all: all-lib
-$(OBJS): | submake-generated-headers
-
# Test input and expected files. These are created by pg_regress itself, so we
# don't have a rule to create them. We do need rules to clean them however.
input_files = $(patsubst $(srcdir)/input/%.source,sql/%.sql, $(wildcard $(srcdir)/input/*.source))
@@ -107,7 +105,7 @@ $(top_builddir)/contrib/spi/refint$(DLSUFFIX): | submake-contrib-spi ;
$(top_builddir)/contrib/spi/autoinc$(DLSUFFIX): | submake-contrib-spi ;
-submake-contrib-spi: | submake-libpgport submake-generated-headers
+submake-contrib-spi: | submake-libpgport
$(MAKE) -C $(top_builddir)/contrib/spi
.PHONY: submake-contrib-spi