1 sphinx_build = find_program(get_option('sphinx_build'),
2 required: get_option('docs'))
4 # Check if tools are available to build documentation.
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' ]
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)
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')
33 SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + get_option('pkgversion')]
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' : ''),
47 'qemu-block-drivers.7': 'man7',
48 'qemu-cpu-models.7': 'man7'
54 private_dir = meson.current_build_dir() / 'manual.p'
55 output_dir = meson.current_build_dir() / 'manual'
56 input_dir = meson.current_source_dir()
58 this_manual = custom_target('QEMU manual',
59 build_by_default: build_docs,
61 input: files('conf.py'),
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)
72 foreach page, section : man_pages
73 these_man_pages += page
74 install_dirs += section == '' ? false : get_option('mandir') / section
77 sphinxmans += custom_target('QEMU man pages',
78 build_by_default: build_docs,
79 output: these_man_pages,
82 install_dir: install_dirs,
83 command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
84 input_dir, meson.current_build_dir()])
86 alias_target('sphinxdocs', sphinxdocs)
87 alias_target('html', sphinxdocs)
88 alias_target('man', sphinxmans)