]>
Commit | Line | Data |
---|---|---|
5c23128d ZJS |
1 | # This is lame, I know, but meson has no other include mechanism |
2 | subdir('rules') | |
3 | ||
4 | # TODO: add regeneration rule: | |
5 | # python3 tools/make-man-rules.py --meson man/*xml > man/rules/meson.build | |
6 | ||
527d43d7 ZJS |
7 | want_man = get_option('man') |
8 | want_html = get_option('html') | |
9 | xsltproc = find_program('xsltproc', | |
4390be30 ZJS |
10 | required : want_man == 'true' or want_html == 'true') |
11 | want_man = want_man != 'false' and xsltproc.found() | |
12 | want_html = want_html != 'false' and xsltproc.found() | |
527d43d7 | 13 | |
5c23128d | 14 | xsltproc_flags = [ |
37efbbd8 ZJS |
15 | '--nonet', |
16 | '--xinclude', | |
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 = [] | |
5c23128d | 37 | foreach tuple : 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 | |
50 | manaliases += [alias + '.' + section] | |
51 | htmlaliases += [alias + '.html'] | |
52 | endforeach | |
53 | ||
54 | mandirn = join_paths(get_option('mandir'), 'man' + section) | |
55 | ||
56 | if condition == '' or conf.get(condition, 0) == 1 | |
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) | |
65 | man_pages += [p1] | |
66 | ||
67 | p2 = custom_target( | |
68 | html, | |
69 | input : xml, | |
70 | output : [html] + htmlaliases, | |
71 | command : xslt_cmd + [custom_html_xsl, '@INPUT@'], | |
72 | depend_files : custom_entities_ent, | |
73 | install : want_html, | |
74 | install_dir : join_paths(docdir, 'html')) | |
75 | html_pages += [p2] | |
76 | ||
77 | source_xml_files += files(tuple[0] + '.xml') | |
78 | else | |
79 | message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition)) | |
80 | endif | |
5c23128d ZJS |
81 | endforeach |
82 | ||
83 | ############################################################ | |
84 | ||
b184e8fe ZJS |
85 | have_lxml = run_command(xml_helper_py).returncode() == 0 |
86 | if not have_lxml | |
37efbbd8 | 87 | message('python-lxml not available, not making man page indices') |
b184e8fe ZJS |
88 | endif |
89 | ||
5c23128d | 90 | systemd_directives_xml = custom_target( |
37efbbd8 ZJS |
91 | 'systemd.directives.xml', |
92 | input : source_xml_files, | |
93 | output : 'systemd.directives.xml', | |
94 | command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files) | |
5c23128d ZJS |
95 | |
96 | nonindex_xml_files = source_xml_files + [systemd_directives_xml] | |
97 | systemd_index_xml = custom_target( | |
37efbbd8 ZJS |
98 | 'systemd.index.xml', |
99 | input : nonindex_xml_files, | |
100 | output : 'systemd.index.xml', | |
101 | command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files) | |
5c23128d ZJS |
102 | |
103 | foreach tuple : [['systemd.directives', '7', systemd_directives_xml], | |
104 | ['systemd.index', '7', systemd_index_xml]] | |
37efbbd8 ZJS |
105 | stem = tuple[0] |
106 | section = tuple[1] | |
107 | xml = tuple[2] | |
108 | ||
109 | html = stem + '.html' | |
110 | man = stem + '.' + section | |
111 | ||
112 | mandirn = join_paths(get_option('mandir'), 'man' + section) | |
113 | ||
114 | p1 = custom_target( | |
115 | man, | |
116 | input : xml, | |
117 | output : man, | |
118 | command : xslt_cmd + [custom_man_xsl, '@INPUT@'], | |
119 | install : want_man and have_lxml, | |
120 | install_dir : mandirn) | |
121 | man_pages += [p1] | |
122 | ||
123 | p2 = custom_target( | |
124 | html, | |
125 | input : xml, | |
126 | output : html, | |
127 | command : xslt_cmd + [custom_html_xsl, '@INPUT@'], | |
128 | install : want_html and have_lxml, | |
129 | install_dir : join_paths(docdir, 'html')) | |
130 | html_pages += [p2] | |
5c23128d | 131 | endforeach |
527d43d7 | 132 | |
f75d75eb ZJS |
133 | man = custom_target('man', |
134 | depends : man_pages, | |
135 | output : 'man', | |
136 | command : ['echo']) | |
137 | ||
138 | html = custom_target('html', | |
139 | depends : html_pages, | |
140 | output : 'html', | |
141 | command : ['echo']) | |
142 | ||
143 | custom_target('doc-sync', | |
144 | depends : [man, html], | |
145 | output : ['doc-sync'], | |
146 | command : ['rsync', '-rlv', | |
147 | '--delete-excluded', | |
148 | '--include=man', | |
149 | '--include=*.html', | |
150 | '--exclude=*', | |
151 | '--omit-dir-times', | |
152 | meson.current_build_dir(), | |
153 | get_option('www-target')]) |