1 # SPDX-License-Identifier: LGPL-2.1+
3 # Copyright 2017 Zbigniew Jędrzejewski-Szmek
5 # elogind is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) any later version.
10 # elogind is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with elogind; If not, see <http://www.gnu.org/licenses/>.
18 # This is lame, I know, but meson has no other include mechanism
21 want_man = get_option('man')
22 want_html = get_option('html')
23 xsltproc = find_program('xsltproc',
24 required : want_man == 'true' or want_html == 'true')
25 want_man = want_man != 'false' and xsltproc.found()
26 want_html = want_html != 'false' and xsltproc.found()
32 '--stringparam', 'man.output.quietly', '1',
33 '--stringparam', 'funcsynopsis.style', 'ansi',
34 '--stringparam', 'man.authors.section.enabled', '0',
35 '--stringparam', 'man.copyright.section.enabled', '0',
36 '--stringparam', 'elogind.version', '@0@'.format(meson.project_version()),
38 '@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())]
40 custom_man_xsl = files('custom-man.xsl')
41 custom_html_xsl = files('custom-html.xsl')
42 xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
44 #if 0 /// UNNEEDED by elogind
45 # custom_entities_ent = configure_file(
46 # input : 'custom-entities.ent.in',
47 # output : 'custom-entities.ent',
48 # configuration : conf)
54 foreach tuple : xsltproc.found() ? manpages : []
62 man = stem + '.' + section
66 foreach alias : aliases
67 manaliases += [alias + '.' + section]
68 htmlaliases += [alias + '.html']
71 mandirn = join_paths(get_option('mandir'), 'man' + section)
73 if condition == '' or conf.get(condition) == 1
77 output : [man] + manaliases,
78 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
79 #if 0 /// UNNEEDED by elogind
80 # depend_files : custom_entities_ent,
83 install_dir : mandirn)
87 foreach htmlalias : htmlaliases
92 command : ['ln', '-fs', html, '@OUTPUT@'])
94 #if 0 /// This must be configurable in elogind
95 # dst = join_paths(docdir, 'html', htmlalias)
97 dst = get_option('htmldir')
98 dst = dst != '' ? dst: join_paths(docdir, 'html', htmlalias)
100 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
101 meson.add_install_script('sh', '-c', cmd)
111 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
112 #if 0 /// UNNEEDED by elogind
113 # depend_files : custom_entities_ent,
117 install_dir : join_paths(docdir, 'html'))
120 source_xml_files += files(tuple[0] + '.xml')
122 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
126 ############################################################
128 have_lxml = run_command(xml_helper_py).returncode() == 0
130 message('python-lxml not available, not making man page indices')
133 elogind_directives_xml = custom_target(
134 'elogind.directives.xml',
135 input : source_xml_files,
136 output : 'elogind.directives.xml',
137 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
139 nonindex_xml_files = source_xml_files + [elogind_directives_xml]
140 elogind_index_xml = custom_target(
142 input : nonindex_xml_files,
143 output : 'elogind.index.xml',
144 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
146 foreach tuple : want_man or want_html ? [['elogind.directives', '7', elogind_directives_xml],
147 ['elogind.index', '7', elogind_index_xml]] : []
152 html = stem + '.html'
153 man = stem + '.' + section
155 mandirn = join_paths(get_option('mandir'), 'man' + section)
161 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
162 install : want_man and have_lxml,
163 install_dir : mandirn)
167 if html == 'elogind.index.html'
168 htmlalias = 'index.html'
169 link = custom_target(
173 command : ['ln', '-fs', html, '@OUTPUT@'])
175 dst = join_paths(docdir, 'html', htmlalias)
176 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
177 meson.add_install_script('sh', '-c', cmd)
187 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
188 #if 0 /// UNNEEDED by elogind
189 # depend_files : custom_entities_ent,
192 install : want_html and have_lxml,
193 install_dir : join_paths(docdir, 'html'))
197 # cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved
204 html = custom_target(
207 depends : html_pages,
210 #if 0 /// UNNEEDED in elogind
213 # depends : man_pages + html_pages,
214 # command : ['rsync', '-rlv',
215 # '--delete-excluded',
217 # '--include=*.html',
219 # '--omit-dir-times',
220 # meson.current_build_dir(),
221 # get_option('www-target')])
224 ############################################################
229 output : 'update-man-rules',
230 # slightly strange syntax because of
231 # https://github.com/mesonbuild/meson/issues/1643
232 # and https://github.com/mesonbuild/meson/issues/1512
233 command : ['sh', '-c',
234 'cd @0@ && '.format(meson.build_root()) +
235 'python3 @0@/tools/make-man-rules.py `git ls-files ":/man/*.xml"` >t && '.format(meson.source_root()) +
236 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
237 #if 0 /// UNNEEDED by elogind
238 # depend_files : custom_entities_ent)