xref: /dpdk/doc/api/meson.build (revision 497cf54829c28859482998957d75477ae2b1bc1c)
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')
40cdata.set('DTS_API_MAIN_PAGE', join_paths('.', 'dts', 'index.html'))
41if get_option('werror')
42    cdata.set('WARN_AS_ERROR', 'YES')
43endif
44
45# configure HTML Doxygen run
46html_cdata = configuration_data()
47html_cdata.merge_from(cdata)
48html_cdata.set('GENERATE_HTML', 'YES')
49html_cdata.set('GENERATE_MAN', 'NO')
50html_cdata.set('FULL_PATH_NAMES', 'YES')
51
52doxy_html_conf = configure_file(input: 'doxy-api.conf.in',
53        output: 'doxy-api-html.conf',
54        configuration: html_cdata)
55
56# configure manpage Doxygen run
57man_cdata = configuration_data()
58man_cdata.merge_from(cdata)
59man_cdata.set('GENERATE_HTML', 'NO')
60man_cdata.set('GENERATE_MAN', 'YES')
61# for manpages, have the pages only titled with the header name,
62# rather than the full path to the header
63man_cdata.set('FULL_PATH_NAMES', 'NO')
64
65doxy_man_conf = configure_file(input: 'doxy-api.conf.in',
66        output: 'doxy-api-man.conf',
67        configuration: man_cdata)
68
69# do Doxygen runs
70doxy_html_build = custom_target('doxygen-html',
71        depends: example,
72        depend_files: 'doxy-api-index.md',
73        input: doxy_html_conf,
74        output: 'html',
75        depfile: 'html.d',
76        command: [generate_doxygen, '@OUTPUT@', doxygen, '@INPUT@'],
77        install: get_option('enable_docs'),
78        install_dir: htmldir,
79        build_by_default: get_option('enable_docs'))
80
81doc_targets += doxy_html_build
82doc_target_names += 'Doxygen_API(HTML)'
83
84doxy_man_build = custom_target('doxygen-man',
85        depends: example,
86        depend_files: 'doxy-api-index.md',
87        input: doxy_man_conf,
88        output: 'man',
89        depfile: 'man.d',
90        command: [generate_doxygen, '@OUTPUT@', doxygen, '@INPUT@'],
91        install: get_option('enable_docs'),
92        install_dir: get_option('datadir'),
93        build_by_default: get_option('enable_docs'))
94
95doc_targets += doxy_man_build
96doc_target_names += 'Doxygen_API(Manpage)'
97
98# refresh the manpage database on install
99# if DPDK manpages are installed to a staging directory, not in MANPATH, this has no effect
100mandb = find_program('mandb', required: false)
101if mandb.found() and get_option('enable_docs')
102    meson.add_install_script(mandb)
103endif
104
105# used by DTS to place its files into
106api_build_dir = meson.current_build_dir()
107
108subdir('dts')
109