xref: /dpdk/meson.build (revision 2169d012477c41e619a1485bf19ea42ea1d2b2f2)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2017-2019 Intel Corporation
3
4project('DPDK', 'c',
5        version: files('VERSION'),
6        license: 'BSD',
7        default_options: [
8            'buildtype=release',
9            'c_std=c11',
10            'default_library=static',
11            'warning_level=2',
12        ],
13        meson_version: '>= 0.57'
14)
15
16# check for developer mode
17developer_mode = false
18if get_option('developer_mode').auto()
19    fs = import('fs')
20    developer_mode = fs.exists('.git')
21else
22    developer_mode = get_option('developer_mode').enabled()
23endif
24if developer_mode
25    message('## Building in Developer Mode ##')
26endif
27
28# set up some global vars for compiler, platform, configuration, etc.
29cc = meson.get_compiler('c')
30dpdk_source_root = meson.current_source_dir()
31dpdk_build_root = meson.current_build_dir()
32dpdk_conf = configuration_data()
33dpdk_includes = []
34dpdk_libraries = []
35dpdk_static_libraries = []
36dpdk_shared_lib_deps = []
37dpdk_static_lib_deps = []
38dpdk_chkinc_headers = []
39dpdk_driver_classes = []
40dpdk_drivers = []
41dpdk_extra_ldflags = []
42dpdk_libs_deprecated = []
43dpdk_apps_disabled = []
44dpdk_apps_enabled = []
45dpdk_libs_disabled = []
46dpdk_libs_enabled = []
47dpdk_drvs_disabled = []
48testpmd_drivers_sources = []
49testpmd_drivers_deps = []
50abi_version_file = files('ABI_VERSION')
51
52if host_machine.cpu_family().startswith('x86')
53    arch_subdir = 'x86'
54elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().startswith('aarch')
55    arch_subdir = 'arm'
56elif host_machine.cpu_family().startswith('loongarch')
57    arch_subdir = 'loongarch'
58elif host_machine.cpu_family().startswith('ppc')
59    arch_subdir = 'ppc'
60elif host_machine.cpu_family().startswith('riscv')
61    arch_subdir = 'riscv'
62endif
63
64# configure the build, and make sure configs here and in config folder are
65# able to be included in any file. We also store a global array of include dirs
66# for passing to pmdinfogen scripts
67global_inc = [include_directories('.', 'config',
68    'lib/eal/include',
69    'lib/eal/@0@/include'.format(host_machine.system()),
70    'lib/eal/@0@/include'.format(arch_subdir),
71)]
72
73# do configuration and get tool paths
74subdir('buildtools')
75subdir('config')
76
77if is_linux
78    global_inc += include_directories('kernel/linux')
79endif
80
81# build libs and drivers
82subdir('lib')
83subdir('drivers')
84
85# build binaries and installable tools
86subdir('usertools')
87subdir('app')
88
89# build docs
90subdir('doc')
91
92# build any examples explicitly requested - useful for developers - and
93# install any example code into the appropriate install path
94subdir('examples')
95install_subdir('examples',
96        install_dir: get_option('datadir') + '/dpdk',
97        exclude_files: ex_file_excludes)
98
99# build kernel modules
100subdir('kernel')
101
102# check header includes if requested
103if get_option('check_includes')
104    subdir('buildtools/chkincs')
105endif
106
107# write the build config
108build_cfg = 'rte_build_config.h'
109configure_file(output: build_cfg,
110        configuration: dpdk_conf,
111        install_dir: join_paths(get_option('includedir'),
112            get_option('include_subdir_arch')))
113
114# build pkg-config files for dpdk
115subdir('buildtools/pkg-config')
116
117if meson.is_subproject()
118    subdir('buildtools/subproject')
119endif
120
121# Final output, list all the parts to be built.
122# This does not affect any part of the build, for information only.
123output_message = '\n=================\nApplications Enabled\n=================\n'
124output_message += '\napps:\n\t'
125output_count = 0
126foreach app:dpdk_apps_enabled
127    output_message += app + ', '
128    output_count += 1
129    if output_count == 8
130        output_message += '\n\t'
131        output_count = 0
132    endif
133endforeach
134message(output_message + '\n')
135
136output_message = '\n=================\nLibraries Enabled\n=================\n'
137output_message += '\nlibs:\n\t'
138output_count = 0
139foreach lib:dpdk_libs_enabled
140    output_message += lib + ', '
141    output_count += 1
142    if output_count == 8
143        output_message += '\n\t'
144        output_count = 0
145    endif
146endforeach
147message(output_message + '\n')
148
149output_message = '\n===============\nDrivers Enabled\n===============\n'
150foreach class:dpdk_driver_classes
151    class_drivers = get_variable(class + '_drivers')
152    output_message += '\n' + class + ':\n\t'
153    output_count = 0
154    foreach drv:class_drivers
155        output_message += drv + ', '
156        output_count += 1
157        if output_count == 8
158            output_message += '\n\t'
159            output_count = 0
160        endif
161    endforeach
162endforeach
163message(output_message + '\n')
164
165output_message = '\n=================\nContent Skipped\n=================\n'
166output_message += '\napps:\n\t'
167foreach app:dpdk_apps_disabled
168    reason = get_variable('app_' + app.underscorify() + '_disable_reason')
169    output_message += app + ':\t' + reason + '\n\t'
170endforeach
171output_message += '\nlibs:\n\t'
172foreach lib:dpdk_libs_disabled
173    reason = get_variable('lib_' + lib.underscorify() + '_disable_reason')
174    output_message += lib + ':\t' + reason + '\n\t'
175endforeach
176output_message += '\ndrivers:\n\t'
177foreach drv:dpdk_drvs_disabled
178    reason = get_variable('drv_' + drv.underscorify() + '_disable_reason')
179    output_message += drv + ':\t' + reason + '\n\t'
180endforeach
181message(output_message + '\n')
182
183message('DPDK build config complete:\n' +
184        '  source path = "' + dpdk_source_root + '"\n' +
185        '  build path  = "' + dpdk_build_root + '"')
186