]>
Commit | Line | Data |
---|---|---|
5c23128d ZJS |
1 | # This is lame, I know, but meson has no other include mechanism |
2 | subdir('rules') | |
3 | ||
527d43d7 ZJS |
4 | want_man = get_option('man') |
5 | want_html = get_option('html') | |
6 | xsltproc = find_program('xsltproc', | |
4390be30 ZJS |
7 | required : want_man == 'true' or want_html == 'true') |
8 | want_man = want_man != 'false' and xsltproc.found() | |
9 | want_html = want_html != 'false' and xsltproc.found() | |
527d43d7 | 10 | |
5c23128d | 11 | xsltproc_flags = [ |
37efbbd8 ZJS |
12 | '--nonet', |
13 | '--xinclude', | |
f2adcd22 | 14 | '--maxdepth', '9000', |
37efbbd8 ZJS |
15 | '--stringparam', 'man.output.quietly', '1', |
16 | '--stringparam', 'funcsynopsis.style', 'ansi', | |
17 | '--stringparam', 'man.authors.section.enabled', '0', | |
18 | '--stringparam', 'man.copyright.section.enabled', '0', | |
19 | '--stringparam', 'systemd.version', '@0@'.format(meson.project_version()), | |
20 | '--path', | |
21 | '@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())] | |
5c23128d ZJS |
22 | |
23 | custom_man_xsl = files('custom-man.xsl') | |
527d43d7 | 24 | custom_html_xsl = files('custom-html.xsl') |
37efbbd8 | 25 | xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags |
04e3eb46 ZJS |
26 | |
27 | custom_entities_ent = configure_file( | |
37efbbd8 ZJS |
28 | input : 'custom-entities.ent.in', |
29 | output : 'custom-entities.ent', | |
30 | configuration : conf) | |
5c23128d | 31 | |
527d43d7 ZJS |
32 | man_pages = [] |
33 | html_pages = [] | |
34 | source_xml_files = [] | |
5c23128d | 35 | foreach tuple : manpages |
37efbbd8 ZJS |
36 | stem = tuple[0] |
37 | section = tuple[1] | |
38 | aliases = tuple[2] | |
39 | condition = tuple[3] | |
40 | ||
41 | xml = stem + '.xml' | |
42 | html = stem + '.html' | |
43 | man = stem + '.' + section | |
44 | ||
45 | manaliases = [] | |
46 | htmlaliases = [] | |
47 | foreach alias : aliases | |
48 | manaliases += [alias + '.' + section] | |
49 | htmlaliases += [alias + '.html'] | |
50 | endforeach | |
51 | ||
52 | mandirn = join_paths(get_option('mandir'), 'man' + section) | |
53 | ||
349cc4a5 | 54 | if condition == '' or conf.get(condition) == 1 |
37efbbd8 ZJS |
55 | p1 = custom_target( |
56 | man, | |
57 | input : xml, | |
58 | output : [man] + manaliases, | |
59 | command : xslt_cmd + [custom_man_xsl, '@INPUT@'], | |
60 | depend_files : custom_entities_ent, | |
61 | install : want_man, | |
62 | install_dir : mandirn) | |
63 | man_pages += [p1] | |
64 | ||
38acf8a7 | 65 | p2 = [] |
488477d1 | 66 | foreach htmlalias : htmlaliases |
38acf8a7 | 67 | link = custom_target( |
488477d1 ZJS |
68 | htmlalias, |
69 | input : p2, | |
70 | output : htmlalias, | |
71 | command : ['ln', '-fs', html, '@OUTPUT@']) | |
72 | if want_html | |
73 | dst = join_paths(docdir, 'html', htmlalias) | |
74 | cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst) | |
75 | meson.add_install_script('sh', '-c', cmd) | |
38acf8a7 | 76 | p2 += [link] |
488477d1 | 77 | endif |
38acf8a7 | 78 | html_pages += [link] |
488477d1 ZJS |
79 | endforeach |
80 | ||
38acf8a7 ZJS |
81 | p3 = custom_target( |
82 | html, | |
83 | input : xml, | |
84 | output : html, | |
85 | command : xslt_cmd + [custom_html_xsl, '@INPUT@'], | |
86 | depend_files : custom_entities_ent, | |
87 | depends : p2, | |
88 | install : want_html, | |
89 | install_dir : join_paths(docdir, 'html')) | |
90 | html_pages += [p3] | |
91 | ||
37efbbd8 ZJS |
92 | source_xml_files += files(tuple[0] + '.xml') |
93 | else | |
94 | message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition)) | |
95 | endif | |
5c23128d ZJS |
96 | endforeach |
97 | ||
98 | ############################################################ | |
99 | ||
b184e8fe ZJS |
100 | have_lxml = run_command(xml_helper_py).returncode() == 0 |
101 | if not have_lxml | |
37efbbd8 | 102 | message('python-lxml not available, not making man page indices') |
b184e8fe ZJS |
103 | endif |
104 | ||
5c23128d | 105 | systemd_directives_xml = custom_target( |
37efbbd8 ZJS |
106 | 'systemd.directives.xml', |
107 | input : source_xml_files, | |
108 | output : 'systemd.directives.xml', | |
109 | command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files) | |
5c23128d ZJS |
110 | |
111 | nonindex_xml_files = source_xml_files + [systemd_directives_xml] | |
112 | systemd_index_xml = custom_target( | |
37efbbd8 ZJS |
113 | 'systemd.index.xml', |
114 | input : nonindex_xml_files, | |
115 | output : 'systemd.index.xml', | |
116 | command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files) | |
5c23128d ZJS |
117 | |
118 | foreach tuple : [['systemd.directives', '7', systemd_directives_xml], | |
119 | ['systemd.index', '7', systemd_index_xml]] | |
37efbbd8 ZJS |
120 | stem = tuple[0] |
121 | section = tuple[1] | |
122 | xml = tuple[2] | |
123 | ||
124 | html = stem + '.html' | |
125 | man = stem + '.' + section | |
126 | ||
127 | mandirn = join_paths(get_option('mandir'), 'man' + section) | |
128 | ||
129 | p1 = custom_target( | |
130 | man, | |
131 | input : xml, | |
132 | output : man, | |
133 | command : xslt_cmd + [custom_man_xsl, '@INPUT@'], | |
134 | install : want_man and have_lxml, | |
135 | install_dir : mandirn) | |
136 | man_pages += [p1] | |
137 | ||
38acf8a7 | 138 | p2 = [] |
064d9ef0 MB |
139 | if html == 'systemd.index.html' |
140 | htmlalias = 'index.html' | |
38acf8a7 | 141 | link = custom_target( |
064d9ef0 MB |
142 | htmlalias, |
143 | input : p2, | |
144 | output : htmlalias, | |
145 | command : ['ln', '-fs', html, '@OUTPUT@']) | |
146 | if want_html | |
147 | dst = join_paths(docdir, 'html', htmlalias) | |
148 | cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst) | |
149 | meson.add_install_script('sh', '-c', cmd) | |
38acf8a7 | 150 | p2 += [link] |
064d9ef0 | 151 | endif |
38acf8a7 | 152 | html_pages += [link] |
064d9ef0 | 153 | endif |
38acf8a7 ZJS |
154 | |
155 | p3 = custom_target( | |
156 | html, | |
157 | input : xml, | |
158 | output : html, | |
159 | command : xslt_cmd + [custom_html_xsl, '@INPUT@'], | |
160 | depend_files : custom_entities_ent, | |
161 | depends : p2, | |
162 | install : want_html and have_lxml, | |
163 | install_dir : join_paths(docdir, 'html')) | |
164 | html_pages += [p3] | |
5c23128d | 165 | endforeach |
527d43d7 | 166 | |
9c84bb78 ZJS |
167 | # cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved |
168 | man = custom_target( | |
a923e085 | 169 | 'man', |
9c84bb78 | 170 | output : 'man', |
a923e085 ZJS |
171 | depends : man_pages, |
172 | command : ['echo']) | |
173 | ||
e85a690b | 174 | html = custom_target( |
a923e085 | 175 | 'html', |
a923e085 | 176 | output : 'html', |
e85a690b | 177 | depends : html_pages, |
a923e085 ZJS |
178 | command : ['echo']) |
179 | ||
180 | run_target( | |
181 | 'doc-sync', | |
182 | depends : man_pages + html_pages, | |
183 | command : ['rsync', '-rlv', | |
184 | '--delete-excluded', | |
185 | '--include=man', | |
186 | '--include=*.html', | |
187 | '--exclude=*', | |
188 | '--omit-dir-times', | |
189 | meson.current_build_dir(), | |
190 | get_option('www-target')]) | |
18af8932 ZJS |
191 | |
192 | ############################################################ | |
193 | ||
194 | if git.found() | |
e85a690b | 195 | custom_target( |
18af8932 | 196 | 'update-man-rules', |
e85a690b | 197 | output : 'update-man-rules', |
18af8932 ZJS |
198 | # slightly strange syntax because of |
199 | # https://github.com/mesonbuild/meson/issues/1643 | |
200 | # and https://github.com/mesonbuild/meson/issues/1512 | |
201 | command : ['sh', '-c', | |
202 | 'cd @0@ && '.format(meson.build_root()) + | |
0689f766 | 203 | 'python3 @0@/tools/make-man-rules.py `git ls-files ":/man/*.xml"` >t && '.format(meson.source_root()) + |
18af8932 ZJS |
204 | 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())], |
205 | depend_files : custom_entities_ent) | |
206 | endif |