Hi,

I really like the idea of an 'help' target that prints the targets. It seemed
annoying to document such targets in both the sgml docs and the input for a
the help target. Particularly due to the redundancies between id attributes,
the target name etc.

First I generated the list of targets from within meson.build, only to later
realize that that would not work when building the docs via make. So I instead
added doc/src/sgml/meson-targets.txt which is lightly postprocessed for the
'help' target, and slightly more processed when building the docs.

That does have some downsides, e.g. it'd be more complicated to only print
targets if a relevant option is enabled. But I think it's acceptable that way.


Example output:

$ ninja help
[0/1 1   0%] Running external command help (wrapped by meson to set env)
Code Targets:
  all                          Build everything other than documentation
  backend                      Build backend and related modules
  bin                          Build frontend binaries
  contrib                      Build contrib modules
  pl                           Build procedual languages

Documentation Targets:
  docs                         Build documentation in multi-page HTML format
  doc-html                     Build documentation in multi-page HTML format
  doc-man                      Build documentation in man page format
  doc/src/sgml/postgres-A4.pdf Build documentation in PDF format, with A4 pages
  doc/src/sgml/postgres-US.pdf Build documentation in PDF format, with US 
letter pages
  doc/src/sgml/postgres.html   Build documentation in single-page HTML format
  alldocs                      Build documentation in all supported formats

Installation Targets:
  install                      Install postgres, excluding documentation
  install-doc-html             Install documentation in multi-page HTML format
  install-doc-man              Install documentation in man page format
  install-docs                 Install documentation in multi-page HTML and man 
page formats
  install-quiet                Like "install", but installed files are not 
displayed
  install-world                Install postgres, including multi-page HTML and 
man page documentation
  uninstall                    Remove installed files

Other Targets:
  clean                        Remove all build products
  test                         Run all enabled tests (including contrib)
  world                        Build everything, including documentation
  help                         List important targets


Because of the common source, some of the descriptions in the state of this
patch are a bit shorter than in the preceding commit. But I don't think that
hurts much.

Greetings,

Andres Freund
>From 9b0b5cd952880ecebbd157c05698125755bc53ed Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Wed, 8 Nov 2023 09:29:38 -0800
Subject: [PATCH v2 1/7] meson: Change default of 'selinux' feature option to
 auto

There is really no reason for selinux to behave differently than other
options.

Author:
Reviewed-by:
Discussion: https://postgr.es/m/20231103211601.bgqx3cfq6pz2l...@awork3.anarazel.de
Backpatch:
---
 meson_options.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson_options.txt b/meson_options.txt
