1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
5 # Get version number from file.
6 # Fallback to "more" for Windows compatibility.
7 version: run_command(find_program('cat', 'more'),
8 files('VERSION')).stdout().strip(),
10 default_options: ['buildtype=debugoptimized',
11 'default_library=static'],
12 meson_version: '>= 0.47.1'
15 # for default "debugoptimized" builds override optimization level 2 with 3
16 if get_option('buildtype') == 'debugoptimized'
17 add_project_arguments('-O3', language: 'c')
20 # set up some global vars for compiler, platform, configuration, etc.
21 cc = meson.get_compiler('c')
22 dpdk_conf = configuration_data()
24 dpdk_static_libraries = []
25 dpdk_driver_classes = []
27 dpdk_extra_ldflags = []
28 dpdk_app_link_libraries = []
29 dpdk_libs_disabled = []
30 dpdk_drvs_disabled = []
31 abi_version_file = files('ABI_VERSION')
33 # configure the build, and make sure configs here and in config folder are
34 # able to be included in any file. We also store a global array of include dirs
35 # for passing to pmdinfogen scripts
36 global_inc = include_directories('.', 'config',
37 'lib/librte_eal/common/include',
38 'lib/librte_eal/@0@/eal/include'.format(host_machine.system()),
42 # build libs and drivers
47 # build binaries and installable tools
54 # build any examples explicitly requested - useful for developers - and
55 # install any example code into the appropriate install path
58 # build kernel modules if enabled
59 if get_option('enable_kmods')
63 # write the build config
64 build_cfg = 'rte_build_config.h'
65 configure_file(output: build_cfg,
66 configuration: dpdk_conf,
67 install_dir: join_paths(get_option('includedir'),
68 get_option('include_subdir_arch')))
70 # for static builds, include the drivers as libs and we need to "whole-archive"
72 dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive']
74 pkg = import('pkgconfig')
75 pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args
77 pkg_extra_cflags += ['-D__BSD_VISIBLE']
79 pkg.generate(name: meson.project_name(),
80 filebase: 'lib' + meson.project_name().to_lower(),
81 version: meson.project_version(),
82 libraries: dpdk_libraries,
83 libraries_private: dpdk_drivers + dpdk_static_libraries +
84 ['-Wl,-Bdynamic'] + dpdk_extra_ldflags,
85 requires: libbsd, # apps using rte_string_fns.h may need this if enabled
86 # if libbsd is not enabled, then this is blank
87 description: '''The Data Plane Development Kit (DPDK).
88 Note that CFLAGS might contain an -march flag higher than typical baseline.
89 This is required for a number of static inline functions in the public headers.''',
90 subdirs: [get_option('include_subdir_arch'), '.'],
91 extra_cflags: pkg_extra_cflags
94 # final output, list all the libs and drivers to be built
95 # this does not affect any part of the build, for information only.
96 output_message = '\n=================\nLibraries Enabled\n=================\n'
97 output_message += '\nlibs:\n\t'
99 foreach lib:enabled_libs
100 output_message += lib + ', '
103 output_message += '\n\t'
107 message(output_message + '\n')
109 output_message = '\n===============\nDrivers Enabled\n===============\n'
110 foreach class:dpdk_driver_classes
111 class_drivers = get_variable(class + '_drivers')
112 output_message += '\n' + class + ':\n\t'
114 foreach drv:class_drivers
115 output_message += drv + ', '
118 output_message += '\n\t'
123 message(output_message + '\n')
125 output_message = '\n=================\nContent Skipped\n=================\n'
126 output_message += '\nlibs:\n\t'
127 foreach lib:dpdk_libs_disabled
128 reason = get_variable(lib.underscorify() + '_disable_reason')
129 output_message += lib + ':\t' + reason + '\n\t'
131 output_message += '\ndrivers:\n\t'
132 foreach drv:dpdk_drvs_disabled
133 reason = get_variable(drv.underscorify() + '_disable_reason')
134 output_message += drv + ':\t' + reason + '\n\t'
136 message(output_message + '\n')