xref: /dpdk/buildtools/pkg-config/meson.build (revision 4a521d190467b3234343c87373604a38c8ada6d2)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2020 Intel Corporation
3
4pkg = import('pkgconfig')
5pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args
6if is_freebsd
7    pkg_extra_cflags += ['-D__BSD_VISIBLE']
8endif
9
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.
28
29
30pkg.generate(name: 'dpdk-libs',
31        filebase: 'libdpdk-libs',
32        description: '''Internal-only DPDK pkgconfig file. Not for direct use.
33Use 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)
39
40platform_flags = []
41if not is_windows
42    platform_flags += ['-Wl,--export-dynamic'] # ELF only
43endif
44pkg.generate(name: 'DPDK', # main DPDK pkgconfig file
45        filebase: 'libdpdk',
46        version: meson.project_version(),
47        description: '''The Data Plane Development Kit (DPDK).
48Note that CFLAGS might contain an -march flag higher than typical baseline.
49This is required for a number of static inline functions in the public headers.''',
50        requires: ['libdpdk-libs', libbsd], # may need libbsd for string funcs
51                      # if libbsd is not enabled, then this is blank
52        libraries_private: ['-Wl,--whole-archive'] +
53            dpdk_drivers + dpdk_static_libraries +
54            ['-Wl,--no-whole-archive'] + platform_flags
55)
56
57# For static linking with dependencies as shared libraries,
58# the internal static libraries must be flagged explicitly.
59run_command(py3, files('set-static-linker-flags.py'), check: true)
60