]> git.proxmox.com Git - mirror_qemu.git/blob - docs/meson.build
Merge remote-tracking branch 'remotes/vsementsov/tags/pull-simplebench-2021-05-04...
[mirror_qemu.git] / docs / meson.build
1 if get_option('sphinx_build') == ''
2 sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'],
3 required: get_option('docs'))
4 else
5 sphinx_build = find_program(get_option('sphinx_build'),
6 required: get_option('docs'))
7 endif
8
9 # Check if tools are available to build documentation.
10 build_docs = false
11 if sphinx_build.found()
12 SPHINX_ARGS = ['env', 'CONFDIR=' + qemu_confdir, sphinx_build]
13 # If we're making warnings fatal, apply this to Sphinx runs as well
14 if get_option('werror')
15 SPHINX_ARGS += [ '-W' ]
16 endif
17
18 # This is a bit awkward but works: create a trivial document and
19 # try to run it with our configuration file (which enforces a
20 # version requirement). This will fail if sphinx-build is too old.
21 run_command('mkdir', ['-p', tmpdir / 'sphinx'])
22 run_command('touch', [tmpdir / 'sphinx/index.rst'])
23 sphinx_build_test_out = run_command(SPHINX_ARGS + [
24 '-c', meson.current_source_dir(),
25 '-b', 'html', tmpdir / 'sphinx',
26 tmpdir / 'sphinx/out'])
27 build_docs = (sphinx_build_test_out.returncode() == 0)
28
29 if not build_docs
30 warning('@0@: @1@'.format(sphinx_build.full_path(), sphinx_build_test_out.stderr()))
31 if get_option('docs').enabled()
32 error('Install a Python 3 version of python-sphinx and the readthedoc theme')
33 endif
34 endif
35 endif
36
37 if build_docs
38 SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + config_host['PKGVERSION']]
39
40 sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
41 meson.source_root() / 'docs/sphinx/hxtool.py',
42 meson.source_root() / 'docs/sphinx/kerneldoc.py',
43 meson.source_root() / 'docs/sphinx/kernellog.py',
44 meson.source_root() / 'docs/sphinx/qapidoc.py',
45 meson.source_root() / 'docs/sphinx/qmp_lexer.py',
46 qapi_gen_depends ]
47
48 have_ga = have_tools and config_host.has_key('CONFIG_GUEST_AGENT')
49
50 man_pages = {
51 'qemu-ga.8': (have_ga ? 'man8' : ''),
52 'qemu-ga-ref.7': (have_ga ? 'man7' : ''),
53 'qemu-qmp-ref.7': 'man7',
54 'qemu-storage-daemon-qmp-ref.7': (have_tools ? 'man7' : ''),
55 'qemu-img.1': (have_tools ? 'man1' : ''),
56 'qemu-nbd.8': (have_tools ? 'man8' : ''),
57 'qemu-pr-helper.8': (have_tools ? 'man8' : ''),
58 'qemu-storage-daemon.1': (have_tools ? 'man1' : ''),
59 'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
60 'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
61 'virtiofsd.1': (have_virtiofsd ? 'man1' : ''),
62 'qemu.1': 'man1',
63 'qemu-block-drivers.7': 'man7',
64 'qemu-cpu-models.7': 'man7'
65 }
66
67 sphinxdocs = []
68 sphinxmans = []
69
70 private_dir = meson.current_build_dir() / 'manual.p'
71 output_dir = meson.current_build_dir() / 'manual'
72 input_dir = meson.current_source_dir()
73
74 this_manual = custom_target('QEMU manual',
75 build_by_default: build_docs,
76 output: 'docs.stamp',
77 input: files('conf.py'),
78 depfile: 'docs.d',
79 depend_files: sphinx_extn_depends,
80 command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
81 '-Ddepfile_stamp=@OUTPUT0@',
82 '-b', 'html', '-d', private_dir,
83 input_dir, output_dir])
84 sphinxdocs += this_manual
85 install_subdir(output_dir, install_dir: qemu_docdir, strip_directory: true)
86
87 these_man_pages = []
88 install_dirs = []
89 foreach page, section : man_pages
90 these_man_pages += page
91 install_dirs += section == '' ? false : get_option('mandir') / section
92 endforeach
93
94 sphinxmans += custom_target('QEMU man pages',
95 build_by_default: build_docs,
96 output: these_man_pages,
97 input: this_manual,
98 install: build_docs,
99 install_dir: install_dirs,
100 command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
101 input_dir, meson.current_build_dir()])
102
103 alias_target('sphinxdocs', sphinxdocs)
104 alias_target('html', sphinxdocs)
105 alias_target('man', sphinxmans)
106 endif