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