| 1 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
# |
| 3 |
# This file is part of libnvme. |
| 4 |
# Copyright (c) 2022 Dell Inc. |
| 5 |
# Copyright (c) 2022 SUSE LLC |
| 6 |
# |
| 7 |
# Authors: Martin Belanger <[email protected]> |
| 8 |
# Authors: Daniel Wagner <[email protected]> |
| 9 |
# |
| 10 |
|
| 11 |
api_files = [ |
| 12 |
'api-types.h', |
| 13 |
'fabrics.h', |
| 14 |
'filters.h', |
| 15 |
'ioctl.h', |
| 16 |
'linux.h', |
| 17 |
'log.h', |
| 18 |
'mi.h', |
| 19 |
'nbft.h', |
| 20 |
'tree.h', |
| 21 |
'types.h', |
| 22 |
'util.h' |
| 23 |
] |
| 24 |
|
| 25 |
api_paths = [] |
| 26 |
foreach f: api_files |
| 27 |
api_paths += files('../src/nvme/' + f) |
| 28 |
endforeach |
| 29 |
|
| 30 |
sphinx_sources = [ |
| 31 |
'conf.py', |
| 32 |
'api.rst', |
| 33 |
'index.rst', |
| 34 |
'quickstart.rst', |
| 35 |
'installation.rst', |
| 36 |
'mi.rst', |
| 37 |
'config-schema.json' |
| 38 |
] |
| 39 |
|
| 40 |
static_sources = [] |
| 41 |
foreach file : sphinx_sources |
| 42 |
static_sources += configure_file(input: file + '.in', |
| 43 |
output: file, |
| 44 |
configuration: substs) |
| 45 |
endforeach |
| 46 |
|
| 47 |
subdir('rst') |
| 48 |
|
| 49 |
top_source_dir = meson.current_source_dir() + '/../' |
| 50 |
|
| 51 |
want_docs = get_option('docs') |
| 52 |
want_docs_build = get_option('docs-build') |
| 53 |
kernel_doc = find_program(top_source_dir + 'scripts/kernel-doc') |
| 54 |
kernel_doc_check = find_program(top_source_dir +'scripts/kernel-doc-check') |
| 55 |
|
| 56 |
test('kdoc', kernel_doc_check, args: api_paths) |
| 57 |
|
| 58 |
if want_docs != 'false' |
| 59 |
|
| 60 |
if want_docs == 'all' or want_docs == 'man' |
| 61 |
mandir = join_paths(get_option('mandir'), 'man2') |
| 62 |
list_man_pages = find_program(top_source_dir + 'scripts/list-man-pages.sh') |
| 63 |
if want_docs_build |
| 64 |
foreach apif : api_paths |
| 65 |
c = run_command(list_man_pages, apif, check: true) |
| 66 |
man_pages = c.stdout().split() |
| 67 |
foreach page : man_pages |
| 68 |
custom_target( |
| 69 |
page.underscorify() + '_man', |
| 70 |
input: apif, |
| 71 |
output: page + '.2', |
| 72 |
capture: true, |
| 73 |
command: [kernel_doc, |
| 74 |
'-module', 'libnvme', |
| 75 |
'-man', |
| 76 |
'-function', |
| 77 |
page, |
| 78 |
apif], |
| 79 |
install: true, |
| 80 |
install_dir: mandir) |
| 81 |
endforeach |
| 82 |
endforeach |
| 83 |
else |
| 84 |
if want_docs == 'all' or want_docs == 'man' |
| 85 |
list_pre_compiled = find_program(top_source_dir + 'scripts/list-pre-compiled.sh') |
| 86 |
m = run_command(list_pre_compiled, check: true) |
| 87 |
man_pages = m.stdout().strip().split('\n') |
| 88 |
install_data(man_pages, install_dir: mandir) |
| 89 |
endif |
| 90 |
endif |
| 91 |
endif |
| 92 |
|
| 93 |
if want_docs == 'all' or want_docs == 'html' |
| 94 |
htmldir = join_paths(get_option('htmldir'), 'nvme') |
| 95 |
sphinx_build = find_program('sphinx-build-3', 'sphinx-build') |
| 96 |
if sphinx_build.found() and want_docs_build |
| 97 |
custom_target( |
| 98 |
'generate_doc_html', |
| 99 |
input: [static_sources, rst], |
| 100 |
output: 'html', |
| 101 |
command: [sphinx_build, |
| 102 |
'-b', 'html', |
| 103 |
'@OUTDIR@', |
| 104 |
'@OUTDIR@' + '/html'], |
| 105 |
install: true, |
| 106 |
install_dir: htmldir) |
| 107 |
else |
| 108 |
# The HTML doc is not ready yet. |
| 109 |
# if want_docs == 'all' or want_docs == 'html' |
| 110 |
# install_subdir('html', install_dir: htmldir) |
| 111 |
# endif |
| 112 |
endif |
| 113 |
endif |
| 114 |
endif |