From b8823d9b8ffcb568cb966deef18087547abeac6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Canek=20Pel=C3=A1ez=20Vald=C3=A9s?= Date: Thu, 20 Jul 2017 11:18:19 -0500 Subject: [PATCH] Meson: Use systemd inspiration for building man pages. --- man/meson.build | 91 +++++++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 34 deletions(-) diff --git a/man/meson.build b/man/meson.build index 01f5e0e..3a23852 100644 --- a/man/meson.build +++ b/man/meson.build @@ -1,34 +1,57 @@ -customman = join_paths(meson.current_source_dir(), 'custom-man.xsl') -customhtml = join_paths(meson.current_source_dir(), 'custom-html.xsl') - -man1dir = join_paths(get_option('mandir'), 'man1') - -commonargs = [ - xsltproc, - '--nonet', - '--xinclude', - '--stringparam', 'man.output.quietly', '1', - '--stringparam', 'man.authors.section.enabled', '1', - '--stringparam', 'man.copyright.section.enabled', '1', - '--stringparam', 'mlm.version', meson.project_version(), - '--path', meson.current_source_dir(), - '-o', '@OUTPUT@' -] - -genman1 = [ commonargs, customman, '@INPUT@' ] - -name = 'analyze' -custom_target('mlm-' + name + '.1', - output: 'mlm-' + name + '.1', - input: 'mlm-' + name + '.xml', - command: genman1, install: true, install_dir: man1dir) -name = 'copy-tags' -custom_target('mlm-' + name + '.1', - output: 'mlm-' + name + '.1', - input: 'mlm-' + name + '.xml', - command: genman1, install: true, install_dir: man1dir) -name = 'tags' -custom_target('mlm-' + name + '.1', - output: 'mlm-' + name + '.1', - input: 'mlm-' + name + '.xml', - command: genman1, install: true, install_dir: man1dir) +if xsltproc.found() and get_option('enable-doc') + customman = files('custom-man.xsl') + customhtml = files('custom-html.xsl') + + flags = [ + '--nonet', + '--xinclude', + '--stringparam', 'man.output.quietly', '1', + '--stringparam', 'man.authors.section.enabled', '1', + '--stringparam', 'man.copyright.section.enabled', '1', + '--stringparam', 'mlm.version', '@0@'.format(meson.project_version()), + '--path', '@0@:@1@'.format(meson.current_build_dir(), + meson.current_source_dir()) + ] + + command = [ xsltproc, '-o', '@OUTPUT@' ] + flags + + manpages = [ 'analyze', 'copy-tags', 'tags' ] + man_pages = [] + html_pages = [] + + foreach manpage : manpages + stem = 'mlm-' + manpage + xml = stem + '.xml' + html = stem + '.html' + man = stem + '.1' + mandir = join_paths(get_option('mandir'), 'man1') + htmldir = join_paths(docdir, 'html') + + p1 = custom_target(man, + input : xml, + output : man, + command : command + [ customman, '@INPUT@' ], + install : true, + install_dir : mandir ) + man_pages += [ p1 ] + + p2 = custom_target(html, + input : xml, + output : html, + command : command + [ customhtml, '@INPUT@' ], + install : true, + install_dir : htmldir ) + html_pages += [ p2 ] + + endforeach + + man = custom_target('man', + output: 'man', + depends: man_pages, + command: ['echo']) + + html = custom_target('html', + output: 'html', + depends: html_pages, + command: ['echo']) +endif -- GitLab