linux-user: Support f_flags in statfs64 when available.
[qemu/ar7.git] / docs / meson.build
blob8c222f96bb7caab395224ccd0ae33f20f80fd747
1 if get_option('sphinx_build') == ''
2   sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'],
3                               required: get_option('docs'))
4 else
5   sphinx_build = find_program(get_option('sphinx_build'),
6                               required: get_option('docs'))
7 endif
9 # Check if tools are available to build documentation.
10 build_docs = false
11 if 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
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)
29   if not build_docs
30     warning('@0@ exists but it is either too old or uses too old a Python version'.format(get_option('sphinx_build')))
31     if get_option('docs').enabled()
32       error('Install a Python 3 version of python-sphinx')
33     endif
34   endif
35 endif
37 if build_docs
38   SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + config_host['PKGVERSION']]
40   sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
41                           meson.source_root() / 'docs/sphinx/hxtool.py',
42                           meson.source_root() / 'docs/sphinx/kerneldoc.py',
43                           meson.source_root() / 'docs/sphinx/kernellog.py',
44                           meson.source_root() / 'docs/sphinx/qapidoc.py',
45                           meson.source_root() / 'docs/sphinx/qmp_lexer.py',
46                           qapi_gen_depends ]
48   configure_file(output: 'index.html',
49                  input: files('index.html.in'),
50                  configuration: {'VERSION': meson.project_version()},
51                  install_dir: qemu_docdir)
52   manuals = [ 'devel', 'interop', 'tools', 'specs', 'system', 'user' ]
53   man_pages = {
54     'interop' : {
55         'qemu-ga.8': (have_tools ? 'man8' : ''),
56         'qemu-ga-ref.7': 'man7',
57         'qemu-qmp-ref.7': 'man7',
58     },
59     'tools': {
60         'qemu-img.1': (have_tools ? 'man1' : ''),
61         'qemu-nbd.8': (have_tools ? 'man8' : ''),
62         'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
63         'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
64         'virtiofsd.1': (have_virtiofsd ? 'man1' : ''),
65     },
66     'system': {
67         'qemu.1': 'man1',
68         'qemu-block-drivers.7': 'man7',
69         'qemu-cpu-models.7': 'man7'
70     },
71   }
73   sphinxdocs = []
74   sphinxmans = []
75   foreach manual : manuals
76     private_dir = meson.current_build_dir() / (manual + '.p')
77     output_dir = meson.current_build_dir() / manual
78     input_dir = meson.current_source_dir() / manual
80     this_manual = custom_target(manual + ' manual',
81                 build_by_default: build_docs,
82                 output: [manual + '.stamp'],
83                 input: [files('conf.py'), files(manual / 'conf.py')],
84                 depfile: manual + '.d',
85                 depend_files: sphinx_extn_depends,
86                 command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
87                           '-Ddepfile_stamp=@OUTPUT0@',
88                           '-b', 'html', '-d', private_dir,
89                           input_dir, output_dir])
90     sphinxdocs += this_manual
91     if build_docs and manual != 'devel'
92       install_subdir(output_dir, install_dir: qemu_docdir)
93     endif
95     these_man_pages = []
96     install_dirs = []
97     foreach page, section : man_pages.get(manual, {})
98       these_man_pages += page
99       install_dirs += section == '' ? false : get_option('mandir') / section
100     endforeach
101     if these_man_pages.length() > 0
102       sphinxmans += custom_target(manual + ' man pages',
103                          build_by_default: build_docs,
104                          output: these_man_pages,
105                          input: this_manual,
106                          install: build_docs,
107                          install_dir: install_dirs,
108                          command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
109                                    input_dir, meson.current_build_dir()])
110     endif
111   endforeach
112   alias_target('sphinxdocs', sphinxdocs)
113   alias_target('html', sphinxdocs)
114   alias_target('man', sphinxmans)
115 endif