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',
37 foreach tuple : xsltproc.found() ? manpages : []
45 man = stem + '.' + section
49 foreach alias : aliases
50 manaliases += alias + '.' + section
51 htmlaliases += alias + '.html'
54 mandirn = join_paths(get_option('mandir'), 'man' + section)
56 if condition == '' or conf.get(condition) == 1
60 output : [man] + manaliases,
61 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
62 depend_files : custom_entities_ent,
64 install_dir : mandirn)
68 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 source_xml_files += files(tuple[0] + '.xml')
96 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
100 ############################################################
102 have_lxml = run_command(xml_helper_py).returncode() == 0
104 message('python-lxml not available, not making man page indices')
107 systemd_directives_xml = custom_target(
108 'systemd.directives.xml',
109 input : source_xml_files,
110 output : 'systemd.directives.xml',
111 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
113 nonindex_xml_files = source_xml_files + [systemd_directives_xml]
114 systemd_index_xml = custom_target(
116 input : nonindex_xml_files,
117 output : 'systemd.index.xml',
118 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
120 foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml],
121 ['systemd.index', '7', systemd_index_xml]] : []
126 html = stem + '.html'
127 man = stem + '.' + section
129 mandirn = join_paths(get_option('mandir'), 'man' + section)
135 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
136 install : want_man and have_lxml,
137 install_dir : mandirn)
141 if html == 'systemd.index.html'
142 htmlalias = 'index.html'
143 link = custom_target(
147 command : ['ln', '-fs', html, '@OUTPUT@'])
149 dst = join_paths(docdir, 'html', htmlalias)
150 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
151 meson.add_install_script('sh', '-c', cmd)
161 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
162 depend_files : custom_entities_ent,
164 install : want_html and have_lxml,
165 install_dir : join_paths(docdir, 'html'))
169 # Cannot use run_target because those targets are used in depends
170 # Also see https://github.com/mesonbuild/meson/issues/368.
177 html = custom_target(
180 depends : html_pages,
185 depends : man_pages + html_pages,
186 command : ['rsync', '-rlv',
192 meson.current_build_dir(),
193 get_option('www-target')])
195 ############################################################
200 output : 'update-man-rules',
201 command : ['sh', '-c',
202 'cd @0@ && '.format(meson.build_root()) +
203 'python3 @0@/tools/make-man-rules.py $(git ls-files ":/man/*.xml") >t && '.format(project_source_root) +
204 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
205 depend_files : custom_entities_ent)