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@:@2@'.format(meson.current_build_dir(),
24 meson.current_source_dir(),
27 custom_man_xsl = files('custom-man.xsl')
28 custom_html_xsl = files('custom-html.xsl')
29 xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
31 custom_entities_ent = custom_target(
32 'custom-entities.ent',
33 input : 'custom-entities.ent.in',
34 output : 'custom-entities.ent',
35 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'])
37 man_page_depends += custom_entities_ent
43 foreach tuple : manpages
51 man = stem + '.' + section
55 foreach alias : aliases
56 manaliases += alias + '.' + section
57 htmlaliases += alias + '.html'
60 mandirn = get_option('mandir') / ('man' + section)
62 if condition == '' or conf.get(condition) == 1
63 file = files(tuple[0] + '.xml')
64 source_xml_files += file
65 if tuple[0].startswith('org.freedesktop.')
73 output : [man] + manaliases,
74 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
75 depends : man_page_depends,
77 install_dir : mandirn)
81 foreach htmlalias : htmlaliases
85 command : [ln, '-fs', html, '@OUTPUT@'])
87 dst = docdir / 'html' / htmlalias
88 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
89 meson.add_install_script('sh', '-c', cmd)
99 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
100 depends : [man_page_depends, p2],
102 install_dir : docdir / 'html')
106 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
110 ############################################################
112 have_lxml = run_command(xml_helper_py, check: false).returncode() == 0
114 message('python-lxml not available, not making man page indices')
117 systemd_directives_xml = custom_target(
118 'systemd.directives.xml',
119 input : ['directives-template.xml', source_xml_files],
120 output : 'systemd.directives.xml',
121 depends : man_page_depends,
122 command : [make_directive_index_py, '@OUTPUT@', '@INPUT@'])
124 nonindex_xml_files = source_xml_files + [systemd_directives_xml]
125 systemd_index_xml = custom_target(
127 input : nonindex_xml_files,
128 output : 'systemd.index.xml',
129 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
131 foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml],
132 ['systemd.index', '7', systemd_index_xml]] : []
137 html = stem + '.html'
138 man = stem + '.' + section
140 mandirn = get_option('mandir') / ('man' + section)
146 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
147 install : want_man and have_lxml,
148 install_dir : mandirn)
152 if html == 'systemd.index.html'
153 htmlalias = 'index.html'
154 link = custom_target(
158 command : [ln, '-fs', html, '@OUTPUT@'])
160 dst = docdir / 'html' / htmlalias
161 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
162 meson.add_install_script('sh', '-c', cmd)
172 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
173 depends : [man_page_depends, p2],
174 install : want_html and have_lxml,
175 install_dir : docdir / 'html')
179 # Cannot use run_target because those targets are used in depends
180 # Also see https://github.com/mesonbuild/meson/issues/368.
187 html = custom_target(
190 depends : html_pages,
196 depends : man_pages + html_pages,
197 command : [rsync, '-rlv',
203 meson.current_build_dir(),
204 get_option('www-target')])
207 ############################################################
209 buildroot_substs = configuration_data()
210 buildroot_substs.set_quoted('BUILD_ROOT', project_build_root)
215 configuration : buildroot_substs)
220 configuration : buildroot_substs)
222 ############################################################
224 update_dbus_docs = custom_target(
225 'update-dbus-docs-impl',
226 output : 'update-dbus-docs',
227 command : [update_dbus_docs_py, '--build-dir', project_build_root, '@INPUT@'],
230 if conf.get('BUILD_MODE_DEVELOPER') == 1
231 test('dbus-docs-fresh',
234 args : ['--build-dir', project_build_root, '--test', dbus_docs],
235 depends : dbus_programs)
238 update_man_rules = custom_target(
239 'update-man-rules-impl',
240 output : 'update-man-rules',
241 command : [update_man_rules_py,
242 '@0@/man/*.xml'.format(project_source_root),
243 '@0@/rules/meson.build'.format(meson.current_source_dir())],
244 depends : man_page_depends)