1 # SPDX-License-Identifier: LGPL-2.1+
3 # Copyright 2017 Zbigniew Jędrzejewski-Szmek
5 # This is lame, I know, but meson has no other include mechanism
8 want_man = get_option('man')
9 want_html = get_option('html')
10 xsltproc = find_program('xsltproc',
11 required : want_man == 'true' or want_html == 'true')
12 want_man = want_man != 'false' and xsltproc.found()
13 want_html = want_html != 'false' and xsltproc.found()
19 '--stringparam', 'man.output.quietly', '1',
20 '--stringparam', 'funcsynopsis.style', 'ansi',
21 '--stringparam', 'man.authors.section.enabled', '0',
22 '--stringparam', 'man.copyright.section.enabled', '0',
23 '--stringparam', 'systemd.version', '@0@'.format(meson.project_version()),
25 '@0@:@1@'.format(meson.current_build_dir(), 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 = configure_file(
32 input : 'custom-entities.ent.in',
33 output : 'custom-entities.ent',
39 foreach tuple : xsltproc.found() ? manpages : []
47 man = stem + '.' + section
51 foreach alias : aliases
52 manaliases += [alias + '.' + section]
53 htmlaliases += [alias + '.html']
56 mandirn = join_paths(get_option('mandir'), 'man' + section)
58 if condition == '' or conf.get(condition) == 1
62 output : [man] + manaliases,
63 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
64 depend_files : custom_entities_ent,
66 install_dir : mandirn)
70 foreach htmlalias : htmlaliases
75 command : ['ln', '-fs', html, '@OUTPUT@'])
77 dst = join_paths(docdir, 'html', htmlalias)
78 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
79 meson.add_install_script('sh', '-c', cmd)
89 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
90 depend_files : custom_entities_ent,
93 install_dir : join_paths(docdir, 'html'))
96 source_xml_files += files(tuple[0] + '.xml')
98 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
102 ############################################################
104 have_lxml = run_command(xml_helper_py).returncode() == 0
106 message('python-lxml not available, not making man page indices')
109 systemd_directives_xml = custom_target(
110 'systemd.directives.xml',
111 input : source_xml_files,
112 output : 'systemd.directives.xml',
113 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
115 nonindex_xml_files = source_xml_files + [systemd_directives_xml]
116 systemd_index_xml = custom_target(
118 input : nonindex_xml_files,
119 output : 'systemd.index.xml',
120 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
122 foreach tuple : want_man or want_html ? [['systemd.directives', '7', systemd_directives_xml],
123 ['systemd.index', '7', systemd_index_xml]] : []
128 html = stem + '.html'
129 man = stem + '.' + section
131 mandirn = join_paths(get_option('mandir'), 'man' + section)
137 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
138 install : want_man and have_lxml,
139 install_dir : mandirn)
143 if html == 'systemd.index.html'
144 htmlalias = 'index.html'
145 link = custom_target(
149 command : ['ln', '-fs', html, '@OUTPUT@'])
151 dst = join_paths(docdir, 'html', htmlalias)
152 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
153 meson.add_install_script('sh', '-c', cmd)
163 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
164 depend_files : custom_entities_ent,
166 install : want_html and have_lxml,
167 install_dir : join_paths(docdir, 'html'))
171 # cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved
178 html = custom_target(
181 depends : html_pages,
186 depends : man_pages + html_pages,
187 command : ['rsync', '-rlv',
193 meson.current_build_dir(),
194 get_option('www-target')])
196 ############################################################
201 output : 'update-man-rules',
202 # slightly strange syntax because of
203 # https://github.com/mesonbuild/meson/issues/1643
204 # and https://github.com/mesonbuild/meson/issues/1512
205 command : ['sh', '-c',
206 'cd @0@ && '.format(meson.build_root()) +
207 'python3 @0@/tools/make-man-rules.py `git ls-files ":/man/*.xml"` >t && '.format(meson.source_root()) +
208 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
209 depend_files : custom_entities_ent)