]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/meson.build
Merge pull request #13904 from keur/job_mode_triggering
[thirdparty/systemd.git] / man / meson.build
1 # SPDX-License-Identifier: LGPL-2.1+
2
3 # This is lame, I know, but meson has no other include mechanism
4 subdir('rules')
5
6 want_man = get_option('man')
7 want_html = get_option('html')
8 xsltproc = find_program('xsltproc',
9 required : want_man == 'true' or want_html == 'true')
10 want_man = want_man != 'false' and xsltproc.found()
11 want_html = want_html != 'false' and xsltproc.found()
12
13 xsltproc_flags = [
14 '--nonet',
15 '--xinclude',
16 '--maxdepth', '9000',
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())]
24
25 custom_man_xsl = files('custom-man.xsl')
26 custom_html_xsl = files('custom-html.xsl')
27 xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
28
29 custom_entities_ent = configure_file(
30 input : 'custom-entities.ent.in',
31 output : 'custom-entities.ent',
32 configuration : conf)
33
34 man_pages = []
35 html_pages = []
36 source_xml_files = []
37 foreach tuple : xsltproc.found() ? manpages : []
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) == 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 = []
68 foreach htmlalias : htmlaliases
69 link = custom_target(
70 htmlalias,
71 output : htmlalias,
72 command : ['ln', '-fs', html, '@OUTPUT@'])
73 if want_html
74 dst = join_paths(docdir, 'html', htmlalias)
75 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
76 meson.add_install_script('sh', '-c', cmd)
77 p2 += link
78 endif
79 html_pages += link
80 endforeach
81
82 p3 = custom_target(
83 html,
84 input : xml,
85 output : html,
86 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
87 depend_files : custom_entities_ent,
88 depends : p2,
89 install : want_html,
90 install_dir : join_paths(docdir, 'html'))
91 html_pages += p3
92
93 source_xml_files += files(tuple[0] + '.xml')
94 else
95 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
96 endif
97 endforeach
98
99 ############################################################
100
101 have_lxml = run_command(xml_helper_py).returncode() == 0
102 if not have_lxml
103 message('python-lxml not available, not making man page indices')
104 endif
105
106 systemd_directives_xml = custom_target(
107 'systemd.directives.xml',
108 input : source_xml_files,
109 output : 'systemd.directives.xml',
110 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
111
112 nonindex_xml_files = source_xml_files + [systemd_directives_xml]
113 systemd_index_xml = custom_target(
114 'systemd.index.xml',
115 input : nonindex_xml_files,
116 output : 'systemd.index.xml',
117 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
118
119 foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml],
120 ['systemd.index', '7', systemd_index_xml]] : []
121 stem = tuple[0]
122 section = tuple[1]
123 xml = tuple[2]
124
125 html = stem + '.html'
126 man = stem + '.' + section
127
128 mandirn = join_paths(get_option('mandir'), 'man' + section)
129
130 p1 = custom_target(
131 man,
132 input : xml,
133 output : man,
134 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
135 install : want_man and have_lxml,
136 install_dir : mandirn)
137 man_pages += p1
138
139 p2 = []
140 if html == 'systemd.index.html'
141 htmlalias = 'index.html'
142 link = custom_target(
143 htmlalias,
144 input : p2,
145 output : htmlalias,
146 command : ['ln', '-fs', html, '@OUTPUT@'])
147 if want_html
148 dst = join_paths(docdir, 'html', htmlalias)
149 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
150 meson.add_install_script('sh', '-c', cmd)
151 p2 += link
152 endif
153 html_pages += link
154 endif
155
156 p3 = custom_target(
157 html,
158 input : xml,
159 output : html,
160 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
161 depend_files : custom_entities_ent,
162 depends : p2,
163 install : want_html and have_lxml,
164 install_dir : join_paths(docdir, 'html'))
165 html_pages += p3
166 endforeach
167
168 # Cannot use run_target because those targets are used in depends
169 # Also see https://github.com/mesonbuild/meson/issues/368.
170 man = custom_target(
171 'man',
172 output : 'man',
173 depends : man_pages,
174 command : ['echo'])
175
176 html = custom_target(
177 'html',
178 output : 'html',
179 depends : html_pages,
180 command : ['echo'])
181
182 run_target(
183 'doc-sync',
184 depends : man_pages + html_pages,
185 command : ['rsync', '-rlv',
186 '--delete-excluded',
187 '--include=man',
188 '--include=*.html',
189 '--exclude=*',
190 '--omit-dir-times',
191 meson.current_build_dir(),
192 get_option('www-target')])
193
194 ############################################################
195
196 if git.found()
197 custom_target(
198 'update-man-rules',
199 output : 'update-man-rules',
200 command : ['sh', '-c',
201 'cd @0@ && '.format(meson.build_root()) +
202 'python3 @0@/tools/make-man-rules.py $(git ls-files ":/man/*.xml") >t && '.format(project_source_root) +
203 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
204 depend_files : custom_entities_ent)
205 endif
206
207 ############################################################
208
209 configure_file(
210 input : 'man.in',
211 output : 'man',
212 configuration : substs)
213
214 configure_file(
215 input : 'html.in',
216 output : 'html',
217 configuration : substs)