1 # SPDX-License-Identifier: LGPL-2.1+
3 # Copyright 2017 Zbigniew Jędrzejewski-Szmek
5 # systemd is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) any later version.
10 # systemd is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 # This is lame, I know, but meson has no other include mechanism
21 want_man = get_option('man')
22 want_html = get_option('html')
23 xsltproc = find_program('xsltproc',
24 required : want_man == 'true' or want_html == 'true')
25 want_man = want_man != 'false' and xsltproc.found()
26 want_html = want_html != 'false' and xsltproc.found()
32 '--stringparam', 'man.output.quietly', '1',
33 '--stringparam', 'funcsynopsis.style', 'ansi',
34 '--stringparam', 'man.authors.section.enabled', '0',
35 '--stringparam', 'man.copyright.section.enabled', '0',
36 '--stringparam', 'systemd.version', '@0@'.format(meson.project_version()),
38 '@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())]
40 custom_man_xsl = files('custom-man.xsl')
41 custom_html_xsl = files('custom-html.xsl')
42 xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
44 custom_entities_ent = configure_file(
45 input : 'custom-entities.ent.in',
46 output : 'custom-entities.ent',
52 foreach tuple : xsltproc.found() ? manpages : []
60 man = stem + '.' + section
64 foreach alias : aliases
65 manaliases += [alias + '.' + section]
66 htmlaliases += [alias + '.html']
69 mandirn = join_paths(get_option('mandir'), 'man' + section)
71 if condition == '' or conf.get(condition) == 1
75 output : [man] + manaliases,
76 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
77 depend_files : custom_entities_ent,
79 install_dir : mandirn)
83 foreach htmlalias : htmlaliases
88 command : ['ln', '-fs', html, '@OUTPUT@'])
90 dst = join_paths(docdir, 'html', htmlalias)
91 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
92 meson.add_install_script('sh', '-c', cmd)
102 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
103 depend_files : custom_entities_ent,
106 install_dir : join_paths(docdir, 'html'))
109 source_xml_files += files(tuple[0] + '.xml')
111 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
115 ############################################################
117 have_lxml = run_command(xml_helper_py).returncode() == 0
119 message('python-lxml not available, not making man page indices')
122 systemd_directives_xml = custom_target(
123 'systemd.directives.xml',
124 input : source_xml_files,
125 output : 'systemd.directives.xml',
126 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
128 nonindex_xml_files = source_xml_files + [systemd_directives_xml]
129 systemd_index_xml = custom_target(
131 input : nonindex_xml_files,
132 output : 'systemd.index.xml',
133 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
135 foreach tuple : want_man or want_html ? [['systemd.directives', '7', systemd_directives_xml],
136 ['systemd.index', '7', systemd_index_xml]] : []
141 html = stem + '.html'
142 man = stem + '.' + section
144 mandirn = join_paths(get_option('mandir'), 'man' + section)
150 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
151 install : want_man and have_lxml,
152 install_dir : mandirn)
156 if html == 'systemd.index.html'
157 htmlalias = 'index.html'
158 link = custom_target(
162 command : ['ln', '-fs', html, '@OUTPUT@'])
164 dst = join_paths(docdir, 'html', htmlalias)
165 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
166 meson.add_install_script('sh', '-c', cmd)
176 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
177 depend_files : custom_entities_ent,
179 install : want_html and have_lxml,
180 install_dir : join_paths(docdir, 'html'))
184 # cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved
191 html = custom_target(
194 depends : html_pages,
199 depends : man_pages + html_pages,
200 command : ['rsync', '-rlv',
206 meson.current_build_dir(),
207 get_option('www-target')])
209 ############################################################
214 output : 'update-man-rules',
215 # slightly strange syntax because of
216 # https://github.com/mesonbuild/meson/issues/1643
217 # and https://github.com/mesonbuild/meson/issues/1512
218 command : ['sh', '-c',
219 'cd @0@ && '.format(meson.build_root()) +
220 'python3 @0@/tools/make-man-rules.py `git ls-files ":/man/*.xml"` >t && '.format(meson.source_root()) +
221 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
222 depend_files : custom_entities_ent)