]> Git Repo - qemu.git/blame - docs/meson.build
accel/tcg: rename tcg-cpus functions to match module name
[qemu.git] / docs / meson.build
CommitLineData
e3667660
YL
1if get_option('sphinx_build') == ''
2 sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'],
3 required: get_option('docs'))
4else
5 sphinx_build = find_program(get_option('sphinx_build'),
6 required: get_option('docs'))
7endif
8
9# Check if tools are available to build documentation.
10build_docs = false
11if sphinx_build.found()
12 SPHINX_ARGS = [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
af2c0e85
PB
30 warning('@0@ is either too old or uses too old a Python version'
31 .format(sphinx_build.full_path()))
e3667660
YL
32 if get_option('docs').enabled()
33 error('Install a Python 3 version of python-sphinx')
34 endif
35 endif
36endif
37
f8aa24ea 38if build_docs
e3667660
YL
39 SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + config_host['PKGVERSION']]
40
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',
47 qapi_gen_depends ]
48
f8aa24ea
PB
49 configure_file(output: 'index.html',
50 input: files('index.html.in'),
51 configuration: {'VERSION': meson.project_version()},
491e74c1 52 install_dir: qemu_docdir)
f8aa24ea
PB
53 manuals = [ 'devel', 'interop', 'tools', 'specs', 'system', 'user' ]
54 man_pages = {
55 'interop' : {
56 'qemu-ga.8': (have_tools ? 'man8' : ''),
db16115f 57 'qemu-ga-ref.7': 'man7',
4ac2ee19 58 'qemu-qmp-ref.7': 'man7',
f8aa24ea
PB
59 },
60 'tools': {
61 'qemu-img.1': (have_tools ? 'man1' : ''),
62 'qemu-nbd.8': (have_tools ? 'man8' : ''),
773ee3f1 63 'qemu-pr-helper.8': (have_tools ? 'man8' : ''),
f8aa24ea
PB
64 'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
65 'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
66 'virtiofsd.1': (have_virtiofsd ? 'man1' : ''),
67 },
68 'system': {
69 'qemu.1': 'man1',
70 'qemu-block-drivers.7': 'man7',
71 'qemu-cpu-models.7': 'man7'
72 },
73 }
74
75 sphinxdocs = []
76 sphinxmans = []
77 foreach manual : manuals
78 private_dir = meson.current_build_dir() / (manual + '.p')
bac35bf5 79 output_dir = meson.current_build_dir() / manual
f8aa24ea 80 input_dir = meson.current_source_dir() / manual
bac35bf5
PB
81
82 this_manual = custom_target(manual + ' manual',
f8aa24ea 83 build_by_default: build_docs,
bac35bf5
PB
84 output: [manual + '.stamp'],
85 input: [files('conf.py'), files(manual / 'conf.py')],
86 depfile: manual + '.d',
b3f4830a 87 depend_files: sphinx_extn_depends,
bac35bf5
PB
88 command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
89 '-Ddepfile_stamp=@OUTPUT0@',
90 '-b', 'html', '-d', private_dir,
91 input_dir, output_dir])
92 sphinxdocs += this_manual
f8aa24ea 93 if build_docs and manual != 'devel'
491e74c1 94 install_subdir(output_dir, install_dir: qemu_docdir)
f8aa24ea
PB
95 endif
96
97 these_man_pages = []
98 install_dirs = []
99 foreach page, section : man_pages.get(manual, {})
100 these_man_pages += page
101 install_dirs += section == '' ? false : get_option('mandir') / section
102 endforeach
103 if these_man_pages.length() > 0
104 sphinxmans += custom_target(manual + ' man pages',
f8aa24ea
PB
105 build_by_default: build_docs,
106 output: these_man_pages,
bac35bf5 107 input: this_manual,
f8aa24ea
PB
108 install: build_docs,
109 install_dir: install_dirs,
110 command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
111 input_dir, meson.current_build_dir()])
112 endif
113 endforeach
114 alias_target('sphinxdocs', sphinxdocs)
4ac2ee19 115 alias_target('html', sphinxdocs)
f8aa24ea
PB
116 alias_target('man', sphinxmans)
117endif
This page took 0.061536 seconds and 4 git commands to generate.