summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.shlib20
-rw-r--r--src/backend/Makefile26
-rw-r--r--src/backend/catalog/Makefile13
-rw-r--r--src/backend/parser/Makefile17
-rw-r--r--src/backend/storage/lmgr/Makefile5
-rw-r--r--src/backend/utils/Makefile5
-rw-r--r--src/bin/psql/Makefile7
-rw-r--r--src/interfaces/ecpg/preproc/Makefile5
-rw-r--r--src/pl/plpgsql/src/Makefile4
-rw-r--r--src/test/isolation/Makefile9
10 files changed, 59 insertions, 52 deletions
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index f50b0398c90..2ba92ce7121 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -338,13 +338,9 @@ else # PORTNAME == aix
# AIX case
-# There is no correct way to write a rule that generates two files.
-# Rules with two targets don't have that meaning, they are merely
-# shorthand for two otherwise separate rules. To be safe for parallel
-# make, we must chain the dependencies like this. The semicolon is
-# important, otherwise make will choose some built-in rule.
-
-$(stlib): $(shlib) ;
+# See notes in src/backend/parser/Makefile about the following two rules
+$(stlib): $(shlib)
+ touch $@
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
rm -f $(stlib)
@@ -375,13 +371,9 @@ else
# Win32 case
-# There is no correct way to write a rule that generates two files.
-# Rules with two targets don't have that meaning, they are merely
-# shorthand for two otherwise separate rules. To be safe for parallel
-# make, we must chain the dependencies like this. The semicolon is
-# important, otherwise make will choose some built-in rule.
-
-$(stlib): $(shlib) ;
+# See notes in src/backend/parser/Makefile about the following two rules
+$(stlib): $(shlib)
+ touch $@
# XXX A backend that loads a module linked with libgcc_s_dw2-1.dll will exit
# uncleanly, hence -static-libgcc. (Last verified with MinGW-w64 compilers
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 3b08defe2bc..e124d1a75c0 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -69,13 +69,10 @@ ifeq ($(PORTNAME), cygwin)
postgres: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) -Wl,--stack,$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(call expand_subsys,$^) $(LIBS) -o $@
-# There is no correct way to write a rule that generates two files.
-# Rules with two targets don't have that meaning, they are merely
-# shorthand for two otherwise separate rules. To be safe for parallel
-# make, we must chain the dependencies like this. The semicolon is
-# important, otherwise make will choose some built-in rule.
-
-libpostgres.a: postgres ;
+# libpostgres.a is actually built in the preceding rule, but we need this to
+# ensure it's newer than postgres; see notes in src/backend/parser/Makefile
+libpostgres.a: postgres
+ touch $@
endif # cygwin
@@ -85,7 +82,10 @@ LIBS += -lsecur32
postgres: $(OBJS) $(WIN32RES)
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -Wl,--stack=$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS) -o $@$(X)
-libpostgres.a: postgres ;
+# libpostgres.a is actually built in the preceding rule, but we need this to
+# ensure it's newer than postgres; see notes in src/backend/parser/Makefile
+libpostgres.a: postgres
+ touch $@
endif # win32
@@ -129,12 +129,18 @@ postgres.o: $(OBJS)
# The following targets are specified in make commands that appear in
# the make files in our subdirectories. Note that it's important we
# match the dependencies shown in the subdirectory makefiles!
+# Also, in cases where a subdirectory makefile generates two files in
+# what's really one step, such as bison producing both gram.h and gram.c,
+# we must request making the one that is shown as the secondary (dependent)
+# output, else the timestamp on it might be wrong. By project convention,
+# the .h file is the dependent one for bison output, so we need only request
+# that; but in other cases, request both for safety.
parser/gram.h: parser/gram.y
$(MAKE) -C parser gram.h
storage/lmgr/lwlocknames.h: storage/lmgr/generate-lwlocknames.pl storage/lmgr/lwlocknames.txt
- $(MAKE) -C storage/lmgr lwlocknames.h
+ $(MAKE) -C storage/lmgr lwlocknames.h lwlocknames.c
utils/errcodes.h: utils/generate-errcodes.pl utils/errcodes.txt
$(MAKE) -C utils errcodes.h
@@ -210,7 +216,7 @@ distprep:
$(MAKE) -C bootstrap bootparse.c bootscanner.c
$(MAKE) -C catalog schemapg.h postgres.bki postgres.description postgres.shdescription
$(MAKE) -C replication repl_gram.c repl_scanner.c syncrep_gram.c syncrep_scanner.c
- $(MAKE) -C storage/lmgr lwlocknames.h
+ $(MAKE) -C storage/lmgr lwlocknames.h lwlocknames.c
$(MAKE) -C utils fmgrtab.c fmgroids.h errcodes.h
$(MAKE) -C utils/misc guc-file.c
$(MAKE) -C utils/sort qsort_tuple.c
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 1ce76100497..4229c4fe000 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -21,7 +21,7 @@ BKIFILES = postgres.bki postgres.description postgres.shdescription
include $(top_srcdir)/src/backend/common.mk
-all: $(BKIFILES) schemapg.h
+all: $(BKIFILES) schemapg.h postgres.description postgres.shdescription
# Note: there are some undocumented dependencies on the ordering in which
# the catalog header files are assembled into postgres.bki. In particular,
@@ -51,12 +51,15 @@ catalogdir = $(top_srcdir)/src/backend/catalog
# locations of headers that genbki.pl needs to read
pg_includes = -I$(top_srcdir)/src/include/catalog -I$(top_builddir)/src/include/catalog
-# see explanation in ../parser/Makefile
-postgres.description: postgres.bki ;
+# see notes in src/backend/parser/Makefile about multiple output files
+postgres.description: postgres.bki
+ touch $@
-postgres.shdescription: postgres.bki ;
+postgres.shdescription: postgres.bki
+ touch $@
-schemapg.h: postgres.bki ;
+schemapg.h: postgres.bki
+ touch $@
# Technically, this should depend on Makefile.global, but then
# postgres.bki would need to be rebuilt after every configure run,
diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile
index fdd8485cec5..161251a2f91 100644
--- a/src/backend/parser/Makefile
+++ b/src/backend/parser/Makefile
@@ -28,12 +28,17 @@ endif
# There is no correct way to write a rule that generates two files.
# Rules with two targets don't have that meaning, they are merely
-# shorthand for two otherwise separate rules. To be safe for parallel
-# make, we must chain the dependencies like this. The semicolon is
-# important, otherwise make will choose the built-in rule for
-# gram.y=>gram.c.
-
-gram.h: gram.c ;
+# shorthand for two otherwise separate rules. If we have an action
+# that in fact generates two or more files, we must choose one of them
+# as primary and show it as the action's output, then make all of the
+# other output files dependent on the primary, like this. Furthermore,
+# the "touch" action is essential, because it ensures that gram.h is
+# marked as newer than (or at least no older than) gram.c. Without that,
+# make is likely to try to rebuild gram.h in subsequent runs, which causes
+# failures in VPATH builds from tarballs.
+
+gram.h: gram.c
+ touch $@
gram.c: BISONFLAGS += -d
gram.c: BISON_CHECK_CMD = $(PERL) $(srcdir)/check_keywords.pl $< $(top_srcdir)/src/include/parser/kwlist.h
diff --git a/src/backend/storage/lmgr/Makefile b/src/backend/storage/lmgr/Makefile
index cd6ec73f08f..d081209e8d7 100644
--- a/src/backend/storage/lmgr/Makefile
+++ b/src/backend/storage/lmgr/Makefile
@@ -25,8 +25,9 @@ s_lock_test: s_lock.c $(top_builddir)/src/port/libpgport.a
$(CC) $(CPPFLAGS) $(CFLAGS) -DS_LOCK_TEST=1 $(srcdir)/s_lock.c \
$(TASPATH) -L $(top_builddir)/src/port -lpgport -o s_lock_test
-# see explanation in ../../parser/Makefile
-lwlocknames.c: lwlocknames.h ;
+# see notes in src/backend/parser/Makefile
+lwlocknames.c: lwlocknames.h
+ touch $@
lwlocknames.h: $(top_srcdir)/src/backend/storage/lmgr/lwlocknames.txt generate-lwlocknames.pl
$(PERL) $(srcdir)/generate-lwlocknames.pl $<
diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile
index 83745337180..7540f10541f 100644
--- a/src/backend/utils/Makefile
+++ b/src/backend/utils/Makefile
@@ -20,8 +20,9 @@ all: errcodes.h fmgroids.h probes.h
$(SUBDIRS:%=%-recursive): fmgroids.h
-# see explanation in ../parser/Makefile
-fmgroids.h: fmgrtab.c ;
+# see notes in src/backend/parser/Makefile
+fmgroids.h: fmgrtab.c
+ touch $@
fmgrtab.c: Gen_fmgrtab.pl $(catalogdir)/Catalog.pm $(top_srcdir)/src/include/catalog/pg_proc.h
$(PERL) -I $(catalogdir) $< $(top_srcdir)/src/include/catalog/pg_proc.h
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index 4295154cae6..9199c3eaff1 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -35,7 +35,10 @@ psql: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
help.o: sql_help.h
-sql_help.c: sql_help.h ;
+# See notes in src/backend/parser/Makefile about the following two rules
+sql_help.c: sql_help.h
+ touch $@
+
sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
$(PERL) $< $(REFDOCDIR) $*
@@ -47,7 +50,7 @@ ifeq ($(GCC),yes)
psqlscanslash.o: CFLAGS += -Wno-error
endif
-distprep: sql_help.h psqlscanslash.c
+distprep: sql_help.h sql_help.c psqlscanslash.c
install: all installdirs
$(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 30db5a049af..5ef30a9cae7 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -44,7 +44,10 @@ ecpg: $(OBJS) | submake-libpgport
../ecpglib/typename.o: ../ecpglib/typename.c
$(MAKE) -C $(dir $@) $(notdir $@)
-preproc.h: preproc.c ;
+# See notes in src/backend/parser/Makefile about the following two rules
+preproc.h: preproc.c
+ touch $@
+
preproc.c: BISONFLAGS += -d
preproc.y: ../../../backend/parser/gram.y parse.pl ecpg.addons ecpg.header ecpg.tokens ecpg.trailer ecpg.type
diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile
index e073b2abd0a..5fb5025a6ab 100644
--- a/src/pl/plpgsql/src/Makefile
+++ b/src/pl/plpgsql/src/Makefile
@@ -58,7 +58,9 @@ uninstall-headers:
pl_gram.o pl_handler.o pl_comp.o pl_exec.o pl_funcs.o pl_scanner.o: plpgsql.h pl_gram.h plerrcodes.h
# See notes in src/backend/parser/Makefile about the following two rules
-pl_gram.h: pl_gram.c ;
+pl_gram.h: pl_gram.c
+ touch $@
+
pl_gram.c: BISONFLAGS += -d
# generate plerrcodes.h from src/backend/utils/errcodes.txt
diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile
index 3d272d5b592..daf7600d842 100644
--- a/src/test/isolation/Makefile
+++ b/src/test/isolation/Makefile
@@ -29,15 +29,6 @@ isolationtester$(X): $(OBJS) | submake-libpq submake-libpgport
distprep: specparse.c specscanner.c
-# There is no correct way to write a rule that generates two files.
-# Rules with two targets don't have that meaning, they are merely
-# shorthand for two otherwise separate rules. To be safe for parallel
-# make, we must chain the dependencies like this. The semicolon is
-# important, otherwise make will choose the built-in rule for
-# gram.y=>gram.c.
-
-specparse.h: specparse.c ;
-
# specscanner is compiled as part of specparse
specparse.o: specscanner.c