1 # This is lame, I know, but meson has no other include mechanism
4 want_man = get_option('man')
5 want_html = get_option('html')
6 xsltproc = find_program('xsltproc',
7 required : want_man == 'true' or want_html == 'true')
8 want_man = want_man != 'false' and xsltproc.found()
9 want_html = want_html != 'false' and xsltproc.found()
15 '--stringparam', 'man.output.quietly', '1',
16 '--stringparam', 'funcsynopsis.style', 'ansi',
17 '--stringparam', 'man.authors.section.enabled', '0',
18 '--stringparam', 'man.copyright.section.enabled', '0',
19 '--stringparam', 'elogind.version', '@0@'.format(meson.project_version()),
21 '@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())]
23 custom_man_xsl = files('custom-man.xsl')
24 custom_html_xsl = files('custom-html.xsl')
25 xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
27 #if 0 /// UNNEEDED by elogind
28 # custom_entities_ent = configure_file(
29 # input : 'custom-entities.ent.in',
30 # output : 'custom-entities.ent',
31 # configuration : conf)
37 foreach tuple : want_man or want_html ? 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 dst = join_paths(docdir, 'html', htmlalias)
78 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
79 meson.add_install_script('sh', '-c', cmd)
89 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
90 #if 0 /// UNNEEDED by elogind
91 # depend_files : custom_entities_ent,
95 install_dir : join_paths(docdir, 'html'))
98 source_xml_files += files(tuple[0] + '.xml')
100 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
104 ############################################################
106 have_lxml = run_command(xml_helper_py).returncode() == 0
108 message('python-lxml not available, not making man page indices')
111 elogind_directives_xml = custom_target(
112 'elogind.directives.xml',
113 input : source_xml_files,
114 output : 'elogind.directives.xml',
115 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
117 nonindex_xml_files = source_xml_files + [elogind_directives_xml]
118 elogind_index_xml = custom_target(
120 input : nonindex_xml_files,
121 output : 'elogind.index.xml',
122 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
124 foreach tuple : want_man or want_html ? [['elogind.directives', '7', elogind_directives_xml],
125 ['elogind.index', '7', elogind_index_xml]] : []
130 html = stem + '.html'
131 man = stem + '.' + section
133 mandirn = join_paths(get_option('mandir'), 'man' + section)
139 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
140 install : want_man and have_lxml,
141 install_dir : mandirn)
145 if html == 'elogind.index.html'
146 htmlalias = 'index.html'
147 link = custom_target(
151 command : ['ln', '-fs', html, '@OUTPUT@'])
153 dst = join_paths(docdir, 'html', htmlalias)
154 cmd = 'ln -fs @0@ $DESTDIR@1@'.format(html, dst)
155 meson.add_install_script('sh', '-c', cmd)
165 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
166 #if 0 /// UNNEEDED by elogind
167 # depend_files : custom_entities_ent,
170 install : want_html and have_lxml,
171 install_dir : join_paths(docdir, 'html'))
175 # cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved
182 html = custom_target(
185 depends : html_pages,
188 #if 0 /// UNNEEDED in elogind
191 # depends : man_pages + html_pages,
192 # command : ['rsync', '-rlv',
193 # '--delete-excluded',
195 # '--include=*.html',
197 # '--omit-dir-times',
198 # meson.current_build_dir(),
199 # get_option('www-target')])
202 ############################################################
207 output : 'update-man-rules',
208 # slightly strange syntax because of
209 # https://github.com/mesonbuild/meson/issues/1643
210 # and https://github.com/mesonbuild/meson/issues/1512
211 command : ['sh', '-c',
212 'cd @0@ && '.format(meson.build_root()) +
213 'python3 @0@/tools/make-man-rules.py `git ls-files ":/man/*.xml"` >t && '.format(meson.source_root()) +
214 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
215 #if 0 /// UNNEEDED by elogind
216 # depend_files : custom_entities_ent)