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