]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/meson.build
meson: use alias_target in one place
[thirdparty/systemd.git] / man / meson.build
CommitLineData
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
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 28
46c4f8dc
ZJS
29custom_entities_ent = custom_target(
30 'custom-entities.ent',
37efbbd8
ZJS
31 input : 'custom-entities.ent.in',
32 output : 'custom-entities.ent',
46c4f8dc
ZJS
33 command : [meson_render_jinja2, config_h, '@INPUT@'],
34 capture : true)
5c23128d 35
527d43d7
ZJS
36man_pages = []
37html_pages = []
38source_xml_files = []
81e06775 39dbus_docs = []
559d215b 40foreach tuple : xsltproc.found() ? manpages : []
37efbbd8
ZJS
41 stem = tuple[0]
42 section = tuple[1]
43 aliases = tuple[2]
44 condition = tuple[3]
45
46 xml = stem + '.xml'
47 html = stem + '.html'
48 man = stem + '.' + section
49
50 manaliases = []
51 htmlaliases = []
52 foreach alias : aliases
5a8b1640
ZJS
53 manaliases += alias + '.' + section
54 htmlaliases += alias + '.html'
37efbbd8
ZJS
55 endforeach
56
fce9abb2 57 mandirn = get_option('mandir') / ('man' + section)
37efbbd8 58
349cc4a5 59 if condition == '' or conf.get(condition) == 1
37efbbd8
ZJS
60 p1 = custom_target(
61 man,
62 input : xml,
63 output : [man] + manaliases,
64 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
46c4f8dc 65 depends : custom_entities_ent,
37efbbd8
ZJS
66 install : want_man,
67 install_dir : mandirn)
5a8b1640 68 man_pages += p1
37efbbd8 69
38acf8a7 70 p2 = []
488477d1 71 foreach htmlalias : htmlaliases
38acf8a7 72 link = custom_target(
488477d1 73 htmlalias,
488477d1 74 output : htmlalias,
0f4c4f38 75 command : [ln, '-fs', html, '@OUTPUT@'])
488477d1 76 if want_html
fce9abb2 77 dst = docdir / 'html' / htmlalias
488477d1
ZJS
78 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
79 meson.add_install_script('sh', '-c', cmd)
5a8b1640 80 p2 += link
488477d1 81 endif
5a8b1640 82 html_pages += link
488477d1
ZJS
83 endforeach
84
38acf8a7
ZJS
85 p3 = custom_target(
86 html,
87 input : xml,
88 output : html,
89 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
46c4f8dc 90 depends : [custom_entities_ent, p2],
38acf8a7 91 install : want_html,
fce9abb2 92 install_dir : docdir / 'html')
5a8b1640 93 html_pages += p3
38acf8a7 94
81e06775
ZJS
95 file = files(tuple[0] + '.xml')
96 source_xml_files += file
97 if tuple[0].startswith('org.freedesktop.')
98 dbus_docs += file
99 endif
37efbbd8
ZJS
100 else
101 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
102 endif
5c23128d
ZJS
103endforeach
104
105############################################################
106
b184e8fe
ZJS
107have_lxml = run_command(xml_helper_py).returncode() == 0
108if not have_lxml
37efbbd8 109 message('python-lxml not available, not making man page indices')
b184e8fe
ZJS
110endif
111
5c23128d 112systemd_directives_xml = custom_target(
37efbbd8 113 'systemd.directives.xml',
28223088 114 input : ['directives-template.xml', source_xml_files],
37efbbd8 115 output : 'systemd.directives.xml',
670427a4 116 depends : custom_entities_ent,
28223088 117 command : [make_directive_index_py, '@OUTPUT@', '@INPUT@'])
5c23128d
ZJS
118
119nonindex_xml_files = source_xml_files + [systemd_directives_xml]
120systemd_index_xml = custom_target(
37efbbd8
ZJS
121 'systemd.index.xml',
122 input : nonindex_xml_files,
123 output : 'systemd.index.xml',
124 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
5c23128d 125
b7507787
ZJS
126foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml],
127 ['systemd.index', '7', systemd_index_xml]] : []
37efbbd8
ZJS
128 stem = tuple[0]
129 section = tuple[1]
130 xml = tuple[2]
131
132 html = stem + '.html'
133 man = stem + '.' + section
134
fce9abb2 135 mandirn = get_option('mandir') / ('man' + section)
37efbbd8
ZJS
136
137 p1 = custom_target(
138 man,
139 input : xml,
140 output : man,
141 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
142 install : want_man and have_lxml,
143 install_dir : mandirn)
5a8b1640 144 man_pages += p1
37efbbd8 145
38acf8a7 146 p2 = []
064d9ef0
MB
147 if html == 'systemd.index.html'
148 htmlalias = 'index.html'
38acf8a7 149 link = custom_target(
064d9ef0
MB
150 htmlalias,
151 input : p2,
152 output : htmlalias,
0f4c4f38 153 command : [ln, '-fs', html, '@OUTPUT@'])
064d9ef0 154 if want_html
fce9abb2 155 dst = docdir / 'html' / htmlalias
064d9ef0
MB
156 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
157 meson.add_install_script('sh', '-c', cmd)
5a8b1640 158 p2 += link
064d9ef0 159 endif
5a8b1640 160 html_pages += link
064d9ef0 161 endif
38acf8a7
ZJS
162
163 p3 = custom_target(
164 html,
165 input : xml,
166 output : html,
167 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
46c4f8dc 168 depends : [custom_entities_ent, p2],
38acf8a7 169 install : want_html and have_lxml,
fce9abb2 170 install_dir : docdir / 'html')
5a8b1640 171 html_pages += p3
5c23128d 172endforeach
527d43d7 173
6939fb9e
ZJS
174# Cannot use run_target because those targets are used in depends
175# Also see https://github.com/mesonbuild/meson/issues/368.
9c84bb78 176man = custom_target(
a923e085 177 'man',
9c84bb78 178 output : 'man',
a923e085 179 depends : man_pages,
0f4c4f38 180 command : [echo])
a923e085 181
e85a690b 182html = custom_target(
a923e085 183 'html',
a923e085 184 output : 'html',
e85a690b 185 depends : html_pages,
0f4c4f38 186 command : [echo])
a923e085 187
7c5fd251
ZJS
188if rsync.found()
189 run_target(
190 'doc-sync',
191 depends : man_pages + html_pages,
192 command : [rsync, '-rlv',
193 '--delete-excluded',
194 '--include=man',
195 '--include=*.html',
196 '--exclude=*',
197 '--omit-dir-times',
198 meson.current_build_dir(),
199 get_option('www-target')])
200endif
18af8932
ZJS
201
202############################################################
203
195a8a93
ZJS
204buildroot_substs = configuration_data()
205buildroot_substs.set_quoted('BUILD_ROOT', project_build_root)
206
e9bbff18
ZJS
207configure_file(
208 input : 'man.in',
209 output : 'man',
195a8a93 210 configuration : buildroot_substs)
e9bbff18
ZJS
211
212configure_file(
213 input : 'html.in',
214 output : 'html',
195a8a93 215 configuration : buildroot_substs)