Bump minimum meson version to 0.47.1 and backport patches
[deb_dpdk.git] / debian / patches / 0005-build-use-dependency-instead-of-find_library.patch
1 Author: Luca Boccassi <bluca@debian.org>
2 Description: use dependency() instead of find_library()
3  Whenever possible (if the library ships a pkg-config file) use meson's
4  dependency() function to look for it, as it will automatically add it
5  to the Requires.private list if needed, to allow for static builds to
6  succeed for reverse dependencies of DPDK. Otherwise the recursive
7  dependencies are not parsed, and users doing static builds have to
8  resolve them manually by themselves.
9  When using this API avoid additional checks that are superfluous and
10  take extra time, and avoid adding the linker flag manually which causes
11  it to be duplicated.
12 Origin: https://patches.dpdk.org/patch/49996/
13 --- a/drivers/crypto/ccp/meson.build
14 +++ b/drivers/crypto/ccp/meson.build
15 @@ -18,4 +18,3 @@ sources = files('rte_ccp_pmd.c',
16                 'ccp_pmd_ops.c')
17  
18  ext_deps += dep
19 -pkgconfig_extra_libs += '-lcrypto'
20 --- a/drivers/crypto/openssl/meson.build
21 +++ b/drivers/crypto/openssl/meson.build
22 @@ -8,4 +8,3 @@ endif
23  deps += 'bus_vdev'
24  sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c')
25  ext_deps += dep
26 -pkgconfig_extra_libs += '-lcrypto'
27 --- a/drivers/crypto/qat/meson.build
28 +++ b/drivers/crypto/qat/meson.build
29 @@ -13,6 +13,5 @@ if dep.found()
30                              'qat_sym.c',
31                              'qat_sym_session.c')
32         qat_ext_deps += dep
33 -       pkgconfig_extra_libs += '-lcrypto'
34         qat_cflags += '-DBUILD_QAT_SYM'
35  endif
36 --- a/drivers/meson.build
37 +++ b/drivers/meson.build
38 @@ -46,10 +46,11 @@ foreach class:driver_classes
39                 # set up internal deps. Drivers can append/override as necessary
40                 deps = std_deps
41                 # ext_deps: Stores external library dependency got
42 -               # using dependency() or cc.find_library(). For most cases, we
43 -               # probably also need to specify the "-l" flags in
44 -               # pkgconfig_extra_libs variable too, so that it can be reflected
45 -               # in the pkgconfig output for static builds
46 +               # using dependency() (preferred) or find_library().
47 +               # For the find_library() case (but not with dependency()) we also
48 +               # need to specify the "-l" flags in pkgconfig_extra_libs variable
49 +               # too, so that it can be reflected in the pkgconfig output for
50 +               # static builds.
51                 ext_deps = []
52                 pkgconfig_extra_libs = []
53  
54 --- a/drivers/net/bnx2x/meson.build
55 +++ b/drivers/net/bnx2x/meson.build
56 @@ -1,7 +1,7 @@
57  # SPDX-License-Identifier: BSD-3-Clause
58  # Copyright(c) 2018 Intel Corporation
59  
60 -dep = cc.find_library('z', required: false)
61 +dep = dependency('zlib', required: false)
62  build = dep.found()
63  ext_deps += dep
64  cflags += '-DZLIB_CONST'
65 --- a/drivers/net/mlx4/meson.build
66 +++ b/drivers/net/mlx4/meson.build
67 @@ -14,9 +14,9 @@ if pmd_dlopen
68         ]
69  endif
70  libs = [
71 -       cc.find_library('mnl', required:false),
72 -       cc.find_library('mlx4', required:false),
73 -       cc.find_library('ibverbs', required:false),
74 +       dependency('libmnl', required:false),
75 +       dependency('libmlx4', required:false),
76 +       dependency('libibverbs', required:false),
77  ]
78  build = true
79  foreach lib:libs
80 --- a/drivers/net/mlx5/meson.build
81 +++ b/drivers/net/mlx5/meson.build
82 @@ -14,9 +14,9 @@ if pmd_dlopen
83         ]
84  endif
85  libs = [
86 -       cc.find_library('mnl', required:false),
87 -       cc.find_library('mlx5', required:false),
88 -       cc.find_library('ibverbs', required:false),
89 +       dependency('libmnl', required:false),
90 +       dependency('libmlx5', required:false),
91 +       dependency('libibverbs', required:false),
92  ]
93  build = true
94  foreach lib:libs
95 --- a/drivers/net/pcap/meson.build
96 +++ b/drivers/net/pcap/meson.build
97 @@ -1,12 +1,11 @@
98  # SPDX-License-Identifier: BSD-3-Clause
99  # Copyright(c) 2017 Intel Corporation
100  
101 -pcap_dep = cc.find_library('pcap', required: false)
102 -if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
103 +pcap_dep = dependency('pcap', required: false)
104 +if pcap_dep.found()
105         build = true
106  else
107         build = false
108  endif
109  sources = files('rte_eth_pcap.c')
110  ext_deps += pcap_dep
111 -pkgconfig_extra_libs += '-lpcap'
112 --- a/lib/librte_bpf/meson.build
113 +++ b/lib/librte_bpf/meson.build
114 @@ -18,8 +18,8 @@ install_headers = files('bpf_def.h',
115  
116  deps += ['mbuf', 'net', 'ethdev']
117  
118 -dep = cc.find_library('elf', required: false)
119 -if dep.found() == true and cc.has_header('libelf.h', dependencies: dep)
120 +dep = dependency('libelf', required: false)
121 +if dep.found()
122         sources += files('bpf_load_elf.c')
123         ext_deps += dep
124  endif
125 --- a/lib/librte_telemetry/meson.build
126 +++ b/lib/librte_telemetry/meson.build
127 @@ -6,7 +6,7 @@ headers = files('rte_telemetry.h', 'rte_
128  deps += ['metrics', 'ethdev']
129  cflags += '-DALLOW_EXPERIMENTAL_API'
130  
131 -jansson = cc.find_library('jansson', required: false)
132 +jansson = dependency('jansson', required: false)
133  if jansson.found()
134         ext_deps += jansson
135         dpdk_app_link_libraries += ['telemetry']
136 --- a/drivers/compress/zlib/meson.build
137 +++ b/drivers/compress/zlib/meson.build
138 @@ -9,6 +9,5 @@ endif
139  deps += 'bus_vdev'
140  sources = files('zlib_pmd.c', 'zlib_pmd_ops.c')
141  ext_deps += dep
142 -pkgconfig_extra_libs += '-lz'
143  
144  allow_experimental_apis = true