]> git.proxmox.com Git - mirror_qemu.git/blame - docs/meson.build
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
[mirror_qemu.git] / docs / meson.build
CommitLineData
6f6652eb 1sphinx_build = find_program(fs.parent(python.full_path()) / 'sphinx-build',
1b1be8d3 2 required: get_option('docs'))
e3667660
YL
3
4# Check if tools are available to build documentation.
5build_docs = false
6if sphinx_build.found()
2e880198 7 SPHINX_ARGS = ['env', 'CONFDIR=' + qemu_confdir, sphinx_build, '-q']
e3667660
YL
8 # If we're making warnings fatal, apply this to Sphinx runs as well
9 if get_option('werror')
36420664 10 SPHINX_ARGS += [ '-W', '-Dkerneldoc_werror=1' ]
e3667660
YL
11 endif
12
ed8d9518
FR
13 sphinx_version = run_command(SPHINX_ARGS + ['--version'],
14 check: true).stdout().split()[1]
15 if sphinx_version.version_compare('>=1.7.0')
16 SPHINX_ARGS += ['-j', 'auto']
17 else
18 nproc = find_program('nproc')
19 if nproc.found()
20 jobs = run_command(nproc, check: true).stdout()
21 SPHINX_ARGS += ['-j', jobs]
22 endif
23 endif
24
e3667660
YL
25 # This is a bit awkward but works: create a trivial document and
26 # try to run it with our configuration file (which enforces a
27 # version requirement). This will fail if sphinx-build is too old.
b20a7ee6
PB
28 run_command('mkdir', ['-p', tmpdir / 'sphinx'], check: true)
29 run_command('touch', [tmpdir / 'sphinx/index.rst'], check: true)
e3667660
YL
30 sphinx_build_test_out = run_command(SPHINX_ARGS + [
31 '-c', meson.current_source_dir(),
32 '-b', 'html', tmpdir / 'sphinx',
b20a7ee6 33 tmpdir / 'sphinx/out'], check: false)
e3667660
YL
34 build_docs = (sphinx_build_test_out.returncode() == 0)
35
36 if not build_docs
73e6aec6 37 warning('@0@: @1@'.format(sphinx_build.full_path(), sphinx_build_test_out.stderr()))
e3667660 38 if get_option('docs').enabled()
73e6aec6 39 error('Install a Python 3 version of python-sphinx and the readthedoc theme')
e3667660
YL
40 endif
41 endif
42endif
43
f8aa24ea 44if build_docs
b0b4323e 45 SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + get_option('pkgversion')]
e3667660 46
f8aa24ea 47 man_pages = {
e0f7fc58
SR
48 'qemu-ga.8': (have_ga ? 'man8' : ''),
49 'qemu-ga-ref.7': (have_ga ? 'man7' : ''),
4ac2ee19 50 'qemu-qmp-ref.7': 'man7',
23c02ace 51 'qemu-storage-daemon-qmp-ref.7': (have_tools ? 'man7' : ''),
f8aa24ea
PB
52 'qemu-img.1': (have_tools ? 'man1' : ''),
53 'qemu-nbd.8': (have_tools ? 'man8' : ''),
773ee3f1 54 'qemu-pr-helper.8': (have_tools ? 'man8' : ''),
fa56cf7e 55 'qemu-storage-daemon.1': (have_tools ? 'man1' : ''),
9c29b741 56 'qemu-trace-stap.1': (stap.found() ? 'man1' : ''),
f8aa24ea 57 'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
f8aa24ea
PB
58 'qemu.1': 'man1',
59 'qemu-block-drivers.7': 'man7',
60 'qemu-cpu-models.7': 'man7'
f8aa24ea
PB
61 }
62
63 sphinxdocs = []
64 sphinxmans = []
bac35bf5 65
b93f4fbd
PM
66 private_dir = meson.current_build_dir() / 'manual.p'
67 output_dir = meson.current_build_dir() / 'manual'
68 input_dir = meson.current_source_dir()
69
70 this_manual = custom_target('QEMU manual',
f8aa24ea 71 build_by_default: build_docs,
b93f4fbd
PM
72 output: 'docs.stamp',
73 input: files('conf.py'),
74 depfile: 'docs.d',
bac35bf5
PB
75 command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
76 '-Ddepfile_stamp=@OUTPUT0@',
77 '-b', 'html', '-d', private_dir,
78 input_dir, output_dir])
b93f4fbd
PM
79 sphinxdocs += this_manual
80 install_subdir(output_dir, install_dir: qemu_docdir, strip_directory: true)
f8aa24ea 81
b93f4fbd
PM
82 these_man_pages = []
83 install_dirs = []
84 foreach page, section : man_pages
85 these_man_pages += page
86 install_dirs += section == '' ? false : get_option('mandir') / section
f8aa24ea 87 endforeach
b93f4fbd
PM
88
89 sphinxmans += custom_target('QEMU man pages',
90 build_by_default: build_docs,
91 output: these_man_pages,
92 input: this_manual,
93 install: build_docs,
94 install_dir: install_dirs,
95 command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
96 input_dir, meson.current_build_dir()])
97
f8aa24ea 98 alias_target('sphinxdocs', sphinxdocs)
4ac2ee19 99 alias_target('html', sphinxdocs)
f8aa24ea
PB
100 alias_target('man', sphinxmans)
101endif