xref: /dpdk/doc/api/meson.build (revision 21a66096bb44a4468353782c36fc85913520dc6c)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2018 Luca Boccassi <bluca@debian.org>
3
4doxygen = find_program('doxygen', required: get_option('enable_docs'))
5
6if not doxygen.found()
7  # process DTS API doc build even if DPDK API doc build can't be done
8  cdata = configuration_data()
9  subdir('dts')
10  subdir_done()
11endif
12
13# due to the CSS customisation script, which needs to run on a file that
14# is in a subdirectory that is created at build time and thus it cannot
15# be an individual custom_target, we need to wrap the doxygen call in a
16# script to run the CSS modification afterwards
17generate_doxygen = py3 + files('generate_doxygen.py')
18generate_examples = py3 + files('generate_examples.py')
19
20htmldir = join_paths(get_option('datadir'), 'doc', 'dpdk')
21
22# due to the following bug: https://github.com/mesonbuild/meson/issues/4107
23# if install is set to true it will override build_by_default and it will
24# cause the target to always be built. If install were to be always set to
25# false it would be impossible to install the docs.
26# So use a configure option for now.
27example = custom_target('examples.dox',
28        output: 'examples.dox',
29        command: [generate_examples, join_paths(dpdk_source_root, 'examples'), '@OUTPUT@'],
30        depfile: 'examples.dox.d',
31        install: get_option('enable_docs'),
32        install_dir: htmldir,
33        build_by_default: get_option('enable_docs'))
34
35# set up common Doxygen configuration
36cdata = configuration_data()
37cdata.set('VERSION', meson.project_version())
38cdata.set('API_EXAMPLES', join_paths(dpdk_build_root, 'doc', 'api', 'examples.dox'))
39cdata.set('OUTPUT', join_paths(dpdk_build_root, 'doc', 'api'))
40cdata.set('TOPDIR', dpdk_source_root)
41cdata.set('STRIP_FROM_PATH', ' '.join([dpdk_source_root, join_paths(dpdk_build_root, 'doc', 'api')]))
42cdata.set('WARN_AS_ERROR', 'NO')
43if get_option('werror')
44    cdata.set('WARN_AS_ERROR', 'YES')
45endif
46
47# configure HTML Doxygen run
48html_cdata = configuration_data()
49html_cdata.merge_from(cdata)
50html_cdata.set('GENERATE_HTML', 'YES')
51html_cdata.set('GENERATE_MAN', 'NO')
52html_cdata.set('FULL_PATH_NAMES', 'YES')
53
54doxy_html_conf = configure_file(input: 'doxy-api.conf.in',
55        output: 'doxy-api-html.conf',
56        configuration: html_cdata)
57
58# configure manpage Doxygen run
59man_cdata = configuration_data()
60man_cdata.merge_from(cdata)
61man_cdata.set('GENERATE_HTML', 'NO')
62man_cdata.set('GENERATE_MAN', 'YES')
63# for manpages, have the pages only titled with the header name,
64# rather than the full path to the header
65man_cdata.set('FULL_PATH_NAMES', 'NO')
66
67doxy_man_conf = configure_file(input: 'doxy-api.conf.in',
68        output: 'doxy-api-man.conf',
69        configuration: man_cdata)
70
71# do Doxygen runs
72doxy_html_build = custom_target('doxygen-html',
73        depends: example,
74        depend_files: 'doxy-api-index.md',
75        input: doxy_html_conf,
76        output: 'html',
77        depfile: 'html.d',
78        command: [generate_doxygen, '@OUTPUT@', doxygen, '@INPUT@'],
79        install: get_option('enable_docs'),
80        install_dir: htmldir,
81        build_by_default: get_option('enable_docs'))
82
83doc_targets += doxy_html_build
84doc_target_names += 'Doxygen_API(HTML)'
85
86doxy_man_build = custom_target('doxygen-man',
87        depends: example,
88        depend_files: 'doxy-api-index.md',
89        input: doxy_man_conf,
90        output: 'man',
91        depfile: 'man.d',
92        command: [generate_doxygen, '@OUTPUT@', doxygen, '@INPUT@'],
93        install: get_option('enable_docs'),
94        install_dir: get_option('datadir'),
95        build_by_default: get_option('enable_docs'))
96
97doc_targets += doxy_man_build
98doc_target_names += 'Doxygen_API(Manpage)'
99
100# refresh the manpage database on install
101# if DPDK manpages are installed to a staging directory, not in MANPATH, this has no effect
102mandb = find_program('mandb', required: false)
103if mandb.found() and get_option('enable_docs')
104    meson.add_install_script(mandb)
105endif
106
107subdir('dts')
108