index d2f95cfec36..be1b327f544 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -136,7 +136,7 @@ option('tcl_version', type: 'string', value: 'tcl',
 option('readline', type: 'feature', value: 'auto',
   description: 'Use GNU Readline or BSD Libedit for editing')
 
-option('selinux', type: 'feature', value: 'disabled',
+option('selinux', type: 'feature', value: 'auto',
   description: 'SELinux support')
 
 option('ssl', type: 'combo', choices: ['auto', 'none', 'openssl'],
-- 
2.38.0

>From a2aa43811296c92a8d4611c996d4aebcf1b88f31 Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Fri, 3 Nov 2023 10:21:13 -0700
Subject: [PATCH v2 2/7] docs: Document --with-selinux/-Dselinux options
 centrally

Previously --with-selinux was documented for autoconf in the sepgsql
documentation and not at all for meson. There are further improvements related
to this that could be made, but this seems like a clear improvement.

Author:
Reviewed-by:
Reported-by: Christoph Berg <m...@debian.org>
Discussion: https://postgr.es/m/20231103163848.26egkh5qdgw3v...@awork3.anarazel.de
Backpatch:
---
 doc/src/sgml/installation.sgml | 21 +++++++++++++++++++++
 doc/src/sgml/sepgsql.sgml      | 11 ++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index a3dc6eb855f..1bfb27fd38d 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -1198,6 +1198,16 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
+      <varlistentry id="configure-option-with-sepgsql">
+       <term><option>--with-selinux</option></term>
+       <listitem>
+        <para>
+         Build with selinux support, enabling the <xref linkend="sepgsql"/>
+         extension.
+        </para>
+       </listitem>
+      </varlistentry>
+
      </variablelist>
 
    </sect3>
@@ -2629,6 +2639,17 @@ ninja install
        </para>
       </listitem>
      </varlistentry>
+
+     <varlistentry id="configure-with-sepgsql-meson">
+      <term><option>-Dselinux={ auto | enabled | disabled }</option></term>
+      <listitem>
+       <para>
+        Build with selinux support, enabling the <xref linkend="sepgsql"/>
+        extension.  Defaults to auto.
+       </para>
+      </listitem>
+     </varlistentry>
+
     </variablelist>
    </sect3>
 
diff --git a/doc/src/sgml/sepgsql.sgml b/doc/src/sgml/sepgsql.sgml
index b368e587cbf..1b848f1977c 100644
--- a/doc/src/sgml/sepgsql.sgml
+++ b/doc/src/sgml/sepgsql.sgml
@@ -87,9 +87,14 @@ Policy from config file:        targeted
   </para>
 
   <para>
-   To build this module, include the option <literal>--with-selinux</literal> in
-   your PostgreSQL <literal>configure</literal> command.  Be sure that the
-   <filename>libselinux-devel</filename> RPM is installed at build time.
+   To build this module specify <xref
+   linkend="configure-option-with-sepgsql"/> (when using <link
+   linkend="install-make">make and autoconf</link> ) or <xref
+   linkend="configure-with-sepgsql-meson"/> (when using <link
+   linkend="install-meson">meson</link>).
+
+   Be sure that the <filename>libselinux-devel</filename> RPM is installed at
+   build time.
   </para>
 
   <para>
-- 
2.38.0

>From a8dc88cf6247a07b02dbef61e9ae7ef30af50131 Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Fri, 3 Nov 2023 11:59:25 -0700
Subject: [PATCH v2 3/7] meson: docs: Add doc-{html,man} targets

Reviewed-by: Christoph Berg <m...@debian.org>
Discussion: https://postgr.es/m/20231103163848.26egkh5qdgw3v...@awork3.anarazel.de
---
 doc/src/sgml/meson.build | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/doc/src/sgml/meson.build b/doc/src/sgml/meson.build
index 90e2c062fa8..fac7e701610 100644
--- a/doc/src/sgml/meson.build
+++ b/doc/src/sgml/meson.build
@@ -142,6 +142,7 @@ if docs_dep.found()
       '--install-dir-contents', dir_doc_html, html],
     build_always_stale: true, build_by_default: false,
   )
+  alias_target('doc-html', html)
   alias_target('install-doc-html', install_doc_html)
 
   # build and install multi-page html docs as part of docs target
@@ -231,6 +232,8 @@ if docs_dep.found()
       '--install-dirs', dir_man, '@INPUT@'],
     build_always_stale: true, build_by_default: false,
   )
+
+  alias_target('doc-man', man)
   alias_target('install-doc-man', install_doc_man)
 
   # even though we don't want to build man pages as part of 'docs', we do want
-- 
2.38.0

>From 65a248330069d2891ae48912fa2c947217f0c366 Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Wed, 8 Nov 2023 12:39:05 -0800
Subject: [PATCH v2 4/7] meson: Add 'world' target

Author:
Reviewed-by:
Discussion: https://postgr.es/m/
Backpatch:
---
 meson.build | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meson.build b/meson.build
index 88a9d9051fe..5b03e90c3db 100644
--- a/meson.build
+++ b/meson.build
@@ -3326,6 +3326,8 @@ alias_target('bin', bin_targets + [libpq_st])
 alias_target('pl', pl_targets)
 alias_target('contrib', contrib_targets)
 alias_target('testprep', testprep_targets)
+
+alias_target('world', all_built, docs)
 alias_target('install-world', install_quiet, installdocs)
 
 
-- 
2.38.0

>From e8bea2e38093371fad3af9ba65436696d4d01cca Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Fri, 3 Nov 2023 14:06:25 -0700
Subject: [PATCH v2 5/7] docs: meson: Add documentation for important build
 targets

