Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9bf28f9

Browse files
committed
Rearrange makefile rules for running Gen_fmgrtab.pl.
Make these rules look more like the ones associated with genbki.pl, to wit: * Use a stamp file to record when we last ran the script, instead of relying on the timestamps of the individual output files. * Take the knowledge out of backend/Makefile and put it in utils/Makefile where it belongs. I moved down the handling of errcodes.h and probes.h too, although those continue to be built by separate processes. In itself, this is just much-needed cleanup with little practical effect. However, by decoupling these makefile rules from the timestamps of the generated header files, we open the door to not advancing those timestamps unnecessarily, which will be taken advantage of by the next commit. msvc/Solution.pm should be taught to do things similarly, but I'll leave that for another commit. Discussion: https://postgr.es/m/16925.1525376229@sss.pgh.pa.us
1 parent fa03769 commit 9bf28f9

File tree

6 files changed

+48
-54
lines changed

6 files changed

+48
-54
lines changed

src/backend/Makefile

+9-40
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ endif
5353

5454
##########################################################################
5555

56-
all: submake-libpgport submake-catalog-headers postgres $(POSTGRES_IMP)
56+
all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
5757

5858
ifneq ($(PORTNAME), cygwin)
5959
ifneq ($(PORTNAME), win32)
@@ -136,24 +136,15 @@ parser/gram.h: parser/gram.y
136136
storage/lmgr/lwlocknames.h: storage/lmgr/generate-lwlocknames.pl storage/lmgr/lwlocknames.txt
137137
$(MAKE) -C storage/lmgr lwlocknames.h lwlocknames.c
138138

139-
utils/errcodes.h: utils/generate-errcodes.pl utils/errcodes.txt
140-
$(MAKE) -C utils errcodes.h
141-
142-
# see notes in src/backend/parser/Makefile
143-
utils/fmgrprotos.h: utils/fmgroids.h
144-
touch $@
145-
146-
utils/fmgroids.h: utils/Gen_fmgrtab.pl catalog/Catalog.pm $(top_srcdir)/src/include/catalog/pg_proc.dat $(top_srcdir)/src/include/access/transam.h
147-
$(MAKE) -C utils fmgroids.h fmgrprotos.h
148-
149-
utils/probes.h: utils/probes.d
150-
$(MAKE) -C utils probes.h
151-
152139
# run this unconditionally to avoid needing to know its dependencies here:
153140
submake-catalog-headers:
154141
$(MAKE) -C catalog distprep generated-header-symlinks
155142

156-
.PHONY: submake-catalog-headers
143+
# run this unconditionally to avoid needing to know its dependencies here:
144+
submake-utils-headers:
145+
$(MAKE) -C utils distprep generated-header-symlinks
146+
147+
.PHONY: submake-catalog-headers submake-utils-headers
157148

158149
# Make symlinks for these headers in the include directory. That way
159150
# we can cut down on the -I options. Also, a symlink is automatically
@@ -168,7 +159,7 @@ submake-catalog-headers:
168159

169160
.PHONY: generated-headers
170161

171-
generated-headers: $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/fmgrprotos.h $(top_builddir)/src/include/utils/probes.h submake-catalog-headers
162+
generated-headers: $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/storage/lwlocknames.h submake-catalog-headers submake-utils-headers
172163

