Subject: [PATCH v2 3/8] wip: meson: add install-{docs,doc-html,doc-man} targets

From: Andres Freund <[email-masked]>
Date: Wed, 15 Mar 2023 16:43:40 -0700

---
 meson.build              |  2 +-
 doc/src/sgml/meson.build | 67 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 84fe2c3d4c3..33dd5b43ed5 100644
--- a/meson.build
+++ b/meson.build
@@ -504,7 +504,7 @@ dir_man = get_option('mandir')
 
 # FIXME: These used to be separately configurable - worth adding?
 dir_doc = get_option('datadir') / 'doc' / 'postgresql'
-dir_doc_html = dir_doc
+dir_doc_html = dir_doc / 'html'
 
 dir_locale = get_option('localedir')
 
diff --git a/doc/src/sgml/meson.build b/doc/src/sgml/meson.build
index e6fe124c7bc..f24acebb0fe 100644
--- a/doc/src/sgml/meson.build
+++ b/doc/src/sgml/meson.build
@@ -1,6 +1,7 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
 docs = []
+installdocs = []
 alldocs = []
 doc_generated = []
 
@@ -120,8 +121,21 @@ if xsltproc_bin.found()
   )
   alldocs += html
 
-  # build multi-page html docs as part of docs target
+  install_doc_html = custom_target('install-html',
+    output: 'install-html', input: html,
+    command: [
+      python, install_files, '--prefix', dir_prefix,
+      '--install-dir-contents', dir_doc_html, '@INPUT@'],
+    depends: html,
+    build_always_stale: true,
+    build_by_default: false,
+  )
+  alias_target('install-doc-html', install_doc_html)
+
+  # build and install multi-page html docs as part of docs target
   docs += html
+  installdocs += install_doc_html
+
 
   htmlhelp = custom_target('htmlhelp',
     input: ['stylesheet-hh.xsl', postgres_full_xml],
@@ -208,6 +222,20 @@ if xsltproc_bin.found()
     build_by_default: false,
   )
   alldocs += man
+
+  install_doc_man = custom_target('install-man',
+    output: 'install-man', input: man,
+    command: [
+      python, install_files, '--prefix', dir_prefix,
+      '--install-dirs', dir_man, '@INPUT@'],
+    build_always_stale: true,
+    build_by_default: false,
+  )
+  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
+  # to install them as part of install-docs
+  installdocs += install_doc_man
 endif

@@ -262,10 +290,47 @@ if pandoc.found() and xsltproc_bin.found()
   alldocs += postgres_epub
 endif
 
+
+##
+## Experimental Texinfo targets
+##
+
+db2x_xsltproc = find_program('db2x_xsltproc', native: true, required: false)
+db2x_texixml = find_program('db2x_texixml', native: true, required: false)
+makeinfo = find_program('makeinfo', native: true, required: false)
+
+if db2x_texixml.found() and db2x_xsltproc.found() and makeinfo.found()
+    postgres_texixml = custom_target('postgres.texixml',
+      input: postgres_full_xml,
+      output: 'postgres.texixml',
+      command: [db2x_xsltproc, '-s', 'texi',
+                '-g', 'output-file=postgres',
+                '@INPUT@', '-o', '@OUTPUT@'],
+      build_by_default: false,
+    )
+    postgres_texi = custom_target('postgres.texi',
+      input: postgres_texixml,
+      output: 'postgres.texi',
+      command: [db2x_texixml, '--encoding=utf-8', '@INPUT@',
+                '--output-dir=@OUTDIR@'],
+      build_by_default: false,
+    )
+    postgres_info = custom_target('postgres.info',
+      input: postgres_texi,
+      output: 'postgres.info',
+      command: [makeinfo, '--enable-encoding', '--no-split', '--no-validate',
+                '@INPUT@', '-o', '@OUTPUT0@'],
+      build_by_default: false,
+    )
+    alldocs += postgres_info
+endif
+
+
 if docs.length() == 0
   run_target('docs', command: [missing, 'xsltproc'])
 else
   alias_target('docs', docs)
+  alias_target('install-docs', installdocs)
 endif
 
 if alldocs.length() == 0
-- 
2.38.0

--az2jhiapsr25u55d
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-meson-add-install-quiet-world-targets.patch"