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 custom_entities_ent = configure_file(
30 input : 'custom-entities.ent.in',
31 output : 'custom-entities.ent',
37 foreach tuple : xsltproc.found() ? manpages : []
45 man = stem + '.' + section
49 foreach alias : aliases
50 manaliases += [alias + '.' + section]
51 htmlaliases += [alias + '.html']
54 mandirn = join_paths(get_option('mandir'), 'man' + section)
56 if condition == '' or conf.get(condition) == 1
60 output : [man] + manaliases,
61 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
62 #if 0 /// UNNEEDED by elogind
63 # depend_files : custom_entities_ent,
66 install_dir : mandirn)
70 foreach htmlalias : htmlaliases
75 command : ['ln', '-fs', html, '@OUTPUT@'])
77 #if 0 /// This must be configurable in elogind
78 # dst = join_paths(docdir, 'html', htmlalias)
80 dst = get_option('htmldir')
81 dst = dst != '' ? dst: join_paths(docdir, 'html', htmlalias)
83 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
84 meson.add_install_script('sh', '-c', cmd)
94 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
95 #if 0 /// UNNEEDED by elogind
96 # depend_files : custom_entities_ent,
100 install_dir : join_paths(docdir, 'html'))
103 source_xml_files += files(tuple[0] + '.xml')
105 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
109 ############################################################
111 have_lxml = run_command(xml_helper_py).returncode() == 0
113 message('python-lxml not available, not making man page indices')
116 elogind_directives_xml = custom_target(
117 'elogind.directives.xml',
118 input : source_xml_files,
119 output : 'elogind.directives.xml',
120 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
122 nonindex_xml_files = source_xml_files + [elogind_directives_xml]
123 elogind_index_xml = custom_target(
125 input : nonindex_xml_files,
126 output : 'elogind.index.xml',
127 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
129 foreach tuple : want_man or want_html ? [['elogind.directives', '7', elogind_directives_xml],
130 ['elogind.index', '7', elogind_index_xml]] : []
135 html = stem + '.html'
136 man = stem + '.' + section
138 mandirn = join_paths(get_option('mandir'), 'man' + section)
144 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
145 install : want_man and have_lxml,
146 install_dir : mandirn)
150 if html == 'elogind.index.html'
151 htmlalias = 'index.html'
152 link = custom_target(
156 command : ['ln', '-fs', html, '@OUTPUT@'])
158 dst = join_paths(docdir, 'html', htmlalias)
159 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
160 meson.add_install_script('sh', '-c', cmd)
170 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
171 #if 0 /// UNNEEDED by elogind
172 # depend_files : custom_entities_ent,
175 install : want_html and have_lxml,
176 install_dir : join_paths(docdir, 'html'))
180 # cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved
187 html = custom_target(
190 depends : html_pages,
193 #if 0 /// UNNEEDED in elogind
196 # depends : man_pages + html_pages,
197 # command : ['rsync', '-rlv',
198 # '--delete-excluded',
200 # '--include=*.html',
202 # '--omit-dir-times',
203 # meson.current_build_dir(),
204 # get_option('www-target')])
207 ############################################################
212 output : 'update-man-rules',
213 # slightly strange syntax because of
214 # https://github.com/mesonbuild/meson/issues/1643
215 # and https://github.com/mesonbuild/meson/issues/1512
216 command : ['sh', '-c',
217 'cd @0@ && '.format(meson.build_root()) +
218 'python3 @0@/tools/make-man-rules.py `git ls-files ":/man/*.xml"` >t && '.format(meson.source_root()) +
219 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
220 #if 0 /// UNNEEDED by elogind
221 # depend_files : custom_entities_ent)