aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/Makefile33
-rw-r--r--src/backend/parser/Makefile17
-rw-r--r--src/backend/storage/lmgr/Makefile5
-rw-r--r--src/backend/utils/Makefile9
4 files changed, 40 insertions, 24 deletions
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 6450c5a9597..ca230de2f3f 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -70,13 +70,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
@@ -86,7 +83,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
@@ -130,21 +130,28 @@ 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
-# see explanation in parser/Makefile
-utils/fmgrprotos.h: utils/fmgroids.h ;
+# see notes in src/backend/parser/Makefile
+utils/fmgrprotos.h: utils/fmgroids.h
+ touch $@
utils/fmgroids.h: utils/Gen_fmgrtab.pl catalog/Catalog.pm $(top_srcdir)/src/include/catalog/pg_proc.h
- $(MAKE) -C utils $(notdir $@)
+ $(MAKE) -C utils fmgroids.h fmgrprotos.h
utils/probes.h: utils/probes.d
$(MAKE) -C utils probes.h
@@ -219,7 +226,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 fmgrprotos.h errcodes.h
$(MAKE) -C utils/misc guc-file.c
$(MAKE) -C utils/sort qsort_tuple.c
diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile
index 4b97f838036..f14febdbda0 100644
--- a/src/backend/parser/Makefile
+++ b/src/backend/parser/Makefile
@@ -23,12 +23,17 @@ include $(top_srcdir)/src/backend/common.mk
# 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 e1b787e838f..8179f6dceb5 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 efb8b53f494..e296e6ce4d5 100644
--- a/src/backend/utils/Makefile
+++ b/src/backend/utils/Makefile
@@ -20,9 +20,12 @@ all: errcodes.h fmgroids.h fmgrprotos.h probes.h
$(SUBDIRS:%=%-recursive): fmgroids.h fmgrprotos.h
-# see explanation in ../parser/Makefile
-fmgrprotos.h: fmgroids.h ;
-fmgroids.h: fmgrtab.c ;
+# see notes in src/backend/parser/Makefile
+fmgrprotos.h: fmgroids.h
+ touch $@
+
+fmgroids.h: fmgrtab.c
+ touch $@
fmgrtab.c: Gen_fmgrtab.pl $(catalogdir)/Catalog.pm $(top_srcdir)/src/include/catalog/pg_proc.h
$(PERL) -I $(catalogdir) $< -I $(top_srcdir)/src/include/ $(top_srcdir)/src/include/catalog/pg_proc.h