Author:
Reviewed-by: Christoph Berg <m...@debian.org>
Discussion: https://postgr.es/m/20231103163848.26egkh5qdgw3v...@awork3.anarazel.de
Backpatch:
---
 doc/src/sgml/installation.sgml | 244 +++++++++++++++++++++++++++++++++
 1 file changed, 244 insertions(+)

diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 1bfb27fd38d..9dde19224a7 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -3200,6 +3200,250 @@ ninja install
     </variablelist>
    </sect3>
   </sect2>
+
+  <sect2 id="meson-targets">
+   <title><literal>meson</literal> Build Targets</title>
+
+   <para>
+    Individual build targets can be built using <command>ninja</command> <replaceable>target</replaceable>.
+
+    When no target is specified, everything except documentation is
+    built. Individual build products can be built using the path/filename as
+    <replaceable>target</replaceable>.
+   </para>
+
+   <sect3 id="meson-targets-code">
+    <title>Code Targets</title>
+
+    <variablelist>
+
+     <varlistentry id="meson-target-all">
+       <term><option>all</option></term>
+       <listitem>
+        <para>
+         Build everything other than documentation
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-backend">
+       <term><option>backend</option></term>
+       <listitem>
+        <para>
+         Build backend and related modules.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-bin">
+       <term><option>bin</option></term>
+       <listitem>
+        <para>
+         Build frontend binaries.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-contrib">
+       <term><option>contrib</option></term>
+       <listitem>
+        <para>
+         Build contrib modules.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-pl">
+       <term><option>pl</option></term>
+       <listitem>
+        <para>
+         Build procedual languages.
+        </para>
+       </listitem>
+     </varlistentry>
+
+    </variablelist>
+
+   </sect3>
+
+   <sect3 id="meson-targets-install">
+    <title>Install Targets</title>
+
+    <variablelist>
+
+     <varlistentry id="meson-target-install">
+       <term><option>install</option></term>
+       <listitem>
+        <para>
+         Install postgres, excluding documentation.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-install-quiet">
+       <term><option>install-quiet</option></term>
+       <listitem>
+        <para>
+         Like <xref linkend="meson-target-install"/>, but installed
+         files are not displayed.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-install-world">
+       <term><option>install-world</option></term>
+       <listitem>
+        <para>
+         Install postgres, including multi-page HTML and man page
+         documentation.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-install-docs">
+       <term><option>install-docs</option></term>
+       <listitem>
+        <para>
+         Install documentation in multi-page HTML and man page formats. See
+         also <xref linkend="meson-target-install-doc-html"/>, <xref
+         linkend="meson-target-install-doc-man"/>.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-install-doc-html">
+       <term><option>install-doc-html</option></term>
+       <listitem>
+        <para>
+         Install documentation in multi-page HTML format.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-install-doc-man">
+       <term><option>install-doc-man</option></term>
+       <listitem>
+        <para>
+         Install documentation in man page format.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-uninstall">
+       <term><option>uninstall</option></term>
+       <listitem>
+        <para>
+         Remove installed files.
+        </para>
+       </listitem>
+     </varlistentry>
+
+    </variablelist>
+   </sect3>
+
+   <sect3 id="meson-targets-docs">
+    <title>Documentation Targets</title>
+
+    <variablelist>
+
+     <varlistentry id="meson-target-docs">
+       <term><option>docs</option></term>
+       <term><option>doc-html</option></term>
+       <listitem>
+        <para>
+         Build documentation in multi-page HTML format.  Note that
+         <option>docs</option> does <emphasis>not</emphasis> include building
+         man page documentation, as man page generation seldom fails when
+         building HTML documentation succeeds.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-doc-man">
+       <term><option>doc-man</option></term>
+       <listitem>
+        <para>
+         Build documentation in man page format.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-html-single-page">
+      <term><option>doc/src/sgml/postgres.html</option></term>
+       <listitem>
+        <para>
+         Build documentation in single-page HTML format.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-pdf">
+      <term><option>doc/src/sgml/postgres-A4.pdf</option></term>
+      <term><option>doc/src/sgml/postgres-US.pdf</option></term>
+       <listitem>
+        <para>
+         Build documentation in PDF format, using A4 and U.S. letter format
+         respectively.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-alldocs">
+       <term><option>alldocs</option></term>
+       <listitem>
+        <para>
+         Build documentation in all supported formats. Primarily useful when
+         testing larger documentation changes.
+        </para>
+       </listitem>
+     </varlistentry>
+
+    </variablelist>
+
+   </sect3>
+
+   <sect3 id="meson-targets-other">
+    <title>Other Targets</title>
+
+    <variablelist>
+
+     <varlistentry id="meson-target-clean">
+       <term><option>clean</option></term>
+       <listitem>
+        <para>
+         Remove all build products
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry id="meson-target-test">
+       <term><option>test</option></term>
+       <listitem>
+        <para>
+         Run all enabled tests (including contrib). Support for some classes
+         of tests can be enabled / disabled with <xref
+         linkend="configure-tap-tests-meson"/> and <xref
+         linkend="configure-pg-test-extra-meson"/>.
+        </para>
+       </listitem>
+     </varlistentry>
+
+
+     <varlistentry id="meson-target-world">
+       <term><option>world</option></term>
+       <listitem>
+        <para>
+         Build everything, including documentation.
+        </para>
+       </listitem>
+     </varlistentry>
+
+    </variablelist>
+
+   </sect3>
+
+  </sect2>
+
  </sect1>
 
  <sect1 id="install-post">
