1 # Copyright (c) 2022-2025, PostgreSQL Global Development Group
8 version_sgml = configure_file(
9 input: 'version.sgml.in',
10 output: 'version.sgml',
13 configure_files += version_sgml
15 doc_generated += custom_target('features-supported.sgml',
17 '../../../src/backend/catalog/sql_feature_packages.txt',
18 '../../../src/backend/catalog/sql_features.txt',
20 output: 'features-supported.sgml',
21 command: [perl, files('mk_feature_tables.pl'), 'YES', '@INPUT@'],
22 build_by_default: false,
27 doc_generated += custom_target('features-unsupported.sgml',
29 '../../../src/backend/catalog/sql_feature_packages.txt',
30 '../../../src/backend/catalog/sql_features.txt',
32 output: 'features-unsupported.sgml',
33 command: [perl, files('mk_feature_tables.pl'), 'NO', '@INPUT@'],
34 build_by_default: false,
39 doc_generated += custom_target('errcodes-table.sgml',
41 '../../../src/backend/utils/errcodes.txt'),
42 output: 'errcodes-table.sgml',
43 command: [perl, files('generate-errcodes-table.pl'), '@INPUT@'],
44 build_by_default: false,
49 doc_generated += custom_target('wait_event_types.sgml',
51 '../../../src/backend/utils/activity/wait_event_names.txt'),
52 output: 'wait_event_types.sgml',
54 files('../../../src/backend/utils/activity/generate-wait_event_types.pl'),
55 '--outdir', '@OUTDIR@', '--docs', '@INPUT@'],
56 build_by_default: false,
61 # FIXME: this actually has further inputs, adding depfile support to
62 # generate-keywords-table.pl is probably the best way to address that
64 doc_generated += custom_target('keywords-table.sgml',
66 '../../../src/include/parser/kwlist.h'),
67 output: 'keywords-table.sgml',
68 command: [perl, files('generate-keywords-table.pl'), '@CURRENT_SOURCE_DIR@'],
69 build_by_default: false,
74 doc_generated += custom_target('targets-meson.sgml',
75 input: files('targets-meson.txt'),
76 output: 'targets-meson.sgml',
77 command: [perl, files('generate-targets-meson.pl'), '@INPUT@'],
78 build_by_default: false,
83 # For everything else we need at least xmllint
84 if not xmllint_bin.found()
88 pandoc = find_program('pandoc', native: true, required: false)
91 python, files('xmltools_dep_wrapper'),
92 '--targetname', '@OUTPUT@', '--depfile', '@DEPFILE@'
95 xmllint = xmltools_wrapper + [
96 '--tool', xmllint_bin, '--',
99 # Run validation only once, common to all subsequent targets. While
100 # we're at it, also resolve all entities (that is, copy all included
101 # files into one big file). This helps tools that don't understand
102 # vpath builds (such as dbtoepub).
103 postgres_full_xml = custom_target('postgres-full.xml',
104 input: 'postgres.sgml',
105 output: 'postgres-full.xml',
106 depfile: 'postgres-full.xml.d',
107 command: [xmllint, '--nonet', '--noent', '--valid',
108 '--path', '@OUTDIR@', '-o', '@OUTPUT@', '@INPUT@'],
109 depends: doc_generated,
110 build_by_default: false,
112 docs += postgres_full_xml
113 alldocs += postgres_full_xml
116 if xsltproc_bin.found()
119 '--stringparam', 'pg.version', pg_version,
120 '--path', '@OUTDIR@', '--path', '@CURRENT_SOURCE_DIR@',
123 xsltproc = xmltools_wrapper + [
124 '--tool', xsltproc_bin, '--',
127 xsltproc_html_flags = xsltproc_flags
128 if get_option('docs_html_style') == 'website'
129 xsltproc_html_flags += ['--param', 'website.stylesheet', '1']
135 # Full documentation as html, text
138 html = custom_target('html',
139 input: ['stylesheet.xsl', postgres_full_xml],
142 command: [xsltproc, '-o', '@OUTDIR@/', xsltproc_html_flags, '@INPUT@'],
143 build_by_default: false,
147 install_doc_html = custom_target('install-html',
148 output: 'install-html',
150 python, install_files, '--prefix', dir_prefix,
151 '--install-dir-contents', dir_doc_html, html],
152 build_always_stale: true, build_by_default: false,
154 alias_target('html', html)
155 alias_target('install-html', install_doc_html)
157 # build and install multi-page html docs as part of docs target
159 installdocs += install_doc_html
163 postgres_html = custom_target('postgres.html',
164 input: ['stylesheet-html-nochunk.xsl', postgres_full_xml],
165 output: 'postgres.html',
166 depfile: 'postgres.html.d',
167 command: [xsltproc, '-o', '@OUTPUT@', xsltproc_html_flags, '@INPUT@'],
168 build_by_default: false,
170 alldocs += postgres_html
174 postgres_txt = custom_target('postgres.txt',
175 input: [postgres_html],
176 output: 'postgres.txt',
177 command: [pandoc, '-t', 'plain', '-o', '@OUTPUT@', '@INPUT@'],
178 build_by_default: false,
180 alldocs += postgres_txt
189 # FIXME: implement / consider sqlmansectnum logic
190 man = custom_target('man',
191 input: ['stylesheet-man.xsl', postgres_full_xml],
192 output: ['man1', 'man3', 'man7'],
194 command: [xsltproc, '-o', '@OUTDIR@/', xsltproc_html_flags, '@INPUT@'],
195 build_by_default: false,
199 install_doc_man = custom_target('install-man',
200 output: 'install-man',
203 python, install_files, '--prefix', dir_prefix,
204 '--install-dirs', dir_man, '@INPUT@'],
205 build_always_stale: true, build_by_default: false,
207 alias_target('man', man)
208 alias_target('install-man', install_doc_man)
210 # built and installed as part of the docs target
211 installdocs += install_doc_man
217 # Full documentation as PDF
219 if docs_pdf_dep.found()
220 xsltproc_fo_flags = xsltproc_flags + [
221 '--stringparam', 'img.src.path', meson.current_source_dir() + '/'
224 foreach format, detail: {'A4': 'A4', 'US': 'USletter'}
225 postgres_x_fo_f = 'postgres-@0@.fo'.format(format)
226 postgres_x_fo_dep = 'postgres-@0@.fo.d'.format(format)
227 postgres_x_pdf_f = 'postgres-@0@.pdf'.format(format)
229 postgres_x_fo = custom_target(postgres_x_fo_f,
230 input: ['stylesheet-fo.xsl', postgres_full_xml],
231 output: postgres_x_fo_f,
232 depfile: postgres_x_fo_dep,
233 command: [xsltproc, xsltproc_fo_flags,
234 '--stringparam', 'paper.type', detail,
235 '-o', '@OUTPUT@', '@INPUT@'],
236 build_by_default: false,
239 postgres_x_pdf = custom_target(postgres_x_pdf_f,
240 input: [postgres_x_fo],
241 output: [postgres_x_pdf_f],
242 command: [fop, '-fo', '@INPUT@', '-pdf', '@OUTPUT@'],
243 build_by_default: false,
245 alldocs += postgres_x_pdf
254 # This was previously implemented using dbtoepub - but that doesn't seem to
255 # support running in build != source directory (i.e. VPATH builds already
256 # weren't supported).
257 if pandoc.found() and xsltproc_bin.found()
258 postgres_epub = custom_target('postgres.epub',
259 input: postgres_full_xml,
260 output: 'postgres.epub',
261 command: [pandoc, '-f', 'docbook', '-t', 'epub', '-o', '@OUTPUT@', '--resource-path=@CURRENT_SOURCE_DIR@',
263 build_by_default: false,
265 alldocs += postgres_epub
270 ## Experimental Texinfo targets
273 db2x_xsltproc = find_program('db2x_xsltproc', native: true, required: false)
274 db2x_texixml = find_program('db2x_texixml', native: true, required: false)
275 makeinfo = find_program('makeinfo', native: true, required: false)
277 if xsltproc_bin.found() and db2x_texixml.found() and db2x_xsltproc.found() and makeinfo.found()
278 postgres_texixml = custom_target('postgres.texixml',
279 output: 'postgres.texixml',
280 command: [db2x_xsltproc, '-s', 'texi',
281 '-g', 'output-file=postgres',
282 postgres_full_xml, '-o', '@OUTPUT@'],
283 build_by_default: false,
285 postgres_texi = custom_target('postgres.texi',
286 output: 'postgres.texi',
287 command: [db2x_texixml, '--encoding=utf-8', postgres_texixml,
288 '--output-dir=@OUTDIR@'],
289 build_by_default: false,
291 postgres_info = custom_target('postgres.info',
292 output: 'postgres.info',
293 command: [makeinfo, '--enable-encoding', '--no-split', '--no-validate',
294 postgres_texi, '-o', '@OUTPUT0@'],
295 build_by_default: false,
297 alldocs += postgres_info
302 alias_target('docs', docs)
303 alias_target('install-docs', installdocs)
306 if alldocs.length() != 0
307 alias_target('alldocs', alldocs)