]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/meson.build
travis: use UBSan checks from OSS-Fuzz
[thirdparty/systemd.git] / man / meson.build
CommitLineData
3a726fcd 1# SPDX-License-Identifier: LGPL-2.1+
3a726fcd 2
5c23128d
ZJS
3# This is lame, I know, but meson has no other include mechanism
4subdir('rules')
5
527d43d7
ZJS
6want_man = get_option('man')
7want_html = get_option('html')
8xsltproc = find_program('xsltproc',
4390be30
ZJS
9 required : want_man == 'true' or want_html == 'true')
10want_man = want_man != 'false' and xsltproc.found()
11want_html = want_html != 'false' and xsltproc.found()
527d43d7 12
5c23128d 13xsltproc_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
25custom_man_xsl = files('custom-man.xsl')
527d43d7 26custom_html_xsl = files('custom-html.xsl')
37efbbd8 27xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
04e3eb46
ZJS
28
29custom_entities_ent = configure_file(
37efbbd8
ZJS
30 input : 'custom-entities.ent.in',
31 output : 'custom-entities.ent',
32 configuration : conf)
5c23128d 33
527d43d7
ZJS
34man_pages = []
35html_pages = []
36source_xml_files = []
559d215b 37foreach tuple : xsltproc.found() ? manpages : []
37efbbd8
ZJS
38 stem = tuple[0]
39 section = tuple[1]
40 aliases = tuple[2]
41 condition = tuple[3]
42
43 xml = stem + '.xml'
44 html = stem + '.html'
45 man = stem + '.' + section
46
47 manaliases = []
48 htmlaliases = []
49 foreach alias : aliases
5a8b1640
ZJS
50 manaliases += alias + '.' + section
51 htmlaliases += alias + '.html'
37efbbd8
ZJS
52 endforeach
53
54 mandirn = join_paths(get_option('mandir'), 'man' + section)
55
349cc4a5 56 if condition == '' or conf.get(condition) == 1
37efbbd8
ZJS
57 p1 = custom_target(
58 man,
59 input : xml,
60 output : [man] + manaliases,
61 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
62 depend_files : custom_entities_ent,
63 install : want_man,
64 install_dir : mandirn)
5a8b1640 65 man_pages += p1
37efbbd8 66
38acf8a7 67 p2 = []
488477d1 68 foreach htmlalias : htmlaliases
38acf8a7 69 link = custom_target(
488477d1
ZJS
70 htmlalias,
71 input : p2,
72 output : htmlalias,
73 command : ['ln', '-fs', html, '@OUTPUT@'])
74 if want_html
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)
5a8b1640 78 p2 += link
488477d1 79 endif
5a8b1640 80 html_pages += link
488477d1
ZJS
81 endforeach
82
38acf8a7
ZJS
83 p3 = custom_target(
84 html,
85 input : xml,
86 output : html,
87 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
88 depend_files : custom_entities_ent,
89 depends : p2,
90 install : want_html,
91 install_dir : join_paths(docdir, 'html'))
5a8b1640 92 html_pages += p3
38acf8a7 93
37efbbd8
ZJS
94 source_xml_files += files(tuple[0] + '.xml')
95 else
96 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
97 endif
5c23128d
ZJS
98endforeach
99
100############################################################
101
b184e8fe
ZJS
102have_lxml = run_command(xml_helper_py).returncode() == 0
103if not have_lxml
37efbbd8 104 message('python-lxml not available, not making man page indices')
b184e8fe
ZJS
105endif
106
5c23128d 107systemd_directives_xml = custom_target(
37efbbd8
ZJS
108 'systemd.directives.xml',
109 input : source_xml_files,
110 output : 'systemd.directives.xml',
111 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
5c23128d
ZJS
112
113nonindex_xml_files = source_xml_files + [systemd_directives_xml]
114systemd_index_xml = custom_target(
37efbbd8
ZJS
115 'systemd.index.xml',
116 input : nonindex_xml_files,
117 output : 'systemd.index.xml',
118 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
5c23128d 119
b7507787
ZJS
120foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml],
121 ['systemd.index', '7', systemd_index_xml]] : []
37efbbd8
ZJS
122 stem = tuple[0]
123 section = tuple[1]
124 xml = tuple[2]
125
126 html = stem + '.html'
127 man = stem + '.' + section
128
129 mandirn = join_paths(get_option('mandir'), 'man' + section)
130
131 p1 = custom_target(
132 man,
133 input : xml,
134 output : man,
135 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
136 install : want_man and have_lxml,
137 install_dir : mandirn)
5a8b1640 138 man_pages += p1
37efbbd8 139
38acf8a7 140 p2 = []
064d9ef0
MB
141 if html == 'systemd.index.html'
142 htmlalias = 'index.html'
38acf8a7 143 link = custom_target(
064d9ef0
MB
144 htmlalias,
145 input : p2,
146 output : htmlalias,
147 command : ['ln', '-fs', html, '@OUTPUT@'])
148 if want_html
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)
5a8b1640 152 p2 += link
064d9ef0 153 endif
5a8b1640 154 html_pages += link
064d9ef0 155 endif
38acf8a7
ZJS
156
157 p3 = custom_target(
158 html,
159 input : xml,
160 output : html,
161 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
162 depend_files : custom_entities_ent,
163 depends : p2,
164 install : want_html and have_lxml,
165 install_dir : join_paths(docdir, 'html'))
5a8b1640 166 html_pages += p3
5c23128d 167endforeach
527d43d7 168
6939fb9e
ZJS
169# Cannot use run_target because those targets are used in depends
170# Also see https://github.com/mesonbuild/meson/issues/368.
9c84bb78 171man = custom_target(
a923e085 172 'man',
9c84bb78 173 output : 'man',
a923e085
ZJS
174 depends : man_pages,
175 command : ['echo'])
176
e85a690b 177html = custom_target(
a923e085 178 'html',
a923e085 179 output : 'html',
e85a690b 180 depends : html_pages,
a923e085
ZJS
181 command : ['echo'])
182
183run_target(
184 'doc-sync',
185 depends : man_pages + html_pages,
186 command : ['rsync', '-rlv',
187 '--delete-excluded',
188 '--include=man',
189 '--include=*.html',
190 '--exclude=*',
191 '--omit-dir-times',
192 meson.current_build_dir(),
193 get_option('www-target')])
18af8932
ZJS
194
195############################################################
196
197if git.found()
e85a690b 198 custom_target(
18af8932 199 'update-man-rules',
e85a690b 200 output : 'update-man-rules',
18af8932
ZJS
201 command : ['sh', '-c',
202 'cd @0@ && '.format(meson.build_root()) +
1485aacb 203 'python3 @0@/tools/make-man-rules.py $(git ls-files ":/man/*.xml") >t && '.format(project_source_root) +
18af8932
ZJS
204 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
205 depend_files : custom_entities_ent)
206endif
e9bbff18
ZJS
207
208############################################################
209
210configure_file(
211 input : 'man.in',
212 output : 'man',
213 configuration : substs)
214
215configure_file(
216 input : 'html.in',
217 output : 'html',
218 configuration : substs)