build: improve dependency handling
authorLuca Boccassi <bluca@debian.org>
Tue, 26 Feb 2019 17:46:33 +0000 (17:46 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 27 Feb 2019 11:13:54 +0000 (12:13 +0100)
Whenever possible (if the library ships a pkg-config file) use meson's
dependency() function to look for it, as it will automatically add it
to the Requires.private list if needed, to allow for static builds to
succeed for reverse dependencies of DPDK. Otherwise the recursive
dependencies are not parsed, and users doing static builds have to
resolve them manually by themselves.
When using this API avoid additional checks that are superfluous and
take extra time, and avoid adding the linker flag manually which causes
it to be duplicated.

Signed-off-by: Luca Boccassi <bluca@debian.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Tested-by: Bruce Richardson <bruce.richardson@intel.com>
drivers/compress/zlib/meson.build
drivers/crypto/ccp/meson.build
drivers/crypto/openssl/meson.build
drivers/crypto/qat/meson.build
drivers/meson.build
drivers/net/bnx2x/meson.build
drivers/net/mlx4/meson.build
drivers/net/mlx5/meson.build
lib/librte_bpf/meson.build
lib/librte_telemetry/meson.build

index 7748de2..b036703 100644 (file)
@@ -9,6 +9,5 @@ endif
 deps += 'bus_vdev'
 sources = files('zlib_pmd.c', 'zlib_pmd_ops.c')
 ext_deps += dep
-pkgconfig_extra_libs += '-lz'
 
 allow_experimental_apis = true
index e43b005..915c4c8 100644 (file)
@@ -18,4 +18,3 @@ sources = files('rte_ccp_pmd.c',
                'ccp_pmd_ops.c')
 
 ext_deps += dep
-pkgconfig_extra_libs += '-lcrypto'
index 77a6596..d56a323 100644 (file)
@@ -9,4 +9,3 @@ allow_experimental_apis = true
 deps += 'bus_vdev'
 sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c')
 ext_deps += dep
-pkgconfig_extra_libs += '-lcrypto'
index 9cc98d2..21f9697 100644 (file)
@@ -13,6 +13,5 @@ if dep.found()
                             'qat_sym.c',
                             'qat_sym_session.c')
        qat_ext_deps += dep
-       pkgconfig_extra_libs += '-lcrypto'
        qat_cflags += '-DBUILD_QAT_SYM'
 endif
index e37d4fe..69d0556 100644 (file)
@@ -46,10 +46,11 @@ foreach class:driver_classes
                # set up internal deps. Drivers can append/override as necessary
                deps = std_deps
                # ext_deps: Stores external library dependency got
-               # using dependency() or cc.find_library(). For most cases, we
-               # probably also need to specify the "-l" flags in
-               # pkgconfig_extra_libs variable too, so that it can be reflected
-               # in the pkgconfig output for static builds
+               # using dependency() (preferred) or find_library().
+               # For the find_library() case (but not with dependency()) we also
+               # need to specify the "-l" flags in pkgconfig_extra_libs variable
+               # too, so that it can be reflected in the pkgconfig output for
+               # static builds.
                ext_deps = []
                pkgconfig_extra_libs = []
 
index e3c6888..dd189ff 100644 (file)
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Intel Corporation
 
-dep = cc.find_library('z', required: false)
+dep = dependency('zlib', required: false)
 build = dep.found()
 ext_deps += dep
 cflags += '-DZLIB_CONST'
index 4bccd68..b4f9672 100644 (file)
@@ -14,9 +14,9 @@ if pmd_dlopen
        ]
 endif
 libs = [
-       cc.find_library('mnl', required:false),
-       cc.find_library('mlx4', required:false),
-       cc.find_library('ibverbs', required:false),
+       dependency('libmnl', required:false),
+       dependency('libmlx4', required:false),
+       dependency('libibverbs', required:false),
 ]
 build = true
 foreach lib:libs
index 4540c45..0cf2f08 100644 (file)
@@ -14,9 +14,9 @@ if pmd_dlopen
        ]
 endif
 libs = [
-       cc.find_library('mnl', required:false),
-       cc.find_library('mlx5', required:false),
-       cc.find_library('ibverbs', required:false),
+       dependency('libmnl', required:false),
+       dependency('libmlx5', required:false),
+       dependency('libibverbs', required:false),
 ]
 build = true
 foreach lib:libs
index 4fbb29d..8a79878 100644 (file)
@@ -18,8 +18,8 @@ install_headers = files('bpf_def.h',
 
 deps += ['mbuf', 'net', 'ethdev']
 
-dep = cc.find_library('elf', required: false)
-if dep.found() == true and cc.has_header('libelf.h', dependencies: dep)
+dep = dependency('libelf', required: false)
+if dep.found()
        sources += files('bpf_load_elf.c')
        ext_deps += dep
 endif
index 9492f54..cafb26f 100644 (file)
@@ -6,7 +6,7 @@ headers = files('rte_telemetry.h', 'rte_telemetry_internal.h', 'rte_telemetry_pa
 deps += ['metrics', 'ethdev']
 cflags += '-DALLOW_EXPERIMENTAL_API'
 
-jansson = cc.find_library('jansson', required: false)
+jansson = dependency('jansson', required: false)
 if jansson.found()
        ext_deps += jansson
        dpdk_app_link_libraries += ['telemetry']