diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2018-05-03 17:54:18 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2018-05-03 17:54:18 -0400 |
commit | 9bf28f96c7eb0c3630ef034679c426c2ee289aca (patch) | |
tree | 71a87ded31406cb2da2df9fd64e83dfa06ec5285 /src/backend/utils | |
parent | fa03769e4c4bf0911da71fba2501006b05ea195a (diff) | |
download | postgresql-9bf28f96c7eb0c3630ef034679c426c2ee289aca.tar.gz postgresql-9bf28f96c7eb0c3630ef034679c426c2ee289aca.zip |
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
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/.gitignore | 1 | ||||
-rw-r--r-- | src/backend/utils/Makefile | 44 |
2 files changed, 33 insertions, 12 deletions
diff --git a/src/backend/utils/.gitignore b/src/backend/utils/.gitignore index f26215c6315..06855569594 100644 --- a/src/backend/utils/.gitignore +++ b/src/backend/utils/.gitignore @@ -1,5 +1,6 @@ /fmgrtab.c /fmgroids.h /fmgrprotos.h +/fmgr-stamp /probes.h /errcodes.h diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile index 343637af858..966e3bc2ed3 100644 --- a/src/backend/utils/Makefile +++ b/src/backend/utils/Makefile @@ -21,23 +21,26 @@ catalogdir = $(top_srcdir)/src/backend/catalog include $(top_srcdir)/src/backend/common.mk -all: errcodes.h fmgroids.h fmgrprotos.h probes.h +all: distprep probes.h generated-header-symlinks -$(SUBDIRS:%=%-recursive): fmgroids.h fmgrprotos.h +distprep: fmgr-stamp errcodes.h + +.PHONY: generated-header-symlinks + +generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp $(top_builddir)/src/include/utils/probes.h + +$(SUBDIRS:%=%-recursive): fmgr-stamp errcodes.h FMGR_DATA := $(addprefix $(top_srcdir)/src/include/catalog/,\ pg_language.dat pg_proc.dat \ ) -# 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 $(FMGR_DATA) $(top_srcdir)/src/include/access/transam.h +# fmgr-stamp records the last time we ran Gen_fmgrtab.pl. We don't rely on +# the timestamps of the individual output files, because the Perl script +# won't update them if they didn't change (to avoid unnecessary recompiles). +fmgr-stamp: Gen_fmgrtab.pl $(catalogdir)/Catalog.pm $(FMGR_DATA) $(top_srcdir)/src/include/access/transam.h $(PERL) -I $(catalogdir) $< -I $(top_srcdir)/src/include/ $(FMGR_DATA) + touch $@ errcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-errcodes.pl $(PERL) $(srcdir)/generate-errcodes.pl $< > $@ @@ -55,6 +58,23 @@ else sed -f $(srcdir)/Gen_dummy_probes.sed $< >$@ endif +# These generated headers must be symlinked into builddir/src/include/, +# using absolute links for the reasons explained in src/backend/Makefile. +# We use header-stamp to record that we've done this because the symlinks +# themselves may appear older than fmgr-stamp. +$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h + prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \ + cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h; do \ + rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \ + done + touch $@ + +# probes.h is handled differently because it's not in the distribution tarball. +$(top_builddir)/src/include/utils/probes.h: probes.h + cd '$(dir $@)' && rm -f $(notdir $@) && \ + $(LN_S) "../../../$(subdir)/probes.h" . + + .PHONY: install-data install-data: errcodes.txt installdirs $(INSTALL_DATA) $(srcdir)/errcodes.txt '$(DESTDIR)$(datadir)/errcodes.txt' @@ -66,10 +86,10 @@ installdirs: uninstall-data: rm -f $(addprefix '$(DESTDIR)$(datadir)'/, errcodes.txt) -# fmgroids.h, fmgrprotos.h, fmgrtab.c and errcodes.h are in the +# fmgroids.h, fmgrprotos.h, fmgrtab.c, fmgr-stamp, and errcodes.h are in the # distribution tarball, so they are not cleaned here. clean: rm -f probes.h maintainer-clean: clean - rm -f fmgroids.h fmgrprotos.h fmgrtab.c errcodes.h + rm -f fmgroids.h fmgrprotos.h fmgrtab.c fmgr-stamp errcodes.h |