1:255.16-alt1
[systemd_ALT.git] / man / meson.build
blob403098a8149cb484da46904aa3d4ab9f9a6fb450
1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 # This is lame, I know, but meson has no other include mechanism
4 subdir('rules')
6 want_man = get_option('man')
7 want_html = get_option('html')
8 xsltproc = find_program('xsltproc',
9                         required : want_man.enabled() or want_html.enabled())
10 want_man = want_man.allowed() and xsltproc.found()
11 want_html = want_html.allowed() and xsltproc.found()
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@:@2@'.format(meson.current_build_dir(),
24                              meson.current_source_dir(),
25                              libshared_build_dir)]
27 custom_man_xsl = files('custom-man.xsl')
28 custom_html_xsl = files('custom-html.xsl')
29 xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
31 custom_entities_ent = custom_target(
32         'custom-entities.ent',
33         input : 'custom-entities.ent.in',
34         output : 'custom-entities.ent',
35         command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'])
37 man_page_depends += custom_entities_ent
39 man_pages = []
40 html_pages = []
41 source_xml_files = []
42 dbus_docs = []
43 foreach tuple : manpages
44         stem = tuple[0]
45         section = tuple[1]
46         aliases = tuple[2]
47         condition = tuple[3]
49         xml = stem + '.xml'
50         html = stem + '.html'
51         man = stem + '.' + section
53         manaliases = []
54         htmlaliases = []
55         foreach alias : aliases
56                 manaliases += alias + '.' + section
57                 htmlaliases += alias + '.html'
58         endforeach
60         mandirn = get_option('mandir') / ('man' + section)
62         if condition == '' or conf.get(condition) == 1
63                 file = files(tuple[0] + '.xml')
64                 source_xml_files += file
65                 if tuple[0].startswith('org.freedesktop.')
66                         dbus_docs += file
67                 endif
69                 if xsltproc.found()
70                         p1 = custom_target(
71                                 man,
72                                 input : xml,
73                                 output : [man] + manaliases,
74                                 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
75                                 depends : man_page_depends,
76                                 install : want_man,
77                                 install_dir : mandirn)
78                         man_pages += p1
80                         p2 = []
81                         foreach htmlalias : htmlaliases
82                                 link = custom_target(
83                                         htmlalias,
84                                         output : htmlalias,
85                                         command : [ln, '-fs', html, '@OUTPUT@'])
86                                 if want_html
87                                         meson.add_install_script(sh, '-c', ln_s.format(docdir / 'html' / html, docdir / 'html' / htmlalias))
88                                         p2 += link
89                                 endif
90                                 html_pages += link
91                         endforeach
93                         p3 = custom_target(
94                                 html,
95                                 input : xml,
96                                 output : html,
97                                 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
98                                 depends : [man_page_depends, p2],
99                                 install : want_html,
100                                 install_dir : docdir / 'html')
101                         html_pages += p3
102                 endif
103         else
104                 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
105         endif
106 endforeach
108 ############################################################
110 have_lxml = run_command(xml_helper_py, check: false).returncode() == 0
111 if not have_lxml
112         message('python-lxml not available, not making man page indices')
113 endif
115 systemd_directives_xml = custom_target(
116         'systemd.directives.xml',
117         input : ['directives-template.xml', source_xml_files],
118         output : 'systemd.directives.xml',
119         depends : man_page_depends,
120         command : [make_directive_index_py, '@OUTPUT@', '@INPUT@'])
122 nonindex_xml_files = source_xml_files + [systemd_directives_xml]
123 systemd_index_xml = custom_target(
124         'systemd.index.xml',
125         input : nonindex_xml_files,
126         output : 'systemd.index.xml',
127         command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
129 foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml],
130                                     ['systemd.index',      '7', systemd_index_xml]] : []
131         stem = tuple[0]
132         section = tuple[1]
133         xml = tuple[2]
135         html = stem + '.html'
136         man = stem + '.' + section
138         mandirn = get_option('mandir') / ('man' + section)
140         p1 = custom_target(
141                 man,
142                 input : xml,
143                 output : man,
144                 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
145                 install : want_man and have_lxml,
146                 install_dir : mandirn)
147         man_pages += p1
149         p2 = []
150         if html == 'systemd.index.html'
151                 htmlalias = 'index.html'
152                 link = custom_target(
153                         htmlalias,
154                         input : p2,
155                         output : htmlalias,
156                         command : [ln, '-fs', html, '@OUTPUT@'])
157                 if want_html
158                         meson.add_install_script(sh, '-c', ln_s.format(docdir / 'html' / html, docdir / 'html' / htmlalias))
159                         p2 += link
160                 endif
161                 html_pages += link
162         endif
164         p3 = custom_target(
165                 html,
166                 input : xml,
167                 output : html,
168                 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
169                 depends : [man_page_depends, p2],
170                 install : want_html and have_lxml,
171                 install_dir : docdir / 'html')
172         html_pages += p3
173 endforeach
175 # Cannot use run_target because those targets are used in depends
176 # Also see https://github.com/mesonbuild/meson/issues/368.
177 man = custom_target(
178         'man',
179         output : 'man',
180         depends : man_pages,
181         command : [echo])
183 html = custom_target(
184         'html',
185         output : 'html',
186         depends : html_pages,
187         command : [echo])
189 if rsync.found()
190         run_target(
191                 'doc-sync',
192                 depends : man_pages + html_pages,
193                 command : [sync_docs_py,
194                            '--version',
195                            '@0@'.format(meson.project_version()),
196                            meson.current_build_dir(),
197                            get_option('www-target')])
198 endif
200 ############################################################
202 buildroot_substs = configuration_data()
203 buildroot_substs.set_quoted('BUILD_ROOT', project_build_root)
205 configure_file(
206         input : 'man.in',
207         output : 'man',
208         configuration : buildroot_substs)
210 configure_file(
211         input : 'html.in',
212         output : 'html',
213         configuration : buildroot_substs)
215 ############################################################
217 update_dbus_docs = custom_target(
218         'update-dbus-docs-impl',
219         output : 'update-dbus-docs',
220         command : [update_dbus_docs_py, '--build-dir', project_build_root, '@INPUT@'],
221         input : dbus_docs)
223 if conf.get('BUILD_MODE_DEVELOPER') == 1
224         test('dbus-docs-fresh',
225              update_dbus_docs_py,
226              suite : 'dist',
227              args : ['--build-dir', project_build_root, '--test', dbus_docs],
228              depends : dbus_programs)
230         test('check-version-history',
231              check_version_history_py,
232              suite : 'dist',
233              args : source_xml_files)
234 endif
236 update_man_rules = custom_target(
237         'update-man-rules-impl',
238         output : 'update-man-rules',
239         command : [update_man_rules_py,
240                    '@0@/man/*.xml'.format(project_source_root),
241                    '@0@/rules/meson.build'.format(meson.current_source_dir())],
242         depends : man_page_depends)