]>
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', | |
1e73a64a JJ |
9 | required : want_man.enabled() or want_html.enabled()) |
10 | want_man = want_man.allowed() and xsltproc.found() | |
11 | want_html = want_html.allowed() 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', | |
c18dde32 ZJS |
23 | '@0@:@1@:@2@'.format(meson.current_build_dir(), |
24 | meson.current_source_dir(), | |
25 | libshared_build_dir)] | |
5c23128d ZJS |
26 | |
27 | custom_man_xsl = files('custom-man.xsl') | |
527d43d7 | 28 | custom_html_xsl = files('custom-html.xsl') |
37efbbd8 | 29 | xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags |
04e3eb46 | 30 | |
46c4f8dc ZJS |
31 | custom_entities_ent = custom_target( |
32 | 'custom-entities.ent', | |
37efbbd8 ZJS |
33 | input : 'custom-entities.ent.in', |
34 | output : 'custom-entities.ent', | |
8f04a1ca | 35 | command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@']) |
5c23128d | 36 | |
c18dde32 ZJS |
37 | man_page_depends += custom_entities_ent |
38 | ||
527d43d7 ZJS |
39 | man_pages = [] |
40 | html_pages = [] | |
41 | source_xml_files = [] | |
81e06775 | 42 | dbus_docs = [] |
f12c5d36 | 43 | foreach tuple : manpages |
37efbbd8 ZJS |
44 | stem = tuple[0] |
45 | section = tuple[1] | |
46 | aliases = tuple[2] | |
47 | condition = tuple[3] | |
48 | ||
49 | xml = stem + '.xml' | |
50 | html = stem + '.html' | |
51 | man = stem + '.' + section | |
52 | ||
53 | manaliases = [] | |
54 | htmlaliases = [] | |
55 | foreach alias : aliases | |
5a8b1640 ZJS |
56 | manaliases += alias + '.' + section |
57 | htmlaliases += alias + '.html' | |
37efbbd8 ZJS |
58 | endforeach |
59 | ||
fce9abb2 | 60 | mandirn = get_option('mandir') / ('man' + section) |
37efbbd8 | 61 | |
ec3cf73f ZJS |
62 | have = true |
63 | foreach word : condition.split() | |
64 | if conf.get(word) != 1 | |
65 | have = false | |
66 | break | |
67 | endif | |
68 | endforeach | |
69 | ||
70 | if have | |
81e06775 | 71 | file = files(tuple[0] + '.xml') |
a7052c6e | 72 | source_xml_files += file |
81e06775 ZJS |
73 | if tuple[0].startswith('org.freedesktop.') |
74 | dbus_docs += file | |
75 | endif | |
f12c5d36 ZJS |
76 | |
77 | if xsltproc.found() | |
78 | p1 = custom_target( | |
79 | man, | |
80 | input : xml, | |
81 | output : [man] + manaliases, | |
82 | command : xslt_cmd + [custom_man_xsl, '@INPUT@'], | |
c18dde32 | 83 | depends : man_page_depends, |
f12c5d36 ZJS |
84 | install : want_man, |
85 | install_dir : mandirn) | |
86 | man_pages += p1 | |
87 | ||
88 | p2 = [] | |
89 | foreach htmlalias : htmlaliases | |
90 | link = custom_target( | |
91 | htmlalias, | |
92 | output : htmlalias, | |
93 | command : [ln, '-fs', html, '@OUTPUT@']) | |
94 | if want_html | |
d537bf72 | 95 | meson.add_install_script(sh, '-c', ln_s.format(docdir / 'html' / html, docdir / 'html' / htmlalias)) |
f12c5d36 ZJS |
96 | p2 += link |
97 | endif | |
98 | html_pages += link | |
99 | endforeach | |
100 | ||
101 | p3 = custom_target( | |
102 | html, | |
103 | input : xml, | |
104 | output : html, | |
105 | command : xslt_cmd + [custom_html_xsl, '@INPUT@'], | |
c18dde32 | 106 | depends : [man_page_depends, p2], |
f12c5d36 ZJS |
107 | install : want_html, |
108 | install_dir : docdir / 'html') | |
109 | html_pages += p3 | |
110 | endif | |
37efbbd8 ZJS |
111 | else |
112 | message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition)) | |
113 | endif | |
5c23128d ZJS |
114 | endforeach |
115 | ||
116 | ############################################################ | |
117 | ||
68a06b3c | 118 | have_lxml = run_command(xml_helper_py, check: false).returncode() == 0 |
b184e8fe | 119 | if not have_lxml |
37efbbd8 | 120 | message('python-lxml not available, not making man page indices') |
b184e8fe ZJS |
121 | endif |
122 | ||
5c23128d | 123 | systemd_directives_xml = custom_target( |
37efbbd8 | 124 | 'systemd.directives.xml', |
28223088 | 125 | input : ['directives-template.xml', source_xml_files], |
37efbbd8 | 126 | output : 'systemd.directives.xml', |
c18dde32 | 127 | depends : man_page_depends, |
28223088 | 128 | command : [make_directive_index_py, '@OUTPUT@', '@INPUT@']) |
5c23128d ZJS |
129 | |
130 | nonindex_xml_files = source_xml_files + [systemd_directives_xml] | |
131 | systemd_index_xml = custom_target( | |
37efbbd8 ZJS |
132 | 'systemd.index.xml', |
133 | input : nonindex_xml_files, | |
134 | output : 'systemd.index.xml', | |
135 | command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files) | |
5c23128d | 136 | |
b7507787 ZJS |
137 | foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml], |
138 | ['systemd.index', '7', systemd_index_xml]] : [] | |
37efbbd8 ZJS |
139 | stem = tuple[0] |
140 | section = tuple[1] | |
141 | xml = tuple[2] | |
142 | ||
143 | html = stem + '.html' | |
144 | man = stem + '.' + section | |
145 | ||
fce9abb2 | 146 | mandirn = get_option('mandir') / ('man' + section) |
37efbbd8 ZJS |
147 | |
148 | p1 = custom_target( | |
149 | man, | |
150 | input : xml, | |
151 | output : man, | |
152 | command : xslt_cmd + [custom_man_xsl, '@INPUT@'], | |
153 | install : want_man and have_lxml, | |
154 | install_dir : mandirn) | |
5a8b1640 | 155 | man_pages += p1 |
37efbbd8 | 156 | |
38acf8a7 | 157 | p2 = [] |
064d9ef0 MB |
158 | if html == 'systemd.index.html' |
159 | htmlalias = 'index.html' | |
38acf8a7 | 160 | link = custom_target( |
064d9ef0 MB |
161 | htmlalias, |
162 | input : p2, | |
163 | output : htmlalias, | |
0f4c4f38 | 164 | command : [ln, '-fs', html, '@OUTPUT@']) |
064d9ef0 | 165 | if want_html |
d537bf72 | 166 | meson.add_install_script(sh, '-c', ln_s.format(docdir / 'html' / html, docdir / 'html' / htmlalias)) |
5a8b1640 | 167 | p2 += link |
064d9ef0 | 168 | endif |
5a8b1640 | 169 | html_pages += link |
064d9ef0 | 170 | endif |
38acf8a7 ZJS |
171 | |
172 | p3 = custom_target( | |
173 | html, | |
174 | input : xml, | |
175 | output : html, | |
176 | command : xslt_cmd + [custom_html_xsl, '@INPUT@'], | |
c18dde32 | 177 | depends : [man_page_depends, p2], |
38acf8a7 | 178 | install : want_html and have_lxml, |
fce9abb2 | 179 | install_dir : docdir / 'html') |
5a8b1640 | 180 | html_pages += p3 |
5c23128d | 181 | endforeach |
527d43d7 | 182 | |
6939fb9e ZJS |
183 | # Cannot use run_target because those targets are used in depends |
184 | # Also see https://github.com/mesonbuild/meson/issues/368. | |
9c84bb78 | 185 | man = custom_target( |
a923e085 | 186 | 'man', |
9c84bb78 | 187 | output : 'man', |
a923e085 | 188 | depends : man_pages, |
0f4c4f38 | 189 | command : [echo]) |
a923e085 | 190 | |
e85a690b | 191 | html = custom_target( |
a923e085 | 192 | 'html', |
a923e085 | 193 | output : 'html', |
e85a690b | 194 | depends : html_pages, |
0f4c4f38 | 195 | command : [echo]) |
a923e085 | 196 | |
7c5fd251 ZJS |
197 | if rsync.found() |
198 | run_target( | |
199 | 'doc-sync', | |
200 | depends : man_pages + html_pages, | |
3c1f396f AK |
201 | command : [sync_docs_py, |
202 | '--version', | |
203 | '@0@'.format(meson.project_version()), | |
7c5fd251 ZJS |
204 | meson.current_build_dir(), |
205 | get_option('www-target')]) | |
206 | endif | |
18af8932 ZJS |
207 | |
208 | ############################################################ | |
209 | ||
195a8a93 ZJS |
210 | buildroot_substs = configuration_data() |
211 | buildroot_substs.set_quoted('BUILD_ROOT', project_build_root) | |
212 | ||
e9bbff18 ZJS |
213 | configure_file( |
214 | input : 'man.in', | |
215 | output : 'man', | |
195a8a93 | 216 | configuration : buildroot_substs) |
e9bbff18 ZJS |
217 | |
218 | configure_file( | |
219 | input : 'html.in', | |
220 | output : 'html', | |
195a8a93 | 221 | configuration : buildroot_substs) |
f12c5d36 ZJS |
222 | |
223 | ############################################################ | |
224 | ||
225 | update_dbus_docs = custom_target( | |
d2ec38e2 | 226 | 'update-dbus-docs-impl', |
f12c5d36 ZJS |
227 | output : 'update-dbus-docs', |
228 | command : [update_dbus_docs_py, '--build-dir', project_build_root, '@INPUT@'], | |
229 | input : dbus_docs) | |
230 | ||
231 | if conf.get('BUILD_MODE_DEVELOPER') == 1 | |
232 | test('dbus-docs-fresh', | |
233 | update_dbus_docs_py, | |
02e0f430 | 234 | suite : 'dist', |
e93ada98 DDM |
235 | args : ['--build-dir', project_build_root, '--test', dbus_docs], |
236 | depends : dbus_programs) | |
3691e7fc AK |
237 | |
238 | test('check-version-history', | |
239 | check_version_history_py, | |
240 | suite : 'dist', | |
241 | args : source_xml_files) | |
f12c5d36 ZJS |
242 | endif |
243 | ||
244 | update_man_rules = custom_target( | |
d2ec38e2 | 245 | 'update-man-rules-impl', |
f12c5d36 | 246 | output : 'update-man-rules', |
77d45f1f ZJS |
247 | command : [update_man_rules_py, |
248 | '@0@/man/*.xml'.format(project_source_root), | |
249 | '@0@/rules/meson.build'.format(meson.current_source_dir())], | |
c18dde32 | 250 | depends : man_page_depends) |
e98d4c35 YW |
251 | |
252 | ############################################################ | |
253 | ||
254 | simple_examples = files( | |
255 | 'event-quick-child.c', | |
256 | 'hwdb-usb-device.c', | |
257 | 'id128-app-specific.c', | |
258 | 'inotify-watch-tmp.c', | |
259 | 'journal-enumerate-fields.c', | |
260 | 'journal-iterate-foreach.c', | |
261 | 'journal-iterate-poll.c', | |
262 | 'journal-iterate-unique.c', | |
263 | 'journal-iterate-wait.c', | |
264 | 'journal-stream-fd.c', | |
265 | 'logcontrol-example.c', | |
266 | 'notify-selfcontained-example.c', | |
267 | 'path-documents.c', | |
268 | 'print-unit-path-call-method.c', | |
269 | 'print-unit-path.c', | |
270 | 'sd-bus-container-append.c', | |
271 | 'sd-bus-container-read.c', | |
272 | 'sd_bus_error-example.c', | |
273 | 'sd_bus_service_reconnect.c', | |
274 | 'send-unit-files-changed.c', | |
275 | 'vtable-example.c', | |
276 | ) | |
277 | ||
278 | examples = [] | |
279 | foreach example : simple_examples | |
280 | examples += [ { 'file' : example } ] | |
281 | endforeach | |
282 | ||
283 | if conf.get('HAVE_GLIB') == 1 | |
284 | examples += [ | |
285 | { | |
286 | 'file' : files('glib-event-glue.c'), | |
287 | 'opts' : [ | |
288 | '-I', libglib.get_variable('includedir') / 'glib-2.0', | |
289 | '-I', libglib.get_variable('libdir') / 'glib-2.0/include', | |
290 | ], | |
291 | }, | |
292 | ] | |
293 | endif | |
294 | ||
295 | default_args = [ | |
296 | cc.cmd_array(), | |
297 | '-c', | |
298 | '-x', 'c', | |
299 | '-pedantic', | |
300 | '-Wall', | |
301 | '-Werror', | |
302 | '-Wextra', | |
303 | '-Wno-unused-parameter', | |
304 | '-o', '/dev/null', | |
305 | '-I', meson.current_source_dir() / '../src', | |
306 | ] | |
307 | ||
308 | std_args_in = [ | |
94ad7098 | 309 | [ '-std=c90', '-Wno-pedantic', '-Wno-variadic-macros', ], |
040cb664 YW |
310 | [ '-std=c99', ], |
311 | [ '-std=c11', ], | |
312 | [ '-std=c17', ], | |
313 | [ '-std=c23', ], | |
94ad7098 | 314 | [ '-std=gnu90', '-Wno-pedantic', '-Wno-variadic-macros', ], |
e98d4c35 YW |
315 | [ '-std=gnu99', ], |
316 | [ '-std=gnu11', ], | |
317 | [ '-std=gnu17', ], | |
318 | [ '-std=gnu23', ], | |
319 | ] | |
320 | ||
321 | std_args = [] | |
322 | foreach std : std_args_in | |
323 | if cc.has_argument(std[0]) | |
324 | std_args += [std] | |
325 | endif | |
326 | endforeach | |
327 | ||
328 | foreach item : examples | |
329 | foreach std : std_args | |
330 | file = item.get('file') | |
331 | test('cc-' + fs.stem(file) + '-' + std[0].split('=')[1], | |
332 | env, | |
333 | suite : 'example', | |
334 | args : default_args + std + item.get('opts', []) + [file]) | |
335 | endforeach | |
336 | endforeach |