1 if get_option('sphinx_build') == ''
2 sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'],
3 required: get_option('docs'))
5 sphinx_build = find_program(get_option('sphinx_build'),
6 required: get_option('docs'))
9 # Check if tools are available to build documentation.
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' ]
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)
30 warning('@0@ is either too old or uses too old a Python version'
31 .format(sphinx_build.full_path()))
32 if get_option('docs').enabled()
33 error('Install a Python 3 version of python-sphinx')
39 SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + config_host['PKGVERSION']]
41 sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
42 meson.source_root() / 'docs/sphinx/hxtool.py',
43 meson.source_root() / 'docs/sphinx/kerneldoc.py',
44 meson.source_root() / 'docs/sphinx/kernellog.py',
45 meson.source_root() / 'docs/sphinx/qapidoc.py',
46 meson.source_root() / 'docs/sphinx/qmp_lexer.py',
49 configure_file(output: 'index.html',
50 input: files('index.html.in'),
51 configuration: {'VERSION': meson.project_version()},
52 install_dir: qemu_docdir)
53 manuals = [ 'devel', 'interop', 'tools', 'specs', 'system', 'user' ]
56 'qemu-ga.8': (have_tools ? 'man8' : ''),
57 'qemu-ga-ref.7': 'man7',
58 'qemu-qmp-ref.7': 'man7',
59 'qemu-storage-daemon-qmp-ref.7': (have_tools ? 'man7' : ''),
62 'qemu-img.1': (have_tools ? 'man1' : ''),
63 'qemu-nbd.8': (have_tools ? 'man8' : ''),
64 'qemu-pr-helper.8': (have_tools ? 'man8' : ''),
65 'qemu-storage-daemon.1': (have_tools ? 'man1' : ''),
66 'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
67 'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
68 'virtiofsd.1': (have_virtiofsd ? 'man1' : ''),
72 'qemu-block-drivers.7': 'man7',
73 'qemu-cpu-models.7': 'man7'
79 foreach manual : manuals
80 private_dir = meson.current_build_dir() / (manual + '.p')
81 output_dir = meson.current_build_dir() / manual
82 input_dir = meson.current_source_dir() / manual
84 this_manual = custom_target(manual + ' manual',
85 build_by_default: build_docs,
86 output: [manual + '.stamp'],
87 input: [files('conf.py'), files(manual / 'conf.py')],
88 depfile: manual + '.d',
89 depend_files: sphinx_extn_depends,
90 command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
91 '-Ddepfile_stamp=@OUTPUT0@',
92 '-b', 'html', '-d', private_dir,
93 input_dir, output_dir])
94 sphinxdocs += this_manual
95 if build_docs and manual != 'devel'
96 install_subdir(output_dir, install_dir: qemu_docdir)
101 foreach page, section : man_pages.get(manual, {})
102 these_man_pages += page
103 install_dirs += section == '' ? false : get_option('mandir') / section
105 if these_man_pages.length() > 0
106 sphinxmans += custom_target(manual + ' man pages',
107 build_by_default: build_docs,
108 output: these_man_pages,
111 install_dir: install_dirs,
112 command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
113 input_dir, meson.current_build_dir()])
116 alias_target('sphinxdocs', sphinxdocs)
117 alias_target('html', sphinxdocs)
118 alias_target('man', sphinxmans)