1 # SPDX-License-Identifier: LGPL-2.1+
3 # This is lame, I know, but meson has no other include mechanism
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()
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', 'elogind.version', '@0@'.format(meson.project_version()),
23 '@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())]
25 custom_man_xsl = files('custom-man.xsl')
26 custom_html_xsl = files('custom-html.xsl')
27 xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
29 #if 0 /// UNNEEDED by elogind
30 # custom_entities_ent = configure_file(
31 # input : 'custom-entities.ent.in',
32 # output : 'custom-entities.ent',
33 # configuration : conf)
39 foreach tuple : xsltproc.found() ? manpages : []
47 man = stem + '.' + section
51 foreach alias : aliases
52 manaliases += [alias + '.' + section]
53 htmlaliases += [alias + '.html']
56 mandirn = join_paths(get_option('mandir'), 'man' + section)
58 if condition == '' or conf.get(condition) == 1
62 output : [man] + manaliases,
63 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
64 #if 0 /// UNNEEDED by elogind
65 # depend_files : custom_entities_ent,
68 install_dir : mandirn)
72 foreach htmlalias : htmlaliases
77 command : ['ln', '-fs', html, '@OUTPUT@'])
79 #if 0 /// This must be configurable in elogind
80 # dst = join_paths(docdir, 'html', htmlalias)
82 dst = get_option('htmldir')
83 dst = dst != '' ? dst: join_paths(docdir, 'html', htmlalias)
85 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
86 meson.add_install_script('sh', '-c', cmd)
96 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
97 #if 0 /// UNNEEDED by elogind
98 # depend_files : custom_entities_ent,
102 install_dir : join_paths(docdir, 'html'))
105 source_xml_files += files(tuple[0] + '.xml')
107 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
111 ############################################################
113 have_lxml = run_command(xml_helper_py).returncode() == 0
115 message('python-lxml not available, not making man page indices')
118 elogind_directives_xml = custom_target(
119 'elogind.directives.xml',
120 input : source_xml_files,
121 output : 'elogind.directives.xml',
122 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
124 nonindex_xml_files = source_xml_files + [elogind_directives_xml]
125 elogind_index_xml = custom_target(
127 input : nonindex_xml_files,
128 output : 'elogind.index.xml',
129 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
131 foreach tuple : want_man or want_html ? [['elogind.directives', '7', elogind_directives_xml],
132 ['elogind.index', '7', elogind_index_xml]] : []
137 html = stem + '.html'
138 man = stem + '.' + section
140 mandirn = join_paths(get_option('mandir'), 'man' + section)
146 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
147 install : want_man and have_lxml,
148 install_dir : mandirn)
152 if html == 'elogind.index.html'
153 htmlalias = 'index.html'
154 link = custom_target(
158 command : ['ln', '-fs', html, '@OUTPUT@'])
160 dst = join_paths(docdir, 'html', htmlalias)
161 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
162 meson.add_install_script('sh', '-c', cmd)
172 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
173 #if 0 /// UNNEEDED by elogind
174 # depend_files : custom_entities_ent,
177 install : want_html and have_lxml,
178 install_dir : join_paths(docdir, 'html'))
182 # cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved
189 html = custom_target(
192 depends : html_pages,
195 #if 0 /// UNNEEDED in elogind
198 # depends : man_pages + html_pages,
199 # command : ['rsync', '-rlv',
200 # '--delete-excluded',
202 # '--include=*.html',
204 # '--omit-dir-times',
205 # meson.current_build_dir(),
206 # get_option('www-target')])
209 ############################################################
214 output : 'update-man-rules',
215 # slightly strange syntax because of
216 # https://github.com/mesonbuild/meson/issues/1643
217 # and https://github.com/mesonbuild/meson/issues/1512
218 command : ['sh', '-c',
219 'cd @0@ && '.format(meson.build_root()) +
220 'python3 @0@/tools/make-man-rules.py `git ls-files ":/man/*.xml"` >t && '.format(meson.source_root()) +
221 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
222 #if 0 /// UNNEEDED by elogind
223 # depend_files : custom_entities_ent)