1 # SPDX-License-Identifier: LGPL-2.1+
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 = configure_file(
30 input : 'custom-entities.ent.in',
31 output : 'custom-entities.ent',
38 foreach tuple : xsltproc.found() ? manpages : []
46 man = stem + '.' + section
50 foreach alias : aliases
51 manaliases += alias + '.' + section
52 htmlaliases += alias + '.html'
55 mandirn = join_paths(get_option('mandir'), 'man' + section)
57 if condition == '' or conf.get(condition) == 1
61 output : [man] + manaliases,
62 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
63 depend_files : custom_entities_ent,
65 install_dir : mandirn)
69 foreach htmlalias : htmlaliases
73 command : ['ln', '-fs', html, '@OUTPUT@'])
75 dst = join_paths(docdir, 'html', htmlalias)
76 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
77 meson.add_install_script('sh', '-c', cmd)
87 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
88 depend_files : custom_entities_ent,
91 install_dir : join_paths(docdir, 'html'))
94 file = files(tuple[0] + '.xml')
95 source_xml_files += file
96 if tuple[0].startswith('org.freedesktop.')
100 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
104 ############################################################
106 have_lxml = run_command(xml_helper_py).returncode() == 0
108 message('python-lxml not available, not making man page indices')
111 systemd_directives_xml = custom_target(
112 'systemd.directives.xml',
113 input : ['directives-template.xml', source_xml_files],
114 output : 'systemd.directives.xml',
115 command : [make_directive_index_py, '@OUTPUT@', '@INPUT@'])
117 nonindex_xml_files = source_xml_files + [systemd_directives_xml]
118 systemd_index_xml = custom_target(
120 input : nonindex_xml_files,
121 output : 'systemd.index.xml',
122 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
124 foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml],
125 ['systemd.index', '7', systemd_index_xml]] : []
130 html = stem + '.html'
131 man = stem + '.' + section
133 mandirn = join_paths(get_option('mandir'), 'man' + section)
139 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
140 install : want_man and have_lxml,
141 install_dir : mandirn)
145 if html == 'systemd.index.html'
146 htmlalias = 'index.html'
147 link = custom_target(
151 command : ['ln', '-fs', html, '@OUTPUT@'])
153 dst = join_paths(docdir, 'html', htmlalias)
154 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
155 meson.add_install_script('sh', '-c', cmd)
165 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
166 depend_files : custom_entities_ent,
168 install : want_html and have_lxml,
169 install_dir : join_paths(docdir, 'html'))
173 # Cannot use run_target because those targets are used in depends
174 # Also see https://github.com/mesonbuild/meson/issues/368.
181 html = custom_target(
184 depends : html_pages,
189 depends : man_pages + html_pages,
190 command : ['rsync', '-rlv',
196 meson.current_build_dir(),
197 get_option('www-target')])
199 ############################################################
201 if dbus_docs.length() > 0
204 output : 'update-dbus-docs',
205 command : ['python3',
206 '@0@/tools/update-dbus-docs.py'.format(project_source_root),
207 '--build-dir=@0@'.format(project_build_root),
212 ############################################################
217 output : 'update-man-rules',
218 command : ['sh', '-c',
219 'cd @0@ && '.format(meson.build_root()) +
220 'python3 @0@/tools/update-man-rules.py $(git ls-files ":/man/*.xml") >t && '.format(project_source_root) +
221 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
222 depend_files : custom_entities_ent)
225 ############################################################
230 configuration : substs)
235 configuration : substs)