1 # This is lame, I know, but meson has no other include mechanism
4 want_man = get_option('man')
5 want_html = get_option('html')
6 xsltproc = find_program('xsltproc',
7 required : want_man == 'true' or want_html == 'true')
8 want_man = want_man != 'false' and xsltproc.found()
9 want_html = want_html != 'false' and xsltproc.found()
14 '--stringparam', 'man.output.quietly', '1',
15 '--stringparam', 'funcsynopsis.style', 'ansi',
16 '--stringparam', 'man.authors.section.enabled', '0',
17 '--stringparam', 'man.copyright.section.enabled', '0',
18 '--stringparam', 'systemd.version', '@0@'.format(meson.project_version()),
20 '@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())]
22 custom_man_xsl = files('custom-man.xsl')
23 custom_html_xsl = files('custom-html.xsl')
24 xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
26 custom_entities_ent = configure_file(
27 input : 'custom-entities.ent.in',
28 output : 'custom-entities.ent',
34 foreach tuple : manpages
42 man = stem + '.' + section
46 foreach alias : aliases
47 manaliases += [alias + '.' + section]
48 htmlaliases += [alias + '.html']
51 mandirn = join_paths(get_option('mandir'), 'man' + section)
53 if condition == '' or conf.get(condition, false)
57 output : [man] + manaliases,
58 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
59 depend_files : custom_entities_ent,
61 install_dir : mandirn)
65 foreach htmlalias : htmlaliases
70 command : ['ln', '-fs', html, '@OUTPUT@'])
72 dst = join_paths(docdir, 'html', htmlalias)
73 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
74 meson.add_install_script('sh', '-c', cmd)
84 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
85 depend_files : custom_entities_ent,
88 install_dir : join_paths(docdir, 'html'))
91 source_xml_files += files(tuple[0] + '.xml')
93 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
97 ############################################################
99 have_lxml = run_command(xml_helper_py).returncode() == 0
101 message('python-lxml not available, not making man page indices')
104 systemd_directives_xml = custom_target(
105 'systemd.directives.xml',
106 input : source_xml_files,
107 output : 'systemd.directives.xml',
108 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
110 nonindex_xml_files = source_xml_files + [systemd_directives_xml]
111 systemd_index_xml = custom_target(
113 input : nonindex_xml_files,
114 output : 'systemd.index.xml',
115 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
117 foreach tuple : [['systemd.directives', '7', systemd_directives_xml],
118 ['systemd.index', '7', systemd_index_xml]]
123 html = stem + '.html'
124 man = stem + '.' + section
126 mandirn = join_paths(get_option('mandir'), 'man' + section)
132 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
133 install : want_man and have_lxml,
134 install_dir : mandirn)
138 if html == 'systemd.index.html'
139 htmlalias = 'index.html'
140 link = custom_target(
144 command : ['ln', '-fs', html, '@OUTPUT@'])
146 dst = join_paths(docdir, 'html', htmlalias)
147 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
148 meson.add_install_script('sh', '-c', cmd)
158 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
159 depend_files : custom_entities_ent,
161 install : want_html and have_lxml,
162 install_dir : join_paths(docdir, 'html'))
166 # cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved
173 html = custom_target(
176 depends : html_pages,
181 depends : man_pages + html_pages,
182 command : ['rsync', '-rlv',
188 meson.current_build_dir(),
189 get_option('www-target')])
191 ############################################################
196 output : 'update-man-rules',
197 # slightly strange syntax because of
198 # https://github.com/mesonbuild/meson/issues/1643
199 # and https://github.com/mesonbuild/meson/issues/1512
200 command : ['sh', '-c',
201 'cd @0@ && '.format(meson.build_root()) +
202 'python3 @0@/tools/make-man-rules.py `git ls-files ":/man/*.xml"` >t && '.format(meson.source_root()) +
203 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
204 depend_files : custom_entities_ent)