xref: /openbmc/qemu/docs/meson.build (revision ac741a9e810f2d820bef342ff58b183e35611e41)
1SPHINX_ARGS = [config_host['SPHINX_BUILD'],
2               '-Dversion=' + meson.project_version(),
3               '-Drelease=' + config_host['PKGVERSION']]
4
5if get_option('werror')
6  SPHINX_ARGS += [ '-W' ]
7endif
8
9if build_docs
10  configure_file(output: 'index.html',
11                 input: files('index.html.in'),
12                 configuration: {'VERSION': meson.project_version()},
13                 install_dir: qemu_docdir)
14  manuals = [ 'devel', 'interop', 'tools', 'specs', 'system', 'user' ]
15  man_pages = {
16    'interop' : {
17        'qemu-ga.8': (have_tools ? 'man8' : ''),
18        'qemu-ga-ref.7': 'man7',
19        'qemu-qmp-ref.7': 'man7',
20    },
21    'tools': {
22        'qemu-img.1': (have_tools ? 'man1' : ''),
23        'qemu-nbd.8': (have_tools ? 'man8' : ''),
24        'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
25        'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
26        'virtiofsd.1': (have_virtiofsd ? 'man1' : ''),
27    },
28    'system': {
29        'qemu.1': 'man1',
30        'qemu-block-drivers.7': 'man7',
31        'qemu-cpu-models.7': 'man7'
32    },
33  }
34
35  sphinxdocs = []
36  sphinxmans = []
37  foreach manual : manuals
38    private_dir = meson.current_build_dir() / (manual + '.p')
39    output_dir = meson.current_build_dir() / manual
40    input_dir = meson.current_source_dir() / manual
41
42    this_manual = custom_target(manual + ' manual',
43                build_by_default: build_docs,
44                output: [manual + '.stamp'],
45                input: [files('conf.py'), files(manual / 'conf.py')],
46                depfile: manual + '.d',
47                command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
48                          '-Ddepfile_stamp=@OUTPUT0@',
49                          '-b', 'html', '-d', private_dir,
50                          input_dir, output_dir])
51    sphinxdocs += this_manual
52    if build_docs and manual != 'devel'
53      install_subdir(output_dir, install_dir: qemu_docdir)
54    endif
55
56    these_man_pages = []
57    install_dirs = []
58    foreach page, section : man_pages.get(manual, {})
59      these_man_pages += page
60      install_dirs += section == '' ? false : get_option('mandir') / section
61    endforeach
62    if these_man_pages.length() > 0
63      sphinxmans += custom_target(manual + ' man pages',
64                         build_by_default: build_docs,
65                         output: these_man_pages,
66                         input: this_manual,
67                         install: build_docs,
68                         install_dir: install_dirs,
69                         command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
70                                   input_dir, meson.current_build_dir()])
71    endif
72  endforeach
73  alias_target('sphinxdocs', sphinxdocs)
74  alias_target('html', sphinxdocs)
75  alias_target('man', sphinxmans)
76endif
77