With the makefile rules, the output of genbki.pl was written to
src/backend/catalog/, and then the header files were linked to
src/include/catalog/.
This patch changes it so that the output files are written directly to
src/include/catalog/. This makes the logic simpler, and it also makes
the behavior consistent with the meson build system. For example, a
file like schemapg.h is now mentioned only in
src/include/catalog/{meson.build,Makefile,.gitignore}
where before it was mentioned in (checks ...)
src/backend/catalog/.gitignore
src/backend/catalog/Makefile
src/include/Makefile
src/include/catalog/.gitignore
src/include/catalog/meson.build
Also, the list of catalog files is now kept in parallel in
src/include/catalog/{meson.build,Makefile}, while before the makefiles
had it in src/backend/catalog/Makefile.
I think keeping the two build systems aligned this way will be useful
for longer-term maintenance.
(There are other generated header files that are linked in a similar way
and could perhaps be simplified. But they don't all work the same way.
Some of the scripts also generate .c files, for example, so they need to
put some stuff under src/backend/. So I restricted this patch to
src/{backend,include}/catalog/, especially because it would be good to
keep the catalog lists aligned.)From e9f3bfeeff47d96c2557836e7c964adba2d9edb5 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 8 Feb 2024 08:31:21 +0100
Subject: [PATCH] Put genbki.pl output into src/include/catalog/ directly
With the makefile rules, the output of genbki.pl was written to
src/backend/catalog/, and then the header files were linked to
src/include/catalog/.
This changes it so that the output files are written directly to
src/include/catalog/. This makes the logic simpler, and it also makes
the behavior consistent with the meson build system. Also, the list
of catalog files is now kept in parallel in
src/include/catalog/{meson.build,Makefile}, while before the makefiles
had it in src/backend/catalog/Makefile.
---
src/backend/Makefile | 2 +-
src/backend/catalog/.gitignore | 8 --
src/backend/catalog/Makefile | 140 +-------------------------
src/include/Makefile | 7 +-
src/include/catalog/.gitignore | 4 +-
src/include/catalog/Makefile | 152 +++++++++++++++++++++++++++++
src/include/catalog/meson.build | 3 +-
src/tools/pginclude/cpluspluscheck | 2 -
src/tools/pginclude/headerscheck | 2 -
9 files changed, 163 insertions(+), 157 deletions(-)
delete mode 100644 src/backend/catalog/.gitignore
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 7d2ea7d54a6..6b3c432c545 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -138,7 +138,7 @@ utils/activity/wait_event_types.h:
utils/activity/generate-wait_event_types.pl u
# run this unconditionally to avoid needing to know its dependencies here:
submake-catalog-headers:
- $(MAKE) -C catalog generated-header-symlinks
+ $(MAKE) -C ../include/catalog generated-headers
# run this unconditionally to avoid needing to know its dependencies here:
submake-nodes-headers:
diff --git a/src/backend/catalog/.gitignore b/src/backend/catalog/.gitignore
deleted file mode 100644
index b580f734c71..00000000000
--- a/src/backend/catalog/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-/postgres.bki
-/schemapg.h
-/syscache_ids.h
-/syscache_info.h
-/system_fk_info.h
-/system_constraints.sql
-/pg_*_d.h
-/bki-stamp
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 196ecafc909..1589a75fd53 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -50,141 +50,8 @@ OBJS = \
include $(top_srcdir)/src/backend/common.mk
-# Note: the order of this list determines the order in which the catalog
-# header files are assembled into postgres.bki. BKI_BOOTSTRAP catalogs
-# must appear first, and pg_statistic before pg_statistic_ext_data, and
-# there are reputedly other, undocumented ordering dependencies.
-CATALOG_HEADERS := \
- pg_proc.h \
- pg_type.h \
- pg_attribute.h \
- pg_class.h \
- pg_attrdef.h \
- pg_constraint.h \
- pg_inherits.h \
- pg_index.h \
- pg_operator.h \
- pg_opfamily.h \
- pg_opclass.h \
- pg_am.h \
- pg_amop.h \
- pg_amproc.h \
- pg_language.h \
- pg_largeobject_metadata.h \
- pg_largeobject.h \
- pg_aggregate.h \
- pg_statistic.h \
- pg_statistic_ext.h \
- pg_statistic_ext_data.h \
- pg_rewrite.h \
- pg_trigger.h \
- pg_event_trigger.h \
- pg_description.h \
- pg_cast.h \
- pg_enum.h \
- pg_namespace.h \
- pg_conversion.h \
- pg_depend.h \
- pg_database.h \
- pg_db_role_setting.h \
- pg_tablespace.h \
- pg_authid.h \
- pg_auth_members.h \
- pg_shdepend.h \
- pg_shdescription.h \
- pg_ts_config.h \
- pg_ts_config_map.h \
- pg_ts_dict.h \
- pg_ts_parser.h \
- pg_ts_template.h \
- pg_extension.h \
- pg_foreign_data_wrapper.h \
- pg_foreign_server.h \
- pg_user_mapping.h \
- pg_foreign_table.h \
- pg_policy.h \
- pg_replication_origin.h \
- pg_default_acl.h \
- pg_init_privs.h \
- pg_seclabel.h \
- pg_shseclabel.h \
- pg_collation.h \
- pg_parameter_acl.h \
- pg_partitioned_table.h \
- pg_range.h \
- pg_transform.h \
- pg_sequence.h \
- pg_publication.h \
- pg_publication_namespace.h \
- pg_publication_rel.h \
- pg_subscription.h \
- pg_subscription_rel.h
-
-GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h syscache_ids.h
syscache_info.h system_fk_info.h
-
-POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,
$(CATALOG_HEADERS))
-
-# The .dat files we need can just be listed alphabetically.
-POSTGRES_BKI_DATA = $(addprefix $(top_srcdir)/src/include/catalog/,\
- pg_aggregate.dat \
- pg_am.dat \
- pg_amop.dat \
- pg_amproc.dat \
- pg_authid.dat \
- pg_cast.dat \
- pg_class.dat \
- pg_collation.dat \
- pg_conversion.dat \
- pg_database.dat \
- pg_language.dat \
- pg_namespace.dat \
- pg_opclass.dat \
- pg_operator.dat \
- pg_opfamily.dat \
- pg_proc.dat \
- pg_range.dat \
- pg_tablespace.dat \
- pg_ts_config.dat \
- pg_ts_config_map.dat \
- pg_ts_dict.dat \
- pg_ts_parser.dat \
- pg_ts_template.dat \
- pg_type.dat \
- )
-
-all: generated-header-symlinks
-
-.PHONY: generated-header-symlinks
-
-generated-header-symlinks: $(top_builddir)/src/include/catalog/header-stamp
-
-# bki-stamp records the last time we ran genbki.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).
-# Technically, this should depend on Makefile.global which supplies
-# $(MAJORVERSION); but then genbki.pl would need to be re-run after every
-# configure run, even in distribution tarballs. So depending on configure.ac
-# instead is cheating a bit, but it will achieve the goal of updating the
-# version number when it changes.
-bki-stamp: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA)
$(top_srcdir)/configure.ac $(top_srcdir)/src/include/access/transam.h
- $(PERL) $< --include-path=$(top_srcdir)/src/include/ \
- --set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
- touch $@
-
-# The generated headers must all be symlinked into src/include/.
-# We use header-stamp to record that we've done this because the symlinks
-# themselves may appear older than bki-stamp.
-$(top_builddir)/src/include/catalog/header-stamp: bki-stamp
- cd '$(dir $@)' && for file in $(GENERATED_HEADERS); do \
- rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
- done
- touch $@
-
-# Note: installation of generated headers is handled elsewhere
.PHONY: install-data
-install-data: bki-stamp installdirs
- $(INSTALL_DATA) postgres.bki '$(DESTDIR)$(datadir)/postgres.bki'
- $(INSTALL_DATA) system_constraints.sql
'$(DESTDIR)$(datadir)/system_constraints.sql'
+install-data: installdirs
$(INSTALL_DATA) $(srcdir)/system_functions.sql
'$(DESTDIR)$(datadir)/system_functions.sql'
$(INSTALL_DATA) $(srcdir)/system_views.sql
'$(DESTDIR)$(datadir)/system_views.sql'
$(INSTALL_DATA) $(srcdir)/information_schema.sql
'$(DESTDIR)$(datadir)/information_schema.sql'
@@ -195,7 +62,4 @@ installdirs:
.PHONY: uninstall-data
uninstall-data:
- rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki
system_constraints.sql system_functions.sql system_views.sql
information_schema.sql sql_features.txt)
-
-clean:
- rm -f bki-stamp postgres.bki system_constraints.sql $(GENERATED_HEADERS)
+ rm -f $(addprefix '$(DESTDIR)$(datadir)'/, system_functions.sql
system_views.sql information_schema.sql sql_features.txt)
diff --git a/src/include/Makefile b/src/include/Makefile
index 584d0300d98..b8b576a4de3 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -54,10 +54,11 @@ install: all installdirs
$(INSTALL_DATA) $(srcdir)/$$dir/*.h
'$(DESTDIR)$(includedir_server)'/$$dir || exit; \
done
ifeq ($(vpath_build),yes)
- for file in catalog/schemapg.h catalog/syscache_ids.h
catalog/system_fk_info.h catalog/pg_*_d.h storage/lwlocknames.h utils/probes.h
utils/wait_event_types.h; do \
+ for file in storage/lwlocknames.h utils/probes.h
utils/wait_event_types.h; do \
$(INSTALL_DATA) $$file '$(DESTDIR)$(includedir_server)'/$$file ||
exit; \
done
endif
+ $(MAKE) -C catalog install
installdirs:
$(MKDIR_P) '$(DESTDIR)$(includedir)/libpq'
'$(DESTDIR)$(includedir_internal)/libpq'
@@ -69,14 +70,14 @@ uninstall:
rm -f $(addprefix '$(DESTDIR)$(includedir_internal)'/, c.h port.h
postgres_fe.h libpq/pqcomm.h libpq/protocol.h)
# heuristic...
rm -rf $(addprefix '$(DESTDIR)$(includedir_server)'/, $(SUBDIRS) *.h)
+ $(MAKE) -C catalog uninstall
clean:
rm -f utils/fmgroids.h utils/fmgrprotos.h utils/errcodes.h
utils/header-stamp
rm -f storage/lwlocknames.h utils/probes.h utils/wait_event_types.h
- rm -f catalog/schemapg.h catalog/syscache_ids.h catalog/syscache_info.h
catalog/system_fk_info.h
- rm -f catalog/pg_*_d.h catalog/header-stamp
rm -f nodes/nodetags.h nodes/header-stamp
+ $(MAKE) -C catalog clean
distclean: clean
rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/include/catalog/.gitignore b/src/include/catalog/.gitignore
index 983574f2c4d..b580f734c71 100644
--- a/src/include/catalog/.gitignore
+++ b/src/include/catalog/.gitignore
@@ -1,6 +1,8 @@
+/postgres.bki
/schemapg.h
/syscache_ids.h
/syscache_info.h
/system_fk_info.h
+/system_constraints.sql
/pg_*_d.h
-/header-stamp
+/bki-stamp
diff --git a/src/include/catalog/Makefile b/src/include/catalog/Makefile
index c2b3cf238db..167f91a6e3f 100644
--- a/src/include/catalog/Makefile
+++ b/src/include/catalog/Makefile
@@ -13,6 +13,158 @@ subdir = src/include/catalog
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
+# Note: the order of this list determines the order in which the catalog
+# header files are assembled into postgres.bki. BKI_BOOTSTRAP catalogs
+# must appear first, and pg_statistic before pg_statistic_ext_data, and
+# there are reputedly other, undocumented ordering dependencies.
+CATALOG_HEADERS := \
+ pg_proc.h \
+ pg_type.h \
+ pg_attribute.h \
+ pg_class.h \
+ pg_attrdef.h \
+ pg_constraint.h \
+ pg_inherits.h \
+ pg_index.h \
+ pg_operator.h \
+ pg_opfamily.h \
+ pg_opclass.h \
+ pg_am.h \
+ pg_amop.h \
+ pg_amproc.h \
+ pg_language.h \
+ pg_largeobject_metadata.h \
+ pg_largeobject.h \
+ pg_aggregate.h \
+ pg_statistic.h \
+ pg_statistic_ext.h \
+ pg_statistic_ext_data.h \
+ pg_rewrite.h \
+ pg_trigger.h \
+ pg_event_trigger.h \
+ pg_description.h \
+ pg_cast.h \
+ pg_enum.h \
+ pg_namespace.h \
+ pg_conversion.h \
+ pg_depend.h \
+ pg_database.h \
+ pg_db_role_setting.h \
+ pg_tablespace.h \
+ pg_authid.h \
+ pg_auth_members.h \
+ pg_shdepend.h \
+ pg_shdescription.h \
+ pg_ts_config.h \
+ pg_ts_config_map.h \
+ pg_ts_dict.h \
+ pg_ts_parser.h \
+ pg_ts_template.h \
+ pg_extension.h \
+ pg_foreign_data_wrapper.h \
+ pg_foreign_server.h \
+ pg_user_mapping.h \
+ pg_foreign_table.h \
+ pg_policy.h \
+ pg_replication_origin.h \
+ pg_default_acl.h \
+ pg_init_privs.h \
+ pg_seclabel.h \
+ pg_shseclabel.h \
+ pg_collation.h \
+ pg_parameter_acl.h \
+ pg_partitioned_table.h \
+ pg_range.h \
+ pg_transform.h \
+ pg_sequence.h \
+ pg_publication.h \
+ pg_publication_namespace.h \
+ pg_publication_rel.h \
+ pg_subscription.h \
+ pg_subscription_rel.h
+
+GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h)
+
+POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,
$(CATALOG_HEADERS))
+
+# The .dat files we need can just be listed alphabetically.
+POSTGRES_BKI_DATA = \
+ pg_aggregate.dat \
+ pg_am.dat \
+ pg_amop.dat \
+ pg_amproc.dat \
+ pg_authid.dat \
+ pg_cast.dat \
+ pg_class.dat \
+ pg_collation.dat \
+ pg_conversion.dat \
+ pg_database.dat \
+ pg_language.dat \
+ pg_namespace.dat \
+ pg_opclass.dat \
+ pg_operator.dat \
+ pg_opfamily.dat \
+ pg_proc.dat \
+ pg_range.dat \
+ pg_tablespace.dat \
+ pg_ts_config.dat \
+ pg_ts_config_map.dat \
+ pg_ts_dict.dat \
+ pg_ts_parser.dat \
+ pg_ts_template.dat \
+ pg_type.dat
+
+GENBKI_OUTPUT_FILES = \
+ $(GENERATED_HEADERS) \
+ postgres.bki \
+ system_constraints.sql \
+ schemapg.h \
+ syscache_ids.h \
+ syscache_info.h \
+ system_fk_info.h
+
+all: generated-headers
+
+.PHONY: generated-headers
+
+generated-headers: bki-stamp
+
+# bki-stamp records the last time we ran genbki.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).
+# Technically, this should depend on Makefile.global which supplies
+# $(MAJORVERSION); but then genbki.pl would need to be re-run after every
+# configure run, even in distribution tarballs. So depending on configure.ac
+# instead is cheating a bit, but it will achieve the goal of updating the
+# version number when it changes.
+bki-stamp: $(top_srcdir)/src/backend/catalog/genbki.pl
$(top_srcdir)/src/backend/catalog/Catalog.pm $(POSTGRES_BKI_SRCS)
$(POSTGRES_BKI_DATA) $(top_srcdir)/configure.ac
$(top_srcdir)/src/include/access/transam.h
+ $(PERL) $< --include-path=$(top_srcdir)/src/include/ \
+ --set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
+ touch $@
+
+install: all installdirs
+ $(INSTALL_DATA) postgres.bki '$(DESTDIR)$(datadir)/postgres.bki'
+ $(INSTALL_DATA) system_constraints.sql
'$(DESTDIR)$(datadir)/system_constraints.sql'
+# In non-vpath builds, src/include/Makefile already installs all headers.
+ifeq ($(vpath_build),yes)
+ $(INSTALL_DATA) schemapg.h
'$(DESTDIR)$(includedir_server)'/catalog/schemapg.h
+ $(INSTALL_DATA) syscache_ids.h
'$(DESTDIR)$(includedir_server)'/catalog/syscache_ids.h
+ $(INSTALL_DATA) system_fk_info.h
'$(DESTDIR)$(includedir_server)'/catalog/system_fk_info.h
+ for file in $(GENERATED_HEADERS); do \
+ $(INSTALL_DATA) $$file
'$(DESTDIR)$(includedir_server)'/catalog/$$file || exit; \
+ done
+endif
+
+installdirs:
+ $(MKDIR_P) '$(DESTDIR)$(datadir)' '$(DESTDIR)$(includedir_server)'
+
+uninstall:
+ rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki
system_constraints.sql)
+ rm -f $(addprefix '$(DESTDIR)$(includedir_server)'/catalog/, schemapg.h
syscache_ids.h system_fk_info.h $(GENERATED_HEADERS))
+
+clean:
+ rm -f bki-stamp $(GENBKI_OUTPUT_FILES)
+
# 'make reformat-dat-files' is a convenience target for rewriting the
# catalog data files in our standard format. This includes collapsing
# out any entries that are redundant with a BKI_DEFAULT annotation.
diff --git a/src/include/catalog/meson.build b/src/include/catalog/meson.build
index 6b3c56c20e8..f70d1daba52 100644
--- a/src/include/catalog/meson.build
+++ b/src/include/catalog/meson.build
@@ -145,8 +145,7 @@ generated_catalog_headers =
custom_target('generated_catalog_headers',
generated_headers += generated_catalog_headers.to_list()
# autoconf generates the file there, ensure we get a conflict
-generated_sources_ac += {'src/backend/catalog': output_files + ['bki-stamp']}
-generated_sources_ac += {'src/include/catalog': ['header-stamp']}
+generated_sources_ac += {'src/include/catalog': output_files + ['bki-stamp']}
# 'reformat-dat-files' is a convenience target for rewriting the
# catalog data files in our standard format. This includes collapsing
diff --git a/src/tools/pginclude/cpluspluscheck
b/src/tools/pginclude/cpluspluscheck
index 7edfc44b49a..404c6584b16 100755
--- a/src/tools/pginclude/cpluspluscheck
+++ b/src/tools/pginclude/cpluspluscheck
@@ -119,8 +119,6 @@ do
test "$f" = src/include/common/unicode_nonspacing_table.h && continue
test "$f" = src/include/common/unicode_east_asian_fw_table.h && continue
- test "$f" = src/backend/catalog/syscache_ids.h && continue
- test "$f" = src/backend/catalog/syscache_info.h && continue
test "$f" = src/include/catalog/syscache_ids.h && continue
test "$f" = src/include/catalog/syscache_info.h && continue
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 84b892b5c51..a5299bf459f 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -114,8 +114,6 @@ do
test "$f" = src/include/common/unicode_nonspacing_table.h && continue
test "$f" = src/include/common/unicode_east_asian_fw_table.h && continue
- test "$f" = src/backend/catalog/syscache_ids.h && continue
- test "$f" = src/backend/catalog/syscache_info.h && continue
test "$f" = src/include/catalog/syscache_ids.h && continue
test "$f" = src/include/catalog/syscache_info.h && continue
base-commit: 25799850867292efecf34da73db4ea1ad1aad573
--
2.43.0