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