xref: /dpdk/meson.build (revision 2169d012477c41e619a1485bf19ea42ea1d2b2f2)
16c9457c2SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause
2428eb983SAnand Rawat# Copyright(c) 2017-2019 Intel Corporation
3a25a650bSBruce Richardson
4f6da046aSBruce Richardsonproject('DPDK', 'c',
519805430SBruce Richardson        version: files('VERSION'),
6a25a650bSBruce Richardson        license: 'BSD',
7d832326aSBruce Richardson        default_options: [
8d832326aSBruce Richardson            'buildtype=release',
933d66940SBruce Richardson            'c_std=c11',
10d832326aSBruce Richardson            'default_library=static',
11d832326aSBruce Richardson            'warning_level=2',
12d832326aSBruce Richardson        ],
136f3dbd30SBruce Richardson        meson_version: '>= 0.57'
14a25a650bSBruce Richardson)
15a25a650bSBruce Richardson
16bc461743SBruce Richardson# check for developer mode
17bc461743SBruce Richardsondeveloper_mode = false
18bc461743SBruce Richardsonif get_option('developer_mode').auto()
19bc461743SBruce Richardson    fs = import('fs')
207ccd05e7SDmitry Kozlyuk    developer_mode = fs.exists('.git')
21bc461743SBruce Richardsonelse
22bc461743SBruce Richardson    developer_mode = get_option('developer_mode').enabled()
23bc461743SBruce Richardsonendif
24bc461743SBruce Richardsonif developer_mode
25bc461743SBruce Richardson    message('## Building in Developer Mode ##')
26bc461743SBruce Richardsonendif
27bc461743SBruce Richardson
28a25a650bSBruce Richardson# set up some global vars for compiler, platform, configuration, etc.
29a25a650bSBruce Richardsoncc = meson.get_compiler('c')
30e16b972bSBruce Richardsondpdk_source_root = meson.current_source_dir()
31e16b972bSBruce Richardsondpdk_build_root = meson.current_build_dir()
32a25a650bSBruce Richardsondpdk_conf = configuration_data()
3345d7cf91SMarkus Theildpdk_includes = []
34a25a650bSBruce Richardsondpdk_libraries = []
3557ae0ec6SKevin Laatzdpdk_static_libraries = []
36f93a605fSBruce Richardsondpdk_shared_lib_deps = []
37f93a605fSBruce Richardsondpdk_static_lib_deps = []
3805050ac4SBruce Richardsondpdk_chkinc_headers = []
390ffbdd1dSAndrius Sirvysdpdk_driver_classes = []
40a25a650bSBruce Richardsondpdk_drivers = []
41a25a650bSBruce Richardsondpdk_extra_ldflags = []
42dfd5b25bSBruce Richardsondpdk_libs_deprecated = []
43ecf75180SDavid Marchanddpdk_apps_disabled = []
44405737aaSDavid Marchanddpdk_apps_enabled = []
458baad6f8SBruce Richardsondpdk_libs_disabled = []
469a04396dSDavid Marchanddpdk_libs_enabled = []
478baad6f8SBruce Richardsondpdk_drvs_disabled = []
48592ab76fSDavid Marchandtestpmd_drivers_sources = []
49592ab76fSDavid Marchandtestpmd_drivers_deps = []
503eb485c6SBruce Richardsonabi_version_file = files('ABI_VERSION')
51a25a650bSBruce Richardson
5244dfb297SBruce Richardsonif host_machine.cpu_family().startswith('x86')
5344dfb297SBruce Richardson    arch_subdir = 'x86'
5444dfb297SBruce Richardsonelif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().startswith('aarch')
5544dfb297SBruce Richardson    arch_subdir = 'arm'
5629631ee5SMin Zhouelif host_machine.cpu_family().startswith('loongarch')
5729631ee5SMin Zhou    arch_subdir = 'loongarch'
5844dfb297SBruce Richardsonelif host_machine.cpu_family().startswith('ppc')
5944dfb297SBruce Richardson    arch_subdir = 'ppc'
60f22e705eSMichal Mazurekelif host_machine.cpu_family().startswith('riscv')
61f22e705eSMichal Mazurek    arch_subdir = 'riscv'
6244dfb297SBruce Richardsonendif
6344dfb297SBruce Richardson
64a25a650bSBruce Richardson# configure the build, and make sure configs here and in config folder are
65a25a650bSBruce Richardson# able to be included in any file. We also store a global array of include dirs
66a25a650bSBruce Richardson# for passing to pmdinfogen scripts
67cf97dfd1SMaxime Coquelinglobal_inc = [include_directories('.', 'config',
6899a2dd95SBruce Richardson    'lib/eal/include',
6999a2dd95SBruce Richardson    'lib/eal/@0@/include'.format(host_machine.system()),
7099a2dd95SBruce Richardson    'lib/eal/@0@/include'.format(arch_subdir),
71cf97dfd1SMaxime Coquelin)]
7268b1f1cdSBruce Richardson
7368b1f1cdSBruce Richardson# do configuration and get tool paths
7468b1f1cdSBruce Richardsonsubdir('buildtools')
75a25a650bSBruce Richardsonsubdir('config')
76a25a650bSBruce Richardson
77cf97dfd1SMaxime Coquelinif is_linux
78cf97dfd1SMaxime Coquelin    global_inc += include_directories('kernel/linux')
79cf97dfd1SMaxime Coquelinendif
80cf97dfd1SMaxime Coquelin
819314afb6SBruce Richardson# build libs and drivers
824c773788SBruce Richardsonsubdir('lib')
839314afb6SBruce Richardsonsubdir('drivers')
84a25a650bSBruce Richardson
857dd34c71SBruce Richardson# build binaries and installable tools
867dd34c71SBruce Richardsonsubdir('usertools')
8716ade738SBruce Richardsonsubdir('app')
88a25a650bSBruce Richardson
89720b14dbSLuca Boccassi# build docs
90720b14dbSLuca Boccassisubdir('doc')
91720b14dbSLuca Boccassi
9285d7158eSBruce Richardson# build any examples explicitly requested - useful for developers - and
9385d7158eSBruce Richardson# install any example code into the appropriate install path
9489f0711fSBruce Richardsonsubdir('examples')
95e5b95003SBruce Richardsoninstall_subdir('examples',
96e5b95003SBruce Richardson        install_dir: get_option('datadir') + '/dpdk',
975d20515eSBruce Richardson        exclude_files: ex_file_excludes)
9889f0711fSBruce Richardson
99a52d472cSBruce Richardson# build kernel modules
10089200580SBruce Richardsonsubdir('kernel')
10189200580SBruce Richardson
10205050ac4SBruce Richardson# check header includes if requested
10305050ac4SBruce Richardsonif get_option('check_includes')
10405050ac4SBruce Richardson    subdir('buildtools/chkincs')
10505050ac4SBruce Richardsonendif
10605050ac4SBruce Richardson
107a25a650bSBruce Richardson# write the build config
108a25a650bSBruce Richardsonbuild_cfg = 'rte_build_config.h'
109a25a650bSBruce Richardsonconfigure_file(output: build_cfg,
110a25a650bSBruce Richardson        configuration: dpdk_conf,
111d7939c5fSLuca Boccassi        install_dir: join_paths(get_option('includedir'),
112d7939c5fSLuca Boccassi            get_option('include_subdir_arch')))
113a25a650bSBruce Richardson
11411a47f9fSBruce Richardson# build pkg-config files for dpdk
11511a47f9fSBruce Richardsonsubdir('buildtools/pkg-config')
116806c45ddSBruce Richardson
117f93a605fSBruce Richardsonif meson.is_subproject()
118f93a605fSBruce Richardson    subdir('buildtools/subproject')
119f93a605fSBruce Richardsonendif
120f93a605fSBruce Richardson
121ecf75180SDavid Marchand# Final output, list all the parts to be built.
122ecf75180SDavid Marchand# This does not affect any part of the build, for information only.
123ecf75180SDavid Marchandoutput_message = '\n=================\nApplications Enabled\n=================\n'
124ecf75180SDavid Marchandoutput_message += '\napps:\n\t'
125ecf75180SDavid Marchandoutput_count = 0
126405737aaSDavid Marchandforeach app:dpdk_apps_enabled
127ecf75180SDavid Marchand    output_message += app + ', '
128ecf75180SDavid Marchand    output_count += 1
129ecf75180SDavid Marchand    if output_count == 8
130ecf75180SDavid Marchand        output_message += '\n\t'
131ecf75180SDavid Marchand        output_count = 0
132ecf75180SDavid Marchand    endif
133ecf75180SDavid Marchandendforeach
134ecf75180SDavid Marchandmessage(output_message + '\n')
135ecf75180SDavid Marchand
136806c45ddSBruce Richardsonoutput_message = '\n=================\nLibraries Enabled\n=================\n'
137806c45ddSBruce Richardsonoutput_message += '\nlibs:\n\t'
138806c45ddSBruce Richardsonoutput_count = 0
1399a04396dSDavid Marchandforeach lib:dpdk_libs_enabled
140806c45ddSBruce Richardson    output_message += lib + ', '
141806c45ddSBruce Richardson    output_count += 1
142806c45ddSBruce Richardson    if output_count == 8
143806c45ddSBruce Richardson        output_message += '\n\t'
144806c45ddSBruce Richardson        output_count = 0
145806c45ddSBruce Richardson    endif
146806c45ddSBruce Richardsonendforeach
147806c45ddSBruce Richardsonmessage(output_message + '\n')
148806c45ddSBruce Richardson
149806c45ddSBruce Richardsonoutput_message = '\n===============\nDrivers Enabled\n===============\n'
1500ffbdd1dSAndrius Sirvysforeach class:dpdk_driver_classes
151806c45ddSBruce Richardson    class_drivers = get_variable(class + '_drivers')
152806c45ddSBruce Richardson    output_message += '\n' + class + ':\n\t'
153806c45ddSBruce Richardson    output_count = 0
154806c45ddSBruce Richardson    foreach drv:class_drivers
155806c45ddSBruce Richardson        output_message += drv + ', '
156806c45ddSBruce Richardson        output_count += 1
157806c45ddSBruce Richardson        if output_count == 8
158806c45ddSBruce Richardson            output_message += '\n\t'
159806c45ddSBruce Richardson            output_count = 0
160806c45ddSBruce Richardson        endif
161806c45ddSBruce Richardson    endforeach
162806c45ddSBruce Richardsonendforeach
163806c45ddSBruce Richardsonmessage(output_message + '\n')
1648baad6f8SBruce Richardson
1658baad6f8SBruce Richardsonoutput_message = '\n=================\nContent Skipped\n=================\n'
166ecf75180SDavid Marchandoutput_message += '\napps:\n\t'
167ecf75180SDavid Marchandforeach app:dpdk_apps_disabled
168a206a015SDavid Marchand    reason = get_variable('app_' + app.underscorify() + '_disable_reason')
169ecf75180SDavid Marchand    output_message += app + ':\t' + reason + '\n\t'
170ecf75180SDavid Marchandendforeach
1718baad6f8SBruce Richardsonoutput_message += '\nlibs:\n\t'
1728baad6f8SBruce Richardsonforeach lib:dpdk_libs_disabled
173a206a015SDavid Marchand    reason = get_variable('lib_' + lib.underscorify() + '_disable_reason')
1748baad6f8SBruce Richardson    output_message += lib + ':\t' + reason + '\n\t'
1758baad6f8SBruce Richardsonendforeach
1768baad6f8SBruce Richardsonoutput_message += '\ndrivers:\n\t'
1778baad6f8SBruce Richardsonforeach drv:dpdk_drvs_disabled
178a206a015SDavid Marchand    reason = get_variable('drv_' + drv.underscorify() + '_disable_reason')
1798baad6f8SBruce Richardson    output_message += drv + ':\t' + reason + '\n\t'
1808baad6f8SBruce Richardsonendforeach
1818baad6f8SBruce Richardsonmessage(output_message + '\n')
182*2169d012SBruce Richardson
183*2169d012SBruce Richardsonmessage('DPDK build config complete:\n' +
184*2169d012SBruce Richardson        '  source path = "' + dpdk_source_root + '"\n' +
185*2169d012SBruce Richardson        '  build path  = "' + dpdk_build_root + '"')
186