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