1 # SPDX-License-Identifier: LGPL-2.1+
3 # Copyright 2017 Zbigniew Jędrzejewski-Szmek
5 # This is lame, I know, but meson has no other include mechanism
8 want_man = get_option('man')
9 want_html = get_option('html')
10 xsltproc = find_program('xsltproc',
11 required : want_man == 'true' or want_html == 'true')
12 want_man = want_man != 'false' and xsltproc.found()
13 want_html = want_html != 'false' and xsltproc.found()
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', 'elogind.version', '@0@'.format(meson.project_version()),
25 '@0@:@1@'.format(meson.current_build_dir(), meson.current_source_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 #if 0 /// UNNEEDED by elogind
32 # custom_entities_ent = configure_file(
33 # input : 'custom-entities.ent.in',
34 # output : 'custom-entities.ent',
35 # configuration : conf)
41 foreach tuple : xsltproc.found() ? manpages : []
49 man = stem + '.' + section
53 foreach alias : aliases
54 manaliases += [alias + '.' + section]
55 htmlaliases += [alias + '.html']
58 mandirn = join_paths(get_option('mandir'), 'man' + section)
60 if condition == '' or conf.get(condition) == 1
64 output : [man] + manaliases,
65 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
66 #if 0 /// UNNEEDED by elogind
67 # depend_files : custom_entities_ent,
70 install_dir : mandirn)
74 foreach htmlalias : htmlaliases
79 command : ['ln', '-fs', html, '@OUTPUT@'])
81 #if 0 /// This must be configurable in elogind
82 # dst = join_paths(docdir, 'html', htmlalias)
84 dst = get_option('htmldir')
85 dst = dst != '' ? dst: join_paths(docdir, 'html', htmlalias)
87 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
88 meson.add_install_script('sh', '-c', cmd)
98 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
99 #if 0 /// UNNEEDED by elogind
100 # depend_files : custom_entities_ent,
104 install_dir : join_paths(docdir, 'html'))
107 source_xml_files += files(tuple[0] + '.xml')
109 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
113 ############################################################
115 have_lxml = run_command(xml_helper_py).returncode() == 0
117 message('python-lxml not available, not making man page indices')
120 elogind_directives_xml = custom_target(
121 'elogind.directives.xml',
122 input : source_xml_files,
123 output : 'elogind.directives.xml',
124 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
126 nonindex_xml_files = source_xml_files + [elogind_directives_xml]
127 elogind_index_xml = custom_target(
129 input : nonindex_xml_files,
130 output : 'elogind.index.xml',
131 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
133 foreach tuple : want_man or want_html ? [['elogind.directives', '7', elogind_directives_xml],
134 ['elogind.index', '7', elogind_index_xml]] : []
139 html = stem + '.html'
140 man = stem + '.' + section
142 mandirn = join_paths(get_option('mandir'), 'man' + section)
148 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
149 install : want_man and have_lxml,
150 install_dir : mandirn)
154 if html == 'elogind.index.html'
155 htmlalias = 'index.html'
156 link = custom_target(
160 command : ['ln', '-fs', html, '@OUTPUT@'])
162 dst = join_paths(docdir, 'html', htmlalias)
163 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
164 meson.add_install_script('sh', '-c', cmd)
174 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
175 #if 0 /// UNNEEDED by elogind
176 # depend_files : custom_entities_ent,
179 install : want_html and have_lxml,
180 install_dir : join_paths(docdir, 'html'))
184 # cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved
191 html = custom_target(
194 depends : html_pages,
197 #if 0 /// UNNEEDED in elogind
200 # depends : man_pages + html_pages,
201 # command : ['rsync', '-rlv',
202 # '--delete-excluded',
204 # '--include=*.html',
206 # '--omit-dir-times',
207 # meson.current_build_dir(),
208 # get_option('www-target')])
211 ############################################################
216 output : 'update-man-rules',
217 # slightly strange syntax because of
218 # https://github.com/mesonbuild/meson/issues/1643
219 # and https://github.com/mesonbuild/meson/issues/1512
220 command : ['sh', '-c',
221 'cd @0@ && '.format(meson.build_root()) +
222 'python3 @0@/tools/make-man-rules.py `git ls-files ":/man/*.xml"` >t && '.format(meson.source_root()) +
223 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
224 #if 0 /// UNNEEDED by elogind
225 # depend_files : custom_entities_ent)