]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/meson.build
Merge pull request #31648 from neighbourhoodie/review-content
[thirdparty/systemd.git] / man / meson.build
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2
3 # This is lame, I know, but meson has no other include mechanism
4 subdir('rules')
5
6 want_man = get_option('man')
7 want_html = get_option('html')
8 xsltproc = find_program('xsltproc',
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()
12
13 xsltproc_flags = [
14 '--nonet',
15 '--xinclude',
16 '--maxdepth', '9000',
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@:@2@'.format(meson.current_build_dir(),
24 meson.current_source_dir(),
25 libshared_build_dir)]
26
27 custom_man_xsl = files('custom-man.xsl')
28 custom_html_xsl = files('custom-html.xsl')
29 xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
30
31 custom_entities_ent = custom_target(
32 'custom-entities.ent',
33 input : 'custom-entities.ent.in',
34 output : 'custom-entities.ent',
35 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'])
36
37 man_page_depends += custom_entities_ent
38
39 man_pages = []
40 html_pages = []
41 source_xml_files = []
42 dbus_docs = []
43 foreach tuple : manpages
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
56 manaliases += alias + '.' + section
57 htmlaliases += alias + '.html'
58 endforeach
59
60 mandirn = get_option('mandir') / ('man' + section)
61
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
71 file = files(tuple[0] + '.xml')
72 source_xml_files += file
73 if tuple[0].startswith('org.freedesktop.')
74 dbus_docs += file
75 endif
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@'],
83 depends : man_page_depends,
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
95 meson.add_install_script(sh, '-c', ln_s.format(docdir / 'html' / html, docdir / 'html' / htmlalias))
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@'],
106 depends : [man_page_depends, p2],
107 install : want_html,
108 install_dir : docdir / 'html')
109 html_pages += p3
110 endif
111 else
112 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
113 endif
114 endforeach
115
116 ############################################################
117
118 have_lxml = run_command(xml_helper_py, check: false).returncode() == 0
119 if not have_lxml
120 message('python-lxml not available, not making man page indices')
121 endif
122
123 systemd_directives_xml = custom_target(
124 'systemd.directives.xml',
125 input : ['directives-template.xml', source_xml_files],
126 output : 'systemd.directives.xml',
127 depends : man_page_depends,
128 command : [make_directive_index_py, '@OUTPUT@', '@INPUT@'])
129
130 nonindex_xml_files = source_xml_files + [systemd_directives_xml]
131 systemd_index_xml = custom_target(
132 'systemd.index.xml',
133 input : nonindex_xml_files,
134 output : 'systemd.index.xml',
135 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
136
137 foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml],
138 ['systemd.index', '7', systemd_index_xml]] : []
139 stem = tuple[0]
140 section = tuple[1]
141 xml = tuple[2]
142
143 html = stem + '.html'
144 man = stem + '.' + section
145
146 mandirn = get_option('mandir') / ('man' + section)
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)
155 man_pages += p1
156
157 p2 = []
158 if html == 'systemd.index.html'
159 htmlalias = 'index.html'
160 link = custom_target(
161 htmlalias,
162 input : p2,
163 output : htmlalias,
164 command : [ln, '-fs', html, '@OUTPUT@'])
165 if want_html
166 meson.add_install_script(sh, '-c', ln_s.format(docdir / 'html' / html, docdir / 'html' / htmlalias))
167 p2 += link
168 endif
169 html_pages += link
170 endif
171
172 p3 = custom_target(
173 html,
174 input : xml,
175 output : html,
176 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
177 depends : [man_page_depends, p2],
178 install : want_html and have_lxml,
179 install_dir : docdir / 'html')
180 html_pages += p3
181 endforeach
182
183 # Cannot use run_target because those targets are used in depends
184 # Also see https://github.com/mesonbuild/meson/issues/368.
185 man = custom_target(
186 'man',
187 output : 'man',
188 depends : man_pages,
189 command : [echo])
190
191 html = custom_target(
192 'html',
193 output : 'html',
194 depends : html_pages,
195 command : [echo])
196
197 if rsync.found()
198 run_target(
199 'doc-sync',
200 depends : man_pages + html_pages,
201 command : [sync_docs_py,
202 '--version',
203 '@0@'.format(meson.project_version()),
204 meson.current_build_dir(),
205 get_option('www-target')])
206 endif
207
208 ############################################################
209
210 buildroot_substs = configuration_data()
211 buildroot_substs.set_quoted('BUILD_ROOT', project_build_root)
212
213 configure_file(
214 input : 'man.in',
215 output : 'man',
216 configuration : buildroot_substs)
217
218 configure_file(
219 input : 'html.in',
220 output : 'html',
221 configuration : buildroot_substs)
222
223 ############################################################
224
225 update_dbus_docs = custom_target(
226 'update-dbus-docs-impl',
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,
234 suite : 'dist',
235 args : ['--build-dir', project_build_root, '--test', dbus_docs],
236 depends : dbus_programs)
237
238 test('check-version-history',
239 check_version_history_py,
240 suite : 'dist',
241 args : source_xml_files)
242 endif
243
244 update_man_rules = custom_target(
245 'update-man-rules-impl',
246 output : 'update-man-rules',
247 command : [update_man_rules_py,
248 '@0@/man/*.xml'.format(project_source_root),
249 '@0@/rules/meson.build'.format(meson.current_source_dir())],
250 depends : man_page_depends)
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 = [
309 [ '-std=c90', '-Wno-pedantic', '-Wno-variadic-macros', ],
310 [ '-std=c99', ],
311 [ '-std=c11', ],
312 [ '-std=c17', ],
313 [ '-std=c23', ],
314 [ '-std=gnu90', '-Wno-pedantic', '-Wno-variadic-macros', ],
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