-- 
2.38.0

>From 619fb4f7b2289bbf2bda9156d866b89451cac70e Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Wed, 8 Nov 2023 15:03:00 -0800
Subject: [PATCH v2 6/7] meson: Add 'help' target, build docs from a common
 source file

Author:
Reviewed-by:
Discussion: https://postgr.es/m/
Backpatch:
---
 meson.build                            |   7 +
 doc/src/sgml/Makefile                  |   3 +
 doc/src/sgml/filelist.sgml             |   1 +
 doc/src/sgml/generate-meson-targets.pl |  63 +++++++
 doc/src/sgml/installation.sgml         | 231 +------------------------
 doc/src/sgml/meson-targets.txt         |  38 ++++
 doc/src/sgml/meson.build               |   9 +
 7 files changed, 122 insertions(+), 230 deletions(-)
 create mode 100644 doc/src/sgml/generate-meson-targets.pl
 create mode 100644 doc/src/sgml/meson-targets.txt

diff --git a/meson.build b/meson.build
index 5b03e90c3db..0f086757e17 100644
--- a/meson.build
+++ b/meson.build
@@ -3330,6 +3330,13 @@ alias_target('testprep', testprep_targets)
 alias_target('world', all_built, docs)
 alias_target('install-world', install_quiet, installdocs)
 
+run_target('help',
+  command: [
+    perl, '-ne', 'next if /^#/; print',
+    files('doc/src/sgml/meson-targets.txt'),
+  ]
+)
+
 
 
 ###############################################################
diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefile
index 49d35dd0d6e..28858f42228 100644
--- a/doc/src/sgml/Makefile
+++ b/doc/src/sgml/Makefile
@@ -110,6 +110,9 @@ keywords-table.sgml: $(top_srcdir)/src/include/parser/kwlist.h $(wildcard $(srcd
 wait_event_types.sgml: $(top_srcdir)/src/backend/utils/activity/wait_event_names.txt $(top_srcdir)/src/backend/utils/activity/generate-wait_event_types.pl
 	$(PERL) $(top_srcdir)/src/backend/utils/activity/generate-wait_event_types.pl --docs $<
 
+meson-targets.sgml: meson-targets.txt $(srcdir)/generate-meson-targets.pl
+	$(PERL) $(srcdir)/generate-meson-targets.pl $^ > $@
+
 ##
 ## Generation of some text files.
 ##
diff --git a/doc/src/sgml/filelist.sgml b/doc/src/sgml/filelist.sgml
index 4c63a7e7689..ed89e75b614 100644
--- a/doc/src/sgml/filelist.sgml
+++ b/doc/src/sgml/filelist.sgml
@@ -38,6 +38,7 @@
 <!ENTITY high-availability      SYSTEM "high-availability.sgml">
 <!ENTITY installbin    SYSTEM "install-binaries.sgml">
 <!ENTITY installation  SYSTEM "installation.sgml">
+<!ENTITY meson-targets  SYSTEM "meson-targets.sgml">
 <!ENTITY installw      SYSTEM "install-windows.sgml">
 <!ENTITY maintenance   SYSTEM "maintenance.sgml">
 <!ENTITY manage-ag     SYSTEM "manage-ag.sgml">
diff --git a/doc/src/sgml/generate-meson-targets.pl b/doc/src/sgml/generate-meson-targets.pl
new file mode 100644
index 00000000000..65314aee282
--- /dev/null
+++ b/doc/src/sgml/generate-meson-targets.pl
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+#
+# Generate the meson-targets.sgml file from meson-targets.txt
+# Copyright (c) 2000-2023, PostgreSQL Global Development Group
+
+use strict;
+use warnings;
+
+my $meson_targets_file = $ARGV[0];
+open my $meson_targets, '<', $meson_targets_file or die;
+
+print
+  "<!-- autogenerated from doc/src/sgml/meson-targets.txt, do not edit -->\n";
+
+# Find the start of each group of targets
+while (<$meson_targets>)
+{
+	next if /^#/;
+
+	if (/^(.*) Targets:$/)
+	{
+		my $targets = $1;
+		my $targets_id = lc $targets;
+
+		print qq(
+<sect3 id="meson-targets-$targets_id">
+ <title>$targets Targets</title>
+
+ <variablelist>
+);
+
+		# Each target in the group
+		while (<$meson_targets>)
+		{
+			next if /^#/;
+			last if !/^\s+([^ ]+)\s+(.+)/;
+
+			my $target = $1;
+			my $desc = $2;
+			my $target_id = $1;
+
+			$target_id =~ s/\//-/g;
+
+			print qq(
+  <varlistentry id="meson-target-${target_id}">
+    <term><option>${target}</option></term>
+    <listitem>
+     <para>
+      ${desc}
+     </para>
+    </listitem>
+  </varlistentry>
+);
+		}
+
+		print qq(
+ </variablelist>
+</sect3>
+);
+	}
+}
+
+close $meson_targets;
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 9dde19224a7..d7fefa0918c 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -3212,236 +3212,7 @@ ninja install
     <replaceable>target</replaceable>.
    </para>
 
-   <sect3 id="meson-targets-code">
-    <title>Code Targets</title>
-
-    <variablelist>
-
-     <varlistentry id="meson-target-all">
-       <term><option>all</option></term>
-       <listitem>
-        <para>
-         Build everything other than documentation
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-backend">
-       <term><option>backend</option></term>
-       <listitem>
-        <para>
-         Build backend and related modules.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-bin">
-       <term><option>bin</option></term>
-       <listitem>
-        <para>
-         Build frontend binaries.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-contrib">
-       <term><option>contrib</option></term>
-       <listitem>
-        <para>
-         Build contrib modules.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-pl">
-       <term><option>pl</option></term>
-       <listitem>
-        <para>
-         Build procedual languages.
-        </para>
-       </listitem>
-     </varlistentry>
-
-    </variablelist>
-
-   </sect3>
-
-   <sect3 id="meson-targets-install">
-    <title>Install Targets</title>
-
-    <variablelist>
-
-     <varlistentry id="meson-target-install">
-       <term><option>install</option></term>
-       <listitem>
-        <para>
-         Install postgres, excluding documentation.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-install-quiet">
-       <term><option>install-quiet</option></term>
-       <listitem>
-        <para>
-         Like <xref linkend="meson-target-install"/>, but installed
-         files are not displayed.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-install-world">
-       <term><option>install-world</option></term>
-       <listitem>
-        <para>
-         Install postgres, including multi-page HTML and man page
-         documentation.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-install-docs">
-       <term><option>install-docs</option></term>
-       <listitem>
-        <para>
-         Install documentation in multi-page HTML and man page formats. See
-         also <xref linkend="meson-target-install-doc-html"/>, <xref
-         linkend="meson-target-install-doc-man"/>.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-install-doc-html">
-       <term><option>install-doc-html</option></term>
-       <listitem>
-        <para>
-         Install documentation in multi-page HTML format.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-install-doc-man">
-       <term><option>install-doc-man</option></term>
-       <listitem>
-        <para>
-         Install documentation in man page format.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-uninstall">
-       <term><option>uninstall</option></term>
-       <listitem>
-        <para>
-         Remove installed files.
-        </para>
-       </listitem>
-     </varlistentry>
-
-    </variablelist>
-   </sect3>
-
-   <sect3 id="meson-targets-docs">
-    <title>Documentation Targets</title>
-
-    <variablelist>
-
-     <varlistentry id="meson-target-docs">
-       <term><option>docs</option></term>
-       <term><option>doc-html</option></term>
-       <listitem>
-        <para>
-         Build documentation in multi-page HTML format.  Note that
-         <option>docs</option> does <emphasis>not</emphasis> include building
-         man page documentation, as man page generation seldom fails when
-         building HTML documentation succeeds.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-doc-man">
-       <term><option>doc-man</option></term>
-       <listitem>
-        <para>
-         Build documentation in man page format.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-html-single-page">
-      <term><option>doc/src/sgml/postgres.html</option></term>
-       <listitem>
-        <para>
-         Build documentation in single-page HTML format.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-pdf">
-      <term><option>doc/src/sgml/postgres-A4.pdf</option></term>
-      <term><option>doc/src/sgml/postgres-US.pdf</option></term>
-       <listitem>
-        <para>
-         Build documentation in PDF format, using A4 and U.S. letter format
-         respectively.
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-alldocs">
-       <term><option>alldocs</option></term>
-       <listitem>
-        <para>
-         Build documentation in all supported formats. Primarily useful when
-         testing larger documentation changes.
-        </para>
-       </listitem>
-     </varlistentry>
-
-    </variablelist>
-
-   </sect3>
-
-   <sect3 id="meson-targets-other">
-    <title>Other Targets</title>
-
-    <variablelist>
-
-     <varlistentry id="meson-target-clean">
-       <term><option>clean</option></term>
-       <listitem>
-        <para>
-         Remove all build products
-        </para>
-       </listitem>
-     </varlistentry>
-
-     <varlistentry id="meson-target-test">
-       <term><option>test</option></term>
-       <listitem>
-        <para>
-         Run all enabled tests (including contrib). Support for some classes
-         of tests can be enabled / disabled with <xref
-         linkend="configure-tap-tests-meson"/> and <xref
-         linkend="configure-pg-test-extra-meson"/>.
-        </para>
-       </listitem>
-     </varlistentry>
-
-
-     <varlistentry id="meson-target-world">
-       <term><option>world</option></term>
-       <listitem>
-        <para>
-         Build everything, including documentation.
-        </para>
-       </listitem>
-     </varlistentry>
-
-    </variablelist>
-
-   </sect3>
-
+   &meson-targets;
   </sect2>
 
  </sect1>
diff --git a/doc/src/sgml/meson-targets.txt b/doc/src/sgml/meson-targets.txt
new file mode 100644
index 00000000000..690e4ebc814
--- /dev/null
+++ b/doc/src/sgml/meson-targets.txt
@@ -0,0 +1,38 @@
+# Copyright (c) 2023, PostgreSQL Global Development Group
+#
+# Description of important meson targets, used for the 'help' target and
+# installation.sgml (via generate-meson-targets.pl). Right now the parsers are
+# extremely simple. Both parsers ignore comments. The help target prints
+# everything else. For xml everything without a leading newline is a group,
+# remaining lines are target separated by whitespace from their description
+#
+Code Targets:
+  all                          Build everything other than documentation
+  backend                      Build backend and related modules
+  bin                          Build frontend binaries
+  contrib                      Build contrib modules
+  pl                           Build procedual languages
+
+Documentation Targets:
+  docs                         Build documentation in multi-page HTML format
+  doc-html                     Build documentation in multi-page HTML format
+  doc-man                      Build documentation in man page format
+  doc/src/sgml/postgres-A4.pdf Build documentation in PDF format, with A4 pages
+  doc/src/sgml/postgres-US.pdf Build documentation in PDF format, with US letter pages
+  doc/src/sgml/postgres.html   Build documentation in single-page HTML format
+  alldocs                      Build documentation in all supported formats
+
+Installation Targets:
+  install                      Install postgres, excluding documentation
+  install-doc-html             Install documentation in multi-page HTML format
+  install-doc-man              Install documentation in man page format
+  install-docs                 Install documentation in multi-page HTML and man page formats
+  install-quiet                Like "install", but installed files are not displayed
+  install-world                Install postgres, including multi-page HTML and man page documentation
+  uninstall                    Remove installed files
+
+Other Targets:
+  clean                        Remove all build products
+  test                         Run all enabled tests (including contrib)
+  world                        Build everything, including documentation
+  help                         List important targets
diff --git a/doc/src/sgml/meson.build b/doc/src/sgml/meson.build
index fac7e701610..2dca38ccf7b 100644
--- a/doc/src/sgml/meson.build
+++ b/doc/src/sgml/meson.build
@@ -71,6 +71,15 @@ doc_generated += custom_target('keywords-table.sgml',
   capture: true,
 )
 
+doc_generated += custom_target('meson-targets.sgml',
+  input: files('meson-targets.txt'),
+  output: 'meson-targets.sgml',
+  command: [perl, files('generate-meson-targets.pl'), '@INPUT@'],
+  build_by_default: false,
+  install: false,
+  capture: true,
+)
+
 # For everything else we need at least xmllint
 if not xmllint_bin.found()
   subdir_done()
-- 
2.38.0

>From d3dc1f361e73f7e2ee4732cc82eb5279596b548d Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Fri, 3 Nov 2023 10:06:00 -0700
Subject: [PATCH v2 7/7] meson: Add -Dpkglibdir option

Author:
Reviewed-by:
Discussion: https://postgr.es/m/20231103163848.26egkh5qdgw3v...@awork3.anarazel.de
Backpatch:
---
 meson.build                    |  9 ++++++---
 meson_options.txt              |  3 +++
 doc/src/sgml/installation.sgml | 18 +++++++++++++++---
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/meson.build b/meson.build
index 0f086757e17..9f38433285b 100644
--- a/meson.build
+++ b/meson.build
@@ -492,9 +492,12 @@ endif
 
 dir_lib = get_option('libdir')
 
-dir_lib_pkg = dir_lib
-if not (dir_prefix_contains_pg or dir_lib_pkg.contains('pgsql') or dir_lib_pkg.contains('postgres'))
-  dir_lib_pkg = dir_lib_pkg / pkg
+dir_lib_pkg = get_option('pkglibdir')
+if dir_lib_pkg == ''
+  dir_lib_pkg = dir_lib
+  if not (dir_prefix_contains_pg or dir_lib_pkg.contains('pgsql') or dir_lib_pkg.contains('postgres'))
+    dir_lib_pkg = dir_lib_pkg / pkg
+  endif
 endif
 
 dir_pgxs = dir_lib_pkg / 'pgxs'
diff --git a/meson_options.txt b/meson_options.txt
index be1b327f544..82441b4d524 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -70,6 +70,9 @@ option('darwin_sysroot', type: 'string', value: '',
 option('rpath', type: 'boolean', value: true,
   description: 'Embed shared library search path in executables')
 
+option('pkglibdir', type: 'string', value: '',
+  description: 'Directory to install / load dynamically loadable modules from')
+
 
 # External dependencies
 
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index d7fefa0918c..8345bb68e92 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -2254,9 +2254,21 @@ ninja install
        <term><option>--libdir=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
-         Sets the location to install libraries and dynamically loadable
-         modules. The default is
-         <filename><replaceable>PREFIX</replaceable>/lib</filename>.
+         Sets the location to install libraries. The default is
+         <filename><replaceable>PREFIX</replaceable>/lib</filename>. This
+         option, unless <xref linkend='configure-pkglibdir-meson'/> is
+         specified, also controls where dynamically loadable modules get
+         installed.
+        </para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry id="configure-pkglibdir-meson">
+       <term><option>-Dpkglibdir=<replaceable>DIRECTORY</replaceable></option></term>
+       <listitem>
+        <para>
+         Sets the location to dynamically loadable modules. The default is set
+         by <xref linkend='configure-libdir-meson'/>.
         </para>
        </listitem>
       </varlistentry>
-- 
2.38.0

Reply via email to