]>
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 | ||
53 | if condition == '' or conf.get(condition, 0) == 1 | |
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 | ||
64 | p2 = custom_target( | |
65 | html, | |
66 | input : xml, | |
488477d1 | 67 | output : html, |
37efbbd8 ZJS |
68 | command : xslt_cmd + [custom_html_xsl, '@INPUT@'], |
69 | depend_files : custom_entities_ent, | |
70 | install : want_html, | |
71 | install_dir : join_paths(docdir, 'html')) | |
72 | html_pages += [p2] | |
73 | ||
488477d1 ZJS |
74 | foreach htmlalias : htmlaliases |
75 | p3 = custom_target( | |
76 | htmlalias, | |
77 | input : p2, | |
78 | output : htmlalias, | |
79 | command : ['ln', '-fs', html, '@OUTPUT@']) | |
80 | if want_html | |
81 | dst = join_paths(docdir, 'html', htmlalias) | |
82 | cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst) | |
83 | meson.add_install_script('sh', '-c', cmd) | |
84 | endif | |
85 | html_pages += [p3] | |
86 | endforeach | |
87 | ||
37efbbd8 ZJS |
88 | source_xml_files += files(tuple[0] + '.xml') |
89 | else | |
90 | message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition)) | |
91 | endif | |
5c23128d ZJS |
92 | endforeach |
93 | ||
94 | ############################################################ | |
95 | ||
b184e8fe ZJS |
96 | have_lxml = run_command(xml_helper_py).returncode() == 0 |
97 | if not have_lxml | |
37efbbd8 | 98 | message('python-lxml not available, not making man page indices') |
b184e8fe ZJS |
99 | endif |
100 | ||
5c23128d | 101 | systemd_directives_xml = custom_target( |
37efbbd8 ZJS |
102 | 'systemd.directives.xml', |
103 | input : source_xml_files, | |
104 | output : 'systemd.directives.xml', | |
105 | command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files) | |
5c23128d ZJS |
106 | |
107 | nonindex_xml_files = source_xml_files + [systemd_directives_xml] | |
108 | systemd_index_xml = custom_target( | |
37efbbd8 ZJS |
109 | 'systemd.index.xml', |
110 | input : nonindex_xml_files, | |
111 | output : 'systemd.index.xml', | |
112 | command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files) | |
5c23128d ZJS |
113 | |
114 | foreach tuple : [['systemd.directives', '7', systemd_directives_xml], | |
115 | ['systemd.index', '7', systemd_index_xml]] | |
37efbbd8 ZJS |
116 | stem = tuple[0] |
117 | section = tuple[1] | |
118 | xml = tuple[2] | |
119 | ||
120 | html = stem + '.html' | |
121 | man = stem + '.' + section | |
122 | ||
123 | mandirn = join_paths(get_option('mandir'), 'man' + section) | |
124 | ||
125 | p1 = custom_target( | |
126 | man, | |
127 | input : xml, | |
128 | output : man, | |
129 | command : xslt_cmd + [custom_man_xsl, '@INPUT@'], | |
130 | install : want_man and have_lxml, | |
131 | install_dir : mandirn) | |
132 | man_pages += [p1] | |
133 | ||
134 | p2 = custom_target( | |
135 | html, | |
136 | input : xml, | |
137 | output : html, | |
138 | command : xslt_cmd + [custom_html_xsl, '@INPUT@'], | |
139 | install : want_html and have_lxml, | |
140 | install_dir : join_paths(docdir, 'html')) | |
141 | html_pages += [p2] | |
064d9ef0 MB |
142 | |
143 | if html == 'systemd.index.html' | |
144 | htmlalias = 'index.html' | |
145 | p3 = custom_target( | |
146 | htmlalias, | |
147 | input : p2, | |
148 | output : htmlalias, | |
149 | command : ['ln', '-fs', html, '@OUTPUT@']) | |
150 | if want_html | |
151 | dst = join_paths(docdir, 'html', htmlalias) | |
152 | cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst) | |
153 | meson.add_install_script('sh', '-c', cmd) | |
154 | endif | |
155 | html_pages += [p3] | |
156 | endif | |
5c23128d | 157 | endforeach |
527d43d7 | 158 | |
9c84bb78 ZJS |
159 | # cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved |
160 | man = custom_target( | |
a923e085 | 161 | 'man', |
9c84bb78 | 162 | output : 'man', |
a923e085 ZJS |
163 | depends : man_pages, |
164 | command : ['echo']) | |
165 | ||
166 | html = run_target( | |
167 | 'html', | |
168 | depends : html_pages, | |
169 | output : 'html', | |
170 | command : ['echo']) | |
171 | ||
172 | run_target( | |
173 | 'doc-sync', | |
174 | depends : man_pages + html_pages, | |
175 | command : ['rsync', '-rlv', | |
176 | '--delete-excluded', | |
177 | '--include=man', | |
178 | '--include=*.html', | |
179 | '--exclude=*', | |
180 | '--omit-dir-times', | |
181 | meson.current_build_dir(), | |
182 | get_option('www-target')]) | |
18af8932 ZJS |
183 | |
184 | ############################################################ | |
185 | ||
186 | if git.found() | |
187 | run_target( | |
188 | 'update-man-rules', | |
189 | # slightly strange syntax because of | |
190 | # https://github.com/mesonbuild/meson/issues/1643 | |
191 | # and https://github.com/mesonbuild/meson/issues/1512 | |
192 | command : ['sh', '-c', | |
193 | 'cd @0@ && '.format(meson.build_root()) + | |
194 | 'python3 @0@/tools/make-man-rules.py --meson `git ls-files ":/man/*.xml"` >t && '.format(meson.source_root()) + | |
195 | 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())], | |
196 | depend_files : custom_entities_ent) | |
197 | endif |