| 1 |
# SPDX-License-Identifier: GPL-2.0-or-later |
| 2 |
# Copyright (c) Iputils Project, 2017-2024 |
| 3 |
|
| 4 |
manpages = [] |
| 5 |
custom_man_xsl = files('custom-man.xsl') |
| 6 |
custom_html_xsl = files('custom-html.xsl') |
| 7 |
|
| 8 |
if build_arping == true |
| 9 |
manpages += ['arping'] |
| 10 |
endif |
| 11 |
|
| 12 |
if build_clockdiff == true |
| 13 |
manpages += ['clockdiff'] |
| 14 |
endif |
| 15 |
|
| 16 |
if build_ping == true |
| 17 |
manpages += ['ping'] |
| 18 |
endif |
| 19 |
|
| 20 |
if build_tracepath == true |
| 21 |
manpages += ['tracepath'] |
| 22 |
endif |
| 23 |
|
| 24 |
# Use the docs included in a dist tarball if available |
| 25 |
if meson.version().version_compare('>=0.58.0') |
| 26 |
fs = import('fs') |
| 27 |
out_man_pages = [] |
| 28 |
out_html_pages = [] |
| 29 |
generated_docs_exist = true |
| 30 |
foreach page : manpages |
| 31 |
man_page_name = page + '.8' |
| 32 |
html_page_name = page + '.html' |
| 33 |
out_man_pages += man_page_name |
| 34 |
out_html_pages += html_page_name |
| 35 |
if not fs.exists(man_page_name) or not fs.exists(html_page_name) |
| 36 |
generated_docs_exist = false |
| 37 |
endif |
| 38 |
endforeach |
| 39 |
if generated_docs_exist |
| 40 |
install_man(out_man_pages) |
| 41 |
install_data(out_html_pages, install_dir : join_paths(get_option('datadir'), meson.project_name())) |
| 42 |
subdir_done() |
| 43 |
endif |
| 44 |
else |
| 45 |
warning('Will not attempt to use pre-generated man pages (meson <0.58.0)') |
| 46 |
endif |
| 47 |
|
| 48 |
xsltproc = find_program('xsltproc', required : build_mans or build_html_mans) |
| 49 |
xsltproc_args = [ |
| 50 |
'--nonet', |
| 51 |
'--stringparam', 'man.output.quietly', '1', |
| 52 |
'--stringparam', 'funcsynopsis.style', 'ansi', |
| 53 |
'--stringparam', 'man.th.extra1.suppress', '1', |
| 54 |
'--stringparam', 'iputils.version', meson.project_version(), |
| 55 |
] |
| 56 |
|
| 57 |
if xsltproc.found() |
| 58 |
doc_targets = [] |
| 59 |
if build_mans |
| 60 |
doc_targets += ['manpages'] |
| 61 |
endif |
| 62 |
if build_html_mans |
| 63 |
doc_targets += ['html'] |
| 64 |
endif |
| 65 |
xsltproc_works = true |
| 66 |
foreach doc_target : doc_targets |
| 67 |
xsl = 'http://docbook.sourceforge.net/release/xsl-ns/current/' + doc_target + '/docbook.xsl' |
| 68 |
testrun = run_command([xsltproc, '--nonet', xsl]) |
| 69 |
if testrun.returncode() != 0 |
| 70 |
xsltproc_works = false |
| 71 |
message('WARNING: xsltproc: cannot process ' + xsl) |
| 72 |
endif |
| 73 |
endforeach |
| 74 |
endif |
| 75 |
|
| 76 |
if xsltproc_works == false |
| 77 |
message('Docs cannot be built: xsltproc does not work correctly') |
| 78 |
build_mans = false |
| 79 |
build_html_mans = false |
| 80 |
endif |
| 81 |
|
| 82 |
if build_mans |
| 83 |
foreach man : manpages |
| 84 |
custom_target(man + '.8', |
| 85 |
output : man + '.8', |
| 86 |
input : man + '.xml', |
| 87 |
command : [ |
| 88 |
xsltproc, |
| 89 |
'-o', '@OUTPUT@', |
| 90 |
xsltproc_args, |
| 91 |
custom_man_xsl, |
| 92 |
'@INPUT@', |
| 93 |
], |
| 94 |
install : true, |
| 95 |
install_dir : join_paths(get_option('mandir'), 'man8'), |
| 96 |
) |
| 97 |
endforeach |
| 98 |
endif |
| 99 |
|
| 100 |
if build_html_mans |
| 101 |
foreach man : manpages |
| 102 |
custom_target(man + '.html', |
| 103 |
output : man + '.html', |
| 104 |
input : man + '.xml', |
| 105 |
command : [ |
| 106 |
xsltproc, |
| 107 |
'-o', '@OUTPUT@', |
| 108 |
xsltproc_args, |
| 109 |
custom_html_xsl, |
| 110 |
'@INPUT@', |
| 111 |
], |
| 112 |
install : true, |
| 113 |
install_dir : join_paths(get_option('datadir'), meson.project_name()), |
| 114 |
) |
| 115 |
endforeach |
| 116 |
endif |