]>
Commit | Line | Data |
---|---|---|
5c23128d ZJS |
1 | # -*- mode: meson -*- |
2 | ||
3 | # This is lame, I know, but meson has no other include mechanism | |
4 | subdir('rules') | |
5 | ||
6 | # TODO: add regeneration rule: | |
7 | # python3 tools/make-man-rules.py --meson man/*xml > man/rules/meson.build | |
8 | ||
527d43d7 ZJS |
9 | want_man = get_option('man') |
10 | want_html = get_option('html') | |
11 | xsltproc = find_program('xsltproc', | |
12 | required : want_man == 'yes' or want_html == 'yes') | |
13 | want_man = want_man != 'no' and xsltproc.found() | |
14 | want_html = want_html != 'no' and xsltproc.found() | |
15 | ||
5c23128d ZJS |
16 | xsltproc_flags = [ |
17 | '--nonet', | |
18 | '--xinclude', | |
19 | '--stringparam', 'man.output.quietly', '1', | |
20 | '--stringparam', 'funcsynopsis.style', 'ansi', | |
21 | '--stringparam', 'man.authors.section.enabled', '0', | |
22 | '--stringparam', 'man.copyright.section.enabled', '0', | |
23 | '--stringparam', 'systemd.version', '@0@'.format(meson.project_version()), | |
24 | '--path', | |
25 | '@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())] | |
26 | ||
27 | custom_man_xsl = files('custom-man.xsl') | |
527d43d7 | 28 | custom_html_xsl = files('custom-html.xsl') |
04e3eb46 ZJS |
29 | |
30 | custom_entities_ent = configure_file( | |
31 | input : 'custom-entities.ent.in', | |
32 | output : 'custom-entities.ent', | |
33 | configuration : conf) | |
5c23128d | 34 | |
527d43d7 ZJS |
35 | man_pages = [] |
36 | html_pages = [] | |
37 | source_xml_files = [] | |
5c23128d ZJS |
38 | foreach tuple : manpages |
39 | stem = tuple[0] | |
40 | section = tuple[1] | |
41 | aliases = tuple[2] | |
42 | condition = tuple[3] | |
43 | ||
44 | xml = stem + '.xml' | |
45 | html = stem + '.html' | |
46 | man = stem + '.' + section | |
47 | ||
48 | manaliases = [] | |
49 | htmlaliases = [] | |
50 | foreach alias : aliases | |
51 | manaliases += [alias + '.' + section] | |
52 | htmlaliases += [alias + '.html'] | |
53 | endforeach | |
54 | ||
e17e5ba9 | 55 | mandirn = join_paths(get_option('mandir'), 'man' + section) |
5c23128d | 56 | |
527d43d7 ZJS |
57 | have = condition == '' or conf.get(condition, 0) == 1 |
58 | ||
59 | if have | |
60 | p1 = custom_target( | |
61 | man, | |
62 | input : xml, | |
63 | output : [man] + manaliases, | |
64 | command : [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags + [custom_man_xsl, '@INPUT@'], | |
65 | depend_files : custom_entities_ent, | |
66 | install : want_man, | |
67 | install_dir : mandirn) | |
68 | man_pages += [p1] | |
69 | ||
70 | p2 = custom_target( | |
71 | html, | |
72 | input : xml, | |
73 | output : [html] + htmlaliases, | |
74 | command : [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags + [custom_html_xsl, '@INPUT@'], | |
75 | depend_files : custom_entities_ent, | |
76 | install : want_html, | |
e17e5ba9 | 77 | install_dir : join_paths(docdir, 'html')) |
527d43d7 ZJS |
78 | html_pages += [p2] |
79 | ||
80 | source_xml_files += files(tuple[0] + '.xml') | |
81 | else | |
82 | message('Skipping @0@.@1@ because @2@ is @3@'.format(stem, section, condition, have)) | |
5c23128d ZJS |
83 | endif |
84 | endforeach | |
85 | ||
86 | ############################################################ | |
87 | ||
5c23128d ZJS |
88 | systemd_directives_xml = custom_target( |
89 | 'systemd.directives.xml', | |
90 | input : source_xml_files, | |
91 | output : 'systemd.directives.xml', | |
92 | command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files) | |
93 | ||
94 | nonindex_xml_files = source_xml_files + [systemd_directives_xml] | |
95 | systemd_index_xml = custom_target( | |
96 | 'systemd.index.xml', | |
97 | input : nonindex_xml_files, | |
98 | output : 'systemd.index.xml', | |
99 | command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files) | |
100 | ||
101 | foreach tuple : [['systemd.directives', '7', systemd_directives_xml], | |
102 | ['systemd.index', '7', systemd_index_xml]] | |
103 | stem = tuple[0] | |
104 | section = tuple[1] | |
105 | xml = tuple[2] | |
106 | ||
107 | html = stem + '.html' | |
108 | man = stem + '.' + section | |
109 | ||
e17e5ba9 | 110 | mandirn = join_paths(get_option('mandir'), 'man' + section) |
5c23128d | 111 | |
527d43d7 | 112 | p1 = custom_target( |
5c23128d ZJS |
113 | man, |
114 | input : xml, | |
115 | output : man, | |
116 | command : [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags + [custom_man_xsl, '@INPUT@'], | |
527d43d7 | 117 | install : want_man, |
5c23128d | 118 | install_dir : mandirn) |
527d43d7 | 119 | man_pages += [p1] |
5c23128d | 120 | |
527d43d7 | 121 | p2 = custom_target( |
5c23128d ZJS |
122 | html, |
123 | input : xml, | |
124 | output : html, | |
527d43d7 ZJS |
125 | command : [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags + [custom_html_xsl, '@INPUT@'], |
126 | install : want_html, | |
e17e5ba9 | 127 | install_dir : join_paths(docdir, 'html')) |
527d43d7 | 128 | html_pages += [p2] |
5c23128d | 129 | endforeach |
527d43d7 ZJS |
130 | |
131 | custom_target('man', | |
132 | depends : man_pages, | |
133 | output : ['man'], | |
134 | command : ['echo']) | |
135 | ||
136 | custom_target('html', | |
137 | depends : html_pages, | |
138 | output : ['html'], | |
139 | command : ['echo']) |