173164
$(top_builddir)/src/include/parser/gram.h: parser/gram.h
174165
prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
@@ -180,25 +171,6 @@ $(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
180171
cd '$(dir $@)' && rm -f $(notdir $@) && \
181172
$(LN_S) "$$prereqdir/$(notdir $<)" .
182173

183-
$(top_builddir)/src/include/utils/errcodes.h: utils/errcodes.h
184-
prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
185-
cd '$(dir $@)' && rm -f $(notdir $@) && \
186-
$(LN_S) "$$prereqdir/$(notdir $<)" .
187-
188-
$(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
189-
prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
190-
cd '$(dir $@)' && rm -f $(notdir $@) && \
191-
$(LN_S) "$$prereqdir/$(notdir $<)" .
192-
193-
$(top_builddir)/src/include/utils/fmgrprotos.h: utils/fmgrprotos.h
194-
prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
195-
cd '$(dir $@)' && rm -f $(notdir $@) && \
196-
$(LN_S) "$$prereqdir/$(notdir $<)" .
197-
198-
$(top_builddir)/src/include/utils/probes.h: utils/probes.h
199-
cd '$(dir $@)' && rm -f $(notdir $@) && \
200-
$(LN_S) "../../../$(subdir)/utils/probes.h" .
201-
202174

203175
utils/probes.o: utils/probes.d $(SUBDIROBJS)
204176
$(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
@@ -213,7 +185,7 @@ distprep:
213185
$(MAKE) -C catalog distprep
214186
$(MAKE) -C replication repl_gram.c repl_scanner.c syncrep_gram.c syncrep_scanner.c
215187
$(MAKE) -C storage/lmgr lwlocknames.h lwlocknames.c
216-
$(MAKE) -C utils fmgrtab.c fmgroids.h fmgrprotos.h errcodes.h
188+
$(MAKE) -C utils distprep
217189
$(MAKE) -C utils/misc guc-file.c
218190
$(MAKE) -C utils/sort qsort_tuple.c
219191

@@ -325,6 +297,7 @@ distclean: clean
325297

326298
maintainer-clean: distclean
327299
$(MAKE) -C catalog $@
300+
$(MAKE) -C utils $@
328301
rm -f bootstrap/bootparse.c \
329302
bootstrap/bootscanner.c \
330303
parser/gram.c \
@@ -336,10 +309,6 @@ maintainer-clean: distclean
336309
replication/syncrep_scanner.c \
337310
storage/lmgr/lwlocknames.c \
338311
storage/lmgr/lwlocknames.h \
339-
utils/fmgroids.h \
340-
utils/fmgrprotos.h \
341-
utils/fmgrtab.c \
342-
utils/errcodes.h \
343312
utils/misc/guc-file.c \
344313
utils/sort/qsort_tuple.c
345314

src/backend/catalog/Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ distprep: bki-stamp
7979

8080
generated-header-symlinks: $(top_builddir)/src/include/catalog/header-stamp
8181

82+
# bki-stamp records the last time we ran genbki.pl. We don't rely on
83+
# the timestamps of the individual output files, because the Perl script
84+
# won't update them if they didn't change (to avoid unnecessary recompiles).
8285
# Technically, this should depend on Makefile.global which supplies
83-
# $(MAJORVERSION); but then postgres.bki would need to be rebuilt after every
86+
# $(MAJORVERSION); but then genbki.pl would need to be re-run after every
8487
# configure run, even in distribution tarballs. So depending on configure.in
8588
# instead is cheating a bit, but it will achieve the goal of updating the
8689
# version number when it changes.

src/backend/utils/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/fmgrtab.c
22
/fmgroids.h
33
/fmgrprotos.h
4+
/fmgr-stamp
45
/probes.h
56
/errcodes.h

src/backend/utils/Makefile

+32-12
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,26 @@ catalogdir = $(top_srcdir)/src/backend/catalog
2121

2222
include $(top_srcdir)/src/backend/common.mk
2323

24-
all: errcodes.h fmgroids.h fmgrprotos.h probes.h
24+
all: distprep probes.h generated-header-symlinks
2525

26-
$(SUBDIRS:%=%-recursive): fmgroids.h fmgrprotos.h
26+
distprep: fmgr-stamp errcodes.h
27+
28+
.PHONY: generated-header-symlinks
29+
30+
generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp $(top_builddir)/src/include/utils/probes.h
31+
32+
$(SUBDIRS:%=%-recursive): fmgr-stamp errcodes.h
2733

2834
FMGR_DATA := $(addprefix $(top_srcdir)/src/include/catalog/,\
2935
pg_language.dat pg_proc.dat \
3036
)
3137

32-
# see notes in src/backend/parser/Makefile
33-
fmgrprotos.h: fmgroids.h
34-
touch $@
35-
36-
fmgroids.h: fmgrtab.c
37-
touch $@
38-
39-
fmgrtab.c: Gen_fmgrtab.pl $(catalogdir)/Catalog.pm $(FMGR_DATA) $(top_srcdir)/src/include/access/transam.h
38+
# fmgr-stamp records the last time we ran Gen_fmgrtab.pl. We don't rely on
39+
# the timestamps of the individual output files, because the Perl script
40+
# won't update them if they didn't change (to avoid unnecessary recompiles).
41+
fmgr-stamp: Gen_fmgrtab.pl $(catalogdir)/Catalog.pm $(FMGR_DATA) $(top_srcdir)/src/include/access/transam.h
4042
$(PERL) -I $(catalogdir) $< -I $(top_srcdir)/src/include/ $(FMGR_DATA)
43+
touch $@
4144

4245
errcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-errcodes.pl
4346
$(PERL) $(srcdir)/generate-errcodes.pl $< > $@
@@ -55,6 +58,23 @@ else
5558
sed -f $(srcdir)/Gen_dummy_probes.sed $< >$@
5659
endif
5760

61+
# These generated headers must be symlinked into builddir/src/include/,
62+
# using absolute links for the reasons explained in src/backend/Makefile.
63+
# We use header-stamp to record that we've done this because the symlinks
64+
# themselves may appear older than fmgr-stamp.
65+
$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h
66+
prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
67+
cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h; do \
68+
rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
69+
done
70+
touch $@
71+
72+
# probes.h is handled differently because it's not in the distribution tarball.
73+
$(top_builddir)/src/include/utils/probes.h: probes.h
74+
cd '$(dir $@)' && rm -f $(notdir $@) && \
75+
$(LN_S) "../../../$(subdir)/probes.h" .
76+
77+
5878
.PHONY: install-data
5979
install-data: errcodes.txt installdirs
6080
$(INSTALL_DATA) $(srcdir)/errcodes.txt '$(DESTDIR)$(datadir)/errcodes.txt'
@@ -66,10 +86,10 @@ installdirs:
6686
uninstall-data:
6787
rm -f $(addprefix '$(DESTDIR)$(datadir)'/, errcodes.txt)
6888

69-
# fmgroids.h, fmgrprotos.h, fmgrtab.c and errcodes.h are in the
89+
# fmgroids.h, fmgrprotos.h, fmgrtab.c, fmgr-stamp, and errcodes.h are in the
7090
# distribution tarball, so they are not cleaned here.
7191
clean:
7292
rm -f probes.h
7393

7494
maintainer-clean: clean
75-
rm -f fmgroids.h fmgrprotos.h fmgrtab.c errcodes.h
95+
rm -f fmgroids.h fmgrprotos.h fmgrtab.c fmgr-stamp errcodes.h

src/include/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ uninstall:
7777

7878

7979
clean:
80-
rm -f utils/fmgroids.h utils/fmgrprotos.h utils/errcodes.h
80+
rm -f utils/fmgroids.h utils/fmgrprotos.h utils/errcodes.h utils/header-stamp
8181
rm -f parser/gram.h storage/lwlocknames.h utils/probes.h
8282
rm -f catalog/schemapg.h catalog/pg_*_d.h catalog/header-stamp
8383

src/include/utils/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/fmgrprotos.h
33
/probes.h
44
/errcodes.h
5+
/header-stamp

0 commit comments

Comments
 (0)