f663b1c66c0854522c8df71dce68d7e0af281a5b
[dpdk.git] / buildtools / pkg-config / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2020 Intel Corporation
3
4 # for static builds, include the drivers as libs and we need to "whole-archive"
5 # them.
6 dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive']
7
8 pkg = import('pkgconfig')
9 pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args
10 if is_freebsd
11         pkg_extra_cflags += ['-D__BSD_VISIBLE']
12 endif
13
14 # When calling pkg-config --static --libs, pkg-config will always output the
15 # regular libs first, and then the extra libs from Libs.private field,
16 # since the assumption is that those are additional dependencies for building
17 # statically that the .a files depend upon. The output order of .pc fields is:
18 #   Libs   Libs.private   Requires   Requires.private
19 # The fields Requires* are for package names.
20 # The flags of the DPDK libraries must be defined in Libs* fields.
21 # However, the DPDK drivers are linked only in static builds (Libs.private),
22 # and those need to come *before* the regular libraries (Libs field).
23 # This requirement is satisfied by moving the regular libs in a separate file
24 # included in the field Requires (after Libs.private).
25
26 pkg.generate(name: 'dpdk-libs',
27         filebase: 'libdpdk-libs',
28         description: '''Internal-only DPDK pkgconfig file. Not for direct use.
29 Use libdpdk.pc instead of this file to query DPDK compile/link arguments''',
30         version: meson.project_version(),
31         subdirs: [get_option('include_subdir_arch'), '.'],
32         extra_cflags: pkg_extra_cflags,
33         libraries: dpdk_libraries,
34         libraries_private: dpdk_extra_ldflags)
35
36 pkg.generate(name: 'DPDK', # main DPDK pkgconfig file
37         filebase: 'libdpdk',
38         version: meson.project_version(),
39         description: '''The Data Plane Development Kit (DPDK).
40 Note that CFLAGS might contain an -march flag higher than typical baseline.
41 This is required for a number of static inline functions in the public headers.''',
42         requires: ['libdpdk-libs', libbsd], # may need libbsd for string funcs
43                           # if libbsd is not enabled, then this is blank
44         libraries_private: dpdk_drivers + dpdk_static_libraries +
45                         ['-Wl,-Bdynamic']
46 )