1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2020 Intel Corporation
4 pkg = import('pkgconfig')
5 pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args
7 pkg_extra_cflags += ['-D__BSD_VISIBLE']
10 # When calling pkg-config --static --libs, pkg-config will always output the
11 # regular libs first, and then the extra libs from Libs.private field,
12 # since the assumption is that those are additional dependencies for building
13 # statically that the .a files depend upon. The output order of .pc fields is:
14 # Libs Libs.private Requires Requires.private
15 # The fields Requires* are for package names.
16 # The flags of the DPDK libraries must be defined in Libs* fields.
17 # However, the DPDK drivers are linked only in static builds (Libs.private),
18 # and those need to come *before* the regular libraries (Libs field).
19 # This requirement is satisfied by moving the regular libs in a separate file
20 # included in the field Requires (after Libs.private).
21 # Another requirement is to allow linking dependencies as shared libraries,
22 # while linking static DPDK libraries and drivers. It is satisfied by
23 # listing the static files in Libs.private with the explicit syntax -l:libfoo.a.
24 # As a consequence, the regular DPDK libraries are already listed as static
25 # in the field Libs.private. The second occurences of DPDK libraries,
26 # included from Requires and used for shared library linkage case,
27 # are skipped in the case of static linkage thanks to the flag --as-needed.
30 pkg.generate(name: 'dpdk-libs',
31 filebase: 'libdpdk-libs',
32 description: '''Internal-only DPDK pkgconfig file. Not for direct use.
33 Use libdpdk.pc instead of this file to query DPDK compile/link arguments''',
34 version: meson.project_version(),
35 subdirs: [get_option('include_subdir_arch'), '.'],
36 extra_cflags: pkg_extra_cflags,
37 libraries: ['-Wl,--as-needed'] + dpdk_libraries,
38 libraries_private: dpdk_extra_ldflags)
40 pkg.generate(name: 'DPDK', # main DPDK pkgconfig file
42 version: meson.project_version(),
43 description: '''The Data Plane Development Kit (DPDK).
44 Note that CFLAGS might contain an -march flag higher than typical baseline.
45 This is required for a number of static inline functions in the public headers.''',
46 requires: ['libdpdk-libs', libbsd], # may need libbsd for string funcs
47 # if libbsd is not enabled, then this is blank
48 libraries_private: ['-Wl,--whole-archive'] +
49 dpdk_drivers + dpdk_static_libraries +
50 ['-Wl,--no-whole-archive']
53 # For static linking with dependencies as shared libraries,
54 # the internal static libraries must be flagged explicitly.
55 run_command(py3, 'set-static-linker-flags.py', check: true)