1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 # This is lame, I know, but meson has no other include mechanism
6 want_man = get_option('man')
7 want_html = get_option('html')
8 xsltproc = find_program('xsltproc',
9 required : want_man == 'true' or want_html == 'true')
10 want_man = want_man != 'false' and xsltproc.found()
11 want_html = want_html != 'false' and xsltproc.found()
17 '--stringparam', 'man.output.quietly', '1',
18 '--stringparam', 'funcsynopsis.style', 'ansi',
19 '--stringparam', 'man.authors.section.enabled', '0',
20 '--stringparam', 'man.copyright.section.enabled', '0',
21 '--stringparam', 'systemd.version', '@0@'.format(meson.project_version()),
23 '@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())]
25 custom_man_xsl = files('custom-man.xsl')
26 custom_html_xsl = files('custom-html.xsl')
27 xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
29 custom_entities_ent = custom_target(
30 'custom-entities.ent',
31 input : 'custom-entities.ent.in',
32 output : 'custom-entities.ent',
33 command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'])
39 foreach tuple : manpages
47 man = stem + '.' + section
51 foreach alias : aliases
52 manaliases += alias + '.' + section
53 htmlaliases += alias + '.html'
56 mandirn = get_option('mandir') / ('man' + section)
58 if condition == '' or conf.get(condition) == 1
59 file = files(tuple[0] + '.xml')
60 source_xml_files += file
61 if tuple[0].startswith('org.freedesktop.')
69 output : [man] + manaliases,
70 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
71 depends : custom_entities_ent,
73 install_dir : mandirn)
77 foreach htmlalias : htmlaliases
81 command : [ln, '-fs', html, '@OUTPUT@'])
83 dst = docdir / 'html' / htmlalias
84 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
85 meson.add_install_script('sh', '-c', cmd)
95 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
96 depends : [custom_entities_ent, p2],
98 install_dir : docdir / 'html')
102 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
106 ############################################################
108 have_lxml = run_command(xml_helper_py, check: false).returncode() == 0
110 message('python-lxml not available, not making man page indices')
113 systemd_directives_xml = custom_target(
114 'systemd.directives.xml',
115 input : ['directives-template.xml', source_xml_files],
116 output : 'systemd.directives.xml',
117 depends : custom_entities_ent,
118 command : [make_directive_index_py, '@OUTPUT@', '@INPUT@'])
120 nonindex_xml_files = source_xml_files + [systemd_directives_xml]
121 systemd_index_xml = custom_target(
123 input : nonindex_xml_files,
124 output : 'systemd.index.xml',
125 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
127 foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml],
128 ['systemd.index', '7', systemd_index_xml]] : []
133 html = stem + '.html'
134 man = stem + '.' + section
136 mandirn = get_option('mandir') / ('man' + section)
142 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
143 install : want_man and have_lxml,
144 install_dir : mandirn)
148 if html == 'systemd.index.html'
149 htmlalias = 'index.html'
150 link = custom_target(
154 command : [ln, '-fs', html, '@OUTPUT@'])
156 dst = docdir / 'html' / htmlalias
157 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
158 meson.add_install_script('sh', '-c', cmd)
168 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
169 depends : [custom_entities_ent, p2],
170 install : want_html and have_lxml,
171 install_dir : docdir / 'html')
175 # Cannot use run_target because those targets are used in depends
176 # Also see https://github.com/mesonbuild/meson/issues/368.
183 html = custom_target(
186 depends : html_pages,
192 depends : man_pages + html_pages,
193 command : [rsync, '-rlv',
199 meson.current_build_dir(),
200 get_option('www-target')])
203 ############################################################
205 buildroot_substs = configuration_data()
206 buildroot_substs.set_quoted('BUILD_ROOT', project_build_root)
211 configuration : buildroot_substs)
216 configuration : buildroot_substs)
218 ############################################################
220 update_dbus_docs = custom_target(
222 output : 'update-dbus-docs',
223 command : [update_dbus_docs_py, '--build-dir', project_build_root, '@INPUT@'],
226 if conf.get('BUILD_MODE_DEVELOPER') == 1
227 test('dbus-docs-fresh',
229 args : ['--build-dir', project_build_root, '--test', dbus_docs],
230 depends : dbus_programs)
233 update_man_rules = custom_target(
235 output : 'update-man-rules',
236 command : [update_man_rules_py,
237 '@0@/man/*.xml'.format(project_source_root),
238 '@0@/rules/meson.build'.format(meson.current_source_dir())],
239 depends : custom_entities_ent)