]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | # SPDX-License-Identifier: LGPL-2.1-or-later |
3a726fcd | 2 | |
5c23128d ZJS |
3 | # This is lame, I know, but meson has no other include mechanism |
4 | subdir('rules') | |
5 | ||
527d43d7 ZJS |
6 | want_man = get_option('man') |
7 | want_html = get_option('html') | |
8 | xsltproc = find_program('xsltproc', | |
4390be30 ZJS |
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() | |
527d43d7 | 12 | |
5c23128d | 13 | xsltproc_flags = [ |
37efbbd8 ZJS |
14 | '--nonet', |
15 | '--xinclude', | |
f2adcd22 | 16 | '--maxdepth', '9000', |
37efbbd8 ZJS |
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()), | |
22 | '--path', | |
23 | '@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())] | |
5c23128d ZJS |
24 | |
25 | custom_man_xsl = files('custom-man.xsl') | |
527d43d7 | 26 | custom_html_xsl = files('custom-html.xsl') |
37efbbd8 | 27 | xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags |
04e3eb46 | 28 | |
46c4f8dc ZJS |
29 | custom_entities_ent = custom_target( |
30 | 'custom-entities.ent', | |
37efbbd8 ZJS |
31 | input : 'custom-entities.ent.in', |
32 | output : 'custom-entities.ent', | |
8f04a1ca | 33 | command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@']) |
5c23128d | 34 | |
527d43d7 ZJS |
35 | man_pages = [] |
36 | html_pages = [] | |
37 | source_xml_files = [] | |
81e06775 | 38 | dbus_docs = [] |
f12c5d36 | 39 | foreach tuple : manpages |
37efbbd8 ZJS |
40 | stem = tuple[0] |
41 | section = tuple[1] | |
42 | aliases = tuple[2] | |
43 | condition = tuple[3] | |
44 | ||
45 | xml = stem + '.xml' | |
46 | html = stem + '.html' | |
47 | man = stem + '.' + section | |
48 | ||
49 | manaliases = [] | |
50 | htmlaliases = [] | |
51 | foreach alias : aliases | |
5a8b1640 ZJS |
52 | manaliases += alias + '.' + section |
53 | htmlaliases += alias + '.html' | |
37efbbd8 ZJS |
54 | endforeach |
55 | ||
fce9abb2 | 56 | mandirn = get_option('mandir') / ('man' + section) |
37efbbd8 | 57 | |
349cc4a5 | 58 | if condition == '' or conf.get(condition) == 1 |
81e06775 | 59 | file = files(tuple[0] + '.xml') |
a7052c6e | 60 | source_xml_files += file |
81e06775 ZJS |
61 | if tuple[0].startswith('org.freedesktop.') |
62 | dbus_docs += file | |
63 | endif | |
f12c5d36 ZJS |
64 | |
65 | if xsltproc.found() | |
66 | p1 = custom_target( | |
67 | man, | |
68 | input : xml, | |
69 | output : [man] + manaliases, | |
70 | command : xslt_cmd + [custom_man_xsl, '@INPUT@'], | |
71 | depends : custom_entities_ent, | |
72 | install : want_man, | |
73 | install_dir : mandirn) | |
74 | man_pages += p1 | |
75 | ||
76 | p2 = [] | |
77 | foreach htmlalias : htmlaliases | |
78 | link = custom_target( | |
79 | htmlalias, | |
80 | output : htmlalias, | |
81 | command : [ln, '-fs', html, '@OUTPUT@']) | |
82 | if want_html | |
83 | dst = docdir / 'html' / htmlalias | |
84 | cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst) | |
85 | meson.add_install_script('sh', '-c', cmd) | |
86 | p2 += link | |
87 | endif | |
88 | html_pages += link | |
89 | endforeach | |
90 | ||
91 | p3 = custom_target( | |
92 | html, | |
93 | input : xml, | |
94 | output : html, | |
95 | command : xslt_cmd + [custom_html_xsl, '@INPUT@'], | |
96 | depends : [custom_entities_ent, p2], | |
97 | install : want_html, | |
98 | install_dir : docdir / 'html') | |
99 | html_pages += p3 | |
100 | endif | |
37efbbd8 ZJS |
101 | else |
102 | message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition)) | |
103 | endif | |
5c23128d ZJS |
104 | endforeach |
105 | ||
106 | ############################################################ | |
107 | ||
68a06b3c | 108 | have_lxml = run_command(xml_helper_py, check: false).returncode() == 0 |
b184e8fe | 109 | if not have_lxml |
37efbbd8 | 110 | message('python-lxml not available, not making man page indices') |
b184e8fe ZJS |
111 | endif |
112 | ||
5c23128d | 113 | systemd_directives_xml = custom_target( |
37efbbd8 | 114 | 'systemd.directives.xml', |
28223088 | 115 | input : ['directives-template.xml', source_xml_files], |
37efbbd8 | 116 | output : 'systemd.directives.xml', |
670427a4 | 117 | depends : custom_entities_ent, |
28223088 | 118 | command : [make_directive_index_py, '@OUTPUT@', '@INPUT@']) |
5c23128d ZJS |
119 | |
120 | nonindex_xml_files = source_xml_files + [systemd_directives_xml] | |
121 | systemd_index_xml = custom_target( | |
37efbbd8 ZJS |
122 | 'systemd.index.xml', |
123 | input : nonindex_xml_files, | |
124 | output : 'systemd.index.xml', | |
125 | command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files) | |
5c23128d | 126 | |
b7507787 ZJS |
127 | foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml], |
128 | ['systemd.index', '7', systemd_index_xml]] : [] | |
37efbbd8 ZJS |
129 | stem = tuple[0] |
130 | section = tuple[1] | |
131 | xml = tuple[2] | |
132 | ||
133 | html = stem + '.html' | |
134 | man = stem + '.' + section | |
135 | ||
fce9abb2 | 136 | mandirn = get_option('mandir') / ('man' + section) |
37efbbd8 ZJS |
137 | |
138 | p1 = custom_target( | |
139 | man, | |
140 | input : xml, | |
141 | output : man, | |
142 | command : xslt_cmd + [custom_man_xsl, '@INPUT@'], | |
143 | install : want_man and have_lxml, | |
144 | install_dir : mandirn) | |
5a8b1640 | 145 | man_pages += p1 |
37efbbd8 | 146 | |
38acf8a7 | 147 | p2 = [] |
064d9ef0 MB |
148 | if html == 'systemd.index.html' |
149 | htmlalias = 'index.html' | |
38acf8a7 | 150 | link = custom_target( |
064d9ef0 MB |
151 | htmlalias, |
152 | input : p2, | |
153 | output : htmlalias, | |
0f4c4f38 | 154 | command : [ln, '-fs', html, '@OUTPUT@']) |
064d9ef0 | 155 | if want_html |
fce9abb2 | 156 | dst = docdir / 'html' / htmlalias |
064d9ef0 MB |
157 | cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst) |
158 | meson.add_install_script('sh', '-c', cmd) | |
5a8b1640 | 159 | p2 += link |
064d9ef0 | 160 | endif |
5a8b1640 | 161 | html_pages += link |
064d9ef0 | 162 | endif |
38acf8a7 ZJS |
163 | |
164 | p3 = custom_target( | |
165 | html, | |
166 | input : xml, | |
167 | output : html, | |
168 | command : xslt_cmd + [custom_html_xsl, '@INPUT@'], | |
46c4f8dc | 169 | depends : [custom_entities_ent, p2], |
38acf8a7 | 170 | install : want_html and have_lxml, |
fce9abb2 | 171 | install_dir : docdir / 'html') |
5a8b1640 | 172 | html_pages += p3 |
5c23128d | 173 | endforeach |
527d43d7 | 174 | |
6939fb9e ZJS |
175 | # Cannot use run_target because those targets are used in depends |
176 | # Also see https://github.com/mesonbuild/meson/issues/368. | |
9c84bb78 | 177 | man = custom_target( |
a923e085 | 178 | 'man', |
9c84bb78 | 179 | output : 'man', |
a923e085 | 180 | depends : man_pages, |
0f4c4f38 | 181 | command : [echo]) |
a923e085 | 182 | |
e85a690b | 183 | html = custom_target( |
a923e085 | 184 | 'html', |
a923e085 | 185 | output : 'html', |
e85a690b | 186 | depends : html_pages, |
0f4c4f38 | 187 | command : [echo]) |
a923e085 | 188 | |
7c5fd251 ZJS |
189 | if rsync.found() |
190 | run_target( | |
191 | 'doc-sync', | |
192 | depends : man_pages + html_pages, | |
193 | command : [rsync, '-rlv', | |
194 | '--delete-excluded', | |
195 | '--include=man', | |
196 | '--include=*.html', | |
197 | '--exclude=*', | |
198 | '--omit-dir-times', | |
199 | meson.current_build_dir(), | |
200 | get_option('www-target')]) | |
201 | endif | |
18af8932 ZJS |
202 | |
203 | ############################################################ | |
204 | ||
195a8a93 ZJS |
205 | buildroot_substs = configuration_data() |
206 | buildroot_substs.set_quoted('BUILD_ROOT', project_build_root) | |
207 | ||
e9bbff18 ZJS |
208 | configure_file( |
209 | input : 'man.in', | |
210 | output : 'man', | |
195a8a93 | 211 | configuration : buildroot_substs) |
e9bbff18 ZJS |
212 | |
213 | configure_file( | |
214 | input : 'html.in', | |
215 | output : 'html', | |
195a8a93 | 216 | configuration : buildroot_substs) |
f12c5d36 ZJS |
217 | |
218 | ############################################################ | |
219 | ||
220 | update_dbus_docs = custom_target( | |
221 | 'update-dbus-docs', | |
222 | output : 'update-dbus-docs', | |
223 | command : [update_dbus_docs_py, '--build-dir', project_build_root, '@INPUT@'], | |
224 | input : dbus_docs) | |
225 | ||
226 | if conf.get('BUILD_MODE_DEVELOPER') == 1 | |
227 | test('dbus-docs-fresh', | |
228 | update_dbus_docs_py, | |
14056a52 | 229 | suite : 'dist-check', |
e93ada98 DDM |
230 | args : ['--build-dir', project_build_root, '--test', dbus_docs], |
231 | depends : dbus_programs) | |
f12c5d36 ZJS |
232 | endif |
233 | ||
234 | update_man_rules = custom_target( | |
235 | 'update-man-rules', | |
236 | output : 'update-man-rules', | |
77d45f1f ZJS |
237 | command : [update_man_rules_py, |
238 | '@0@/man/*.xml'.format(project_source_root), | |
239 | '@0@/rules/meson.build'.format(meson.current_source_dir())], | |
f12c5d36 | 240 | depends : custom_entities_ent) |