]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/meson.build
man: fix incorrectly placed full stop
[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 = []
81e06775 37dbus_docs = []
559d215b 38foreach tuple : xsltproc.found() ? manpages : []
37efbbd8
ZJS
39 stem = tuple[0]
40 section = tuple[1]
41 aliases = tuple[2]
42 condition = tuple[3]
43
44 xml = stem + '.xml'
45 html = stem + '.html'
46 man = stem + '.' + section
47
48 manaliases = []
49 htmlaliases = []
50 foreach alias : aliases
5a8b1640
ZJS
51 manaliases += alias + '.' + section
52 htmlaliases += alias + '.html'
37efbbd8
ZJS
53 endforeach
54
55 mandirn = join_paths(get_option('mandir'), 'man' + section)
56
349cc4a5 57 if condition == '' or conf.get(condition) == 1
37efbbd8
ZJS
58 p1 = custom_target(
59 man,
60 input : xml,
61 output : [man] + manaliases,
62 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
63 depend_files : custom_entities_ent,
64 install : want_man,
65 install_dir : mandirn)
5a8b1640 66 man_pages += p1
37efbbd8 67
38acf8a7 68 p2 = []
488477d1 69 foreach htmlalias : htmlaliases
38acf8a7 70 link = custom_target(
488477d1 71 htmlalias,
488477d1
ZJS
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
81e06775
ZJS
94 file = files(tuple[0] + '.xml')
95 source_xml_files += file
96 if tuple[0].startswith('org.freedesktop.')
97 dbus_docs += file
98 endif
37efbbd8
ZJS
99 else
100 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
101 endif
5c23128d
ZJS
102endforeach
103
104############################################################
105
b184e8fe
ZJS
106have_lxml = run_command(xml_helper_py).returncode() == 0
107if not have_lxml
37efbbd8 108 message('python-lxml not available, not making man page indices')
b184e8fe
ZJS
109endif
110
5c23128d 111systemd_directives_xml = custom_target(
37efbbd8 112 'systemd.directives.xml',
28223088 113 input : ['directives-template.xml', source_xml_files],
37efbbd8 114 output : 'systemd.directives.xml',
28223088 115 command : [make_directive_index_py, '@OUTPUT@', '@INPUT@'])
5c23128d
ZJS
116
117nonindex_xml_files = source_xml_files + [systemd_directives_xml]
118systemd_index_xml = custom_target(
37efbbd8
ZJS
119 'systemd.index.xml',
120 input : nonindex_xml_files,
121 output : 'systemd.index.xml',
122 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
5c23128d 123
b7507787
ZJS
124foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml],
125 ['systemd.index', '7', systemd_index_xml]] : []
37efbbd8
ZJS
126 stem = tuple[0]
127 section = tuple[1]
128 xml = tuple[2]
129
130 html = stem + '.html'
131 man = stem + '.' + section
132
133 mandirn = join_paths(get_option('mandir'), 'man' + section)
134
135 p1 = custom_target(
136 man,
137 input : xml,
138 output : man,
139 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
140 install : want_man and have_lxml,
141 install_dir : mandirn)
5a8b1640 142 man_pages += p1
37efbbd8 143
38acf8a7 144 p2 = []
064d9ef0
MB
145 if html == 'systemd.index.html'
146 htmlalias = 'index.html'
38acf8a7 147 link = custom_target(
064d9ef0
MB
148 htmlalias,
149 input : p2,
150 output : htmlalias,
151 command : ['ln', '-fs', html, '@OUTPUT@'])
152 if want_html
153 dst = join_paths(docdir, 'html', htmlalias)
154 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
155 meson.add_install_script('sh', '-c', cmd)
5a8b1640 156 p2 += link
064d9ef0 157 endif
5a8b1640 158 html_pages += link
064d9ef0 159 endif
38acf8a7
ZJS
160
161 p3 = custom_target(
162 html,
163 input : xml,
164 output : html,
165 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
166 depend_files : custom_entities_ent,
167 depends : p2,
168 install : want_html and have_lxml,
169 install_dir : join_paths(docdir, 'html'))
5a8b1640 170 html_pages += p3
5c23128d 171endforeach
527d43d7 172
6939fb9e
ZJS
173# Cannot use run_target because those targets are used in depends
174# Also see https://github.com/mesonbuild/meson/issues/368.
9c84bb78 175man = custom_target(
a923e085 176 'man',
9c84bb78 177 output : 'man',
a923e085
ZJS
178 depends : man_pages,
179 command : ['echo'])
180
e85a690b 181html = custom_target(
a923e085 182 'html',
a923e085 183 output : 'html',
e85a690b 184 depends : html_pages,
a923e085
ZJS
185 command : ['echo'])
186
187run_target(
188 'doc-sync',
189 depends : man_pages + html_pages,
190 command : ['rsync', '-rlv',
191 '--delete-excluded',
192 '--include=man',
193 '--include=*.html',
194 '--exclude=*',
195 '--omit-dir-times',
196 meson.current_build_dir(),
197 get_option('www-target')])
18af8932
ZJS
198
199############################################################
200
81e06775
ZJS
201if dbus_docs.length() > 0
202 custom_target(
203 'update-dbus-docs',
204 output : 'update-dbus-docs',
205 command : ['python3',
206 '@0@/tools/update-dbus-docs.py'.format(project_source_root),
207 '--build-dir=@0@'.format(project_build_root),
208 '@INPUT@'],
209 input : dbus_docs)
210endif
211
212############################################################
213
18af8932 214if git.found()
e85a690b 215 custom_target(
18af8932 216 'update-man-rules',
e85a690b 217 output : 'update-man-rules',
18af8932
ZJS
218 command : ['sh', '-c',
219 'cd @0@ && '.format(meson.build_root()) +
06689b8d 220 'python3 @0@/tools/update-man-rules.py $(git ls-files ":/man/*.xml") >t && '.format(project_source_root) +
18af8932
ZJS
221 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
222 depend_files : custom_entities_ent)
223endif
e9bbff18
ZJS
224
225############################################################
226
227configure_file(
228 input : 'man.in',
229 output : 'man',
230 configuration : substs)
231
232configure_file(
233 input : 'html.in',
234 output : 'html',
235 configuration : substs)