From patchwork Tue Feb 26 17:46:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Boccassi X-Patchwork-Id: 50520 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 92D97375B; Tue, 26 Feb 2019 18:46:56 +0100 (CET) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id 7FC4B326D for ; Tue, 26 Feb 2019 18:46:55 +0100 (CET) Received: by mail-wr1-f66.google.com with SMTP id g12so2865984wrm.5 for ; Tue, 26 Feb 2019 09:46:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IsCcp/eLlNez05HaPFUgJTn2OhKNsyZcXaV1hTH9siM=; b=YxDia6aiPTLlOvHrDTd0XHnkglgU1gFWun9MKezCHU+WXYEQcLCScvFw3QQT/kP1ZX 03/rqj3+/onvZwfKie5Pb0/VYBV+xclGaT+jgE4duWkljW7bO0evreKQ6MwgqjSUOebX df0YjtWEvMZzxrN+8ETnaLJp9JThem6oZlqGP2nfGPKtPlM5GMpv0PPUVA/r8DXUcjgD h2uUwO2pvAES5u26aNOBobcftt84yFl3KGW4CcVZTN9Owvk7wNa1zHlfqNcQcPCoe/nk Ct1vsgp6QtON47MCjN5DGMTVZkMBM45i9TZ/8PhH9j2l/9TIspXnoVqZgn/EFjwrukMS xOzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IsCcp/eLlNez05HaPFUgJTn2OhKNsyZcXaV1hTH9siM=; b=njuLQZtgaORNAqmxPrCyaJlqM+r2IYPWPDKtES5ODdL0TEkqHriJSBnmW8nen9YpTe boK4opmBwwNaTyni84vfgp4/x4ADoo0oddFD6TLW3qyb/FPlzTa+zJIzInOWwCo7a1f+ YxU4M7VXtbW1bY/y4Vmu2EycMhOB/mdEOWXX5i8yCsu+oc2mLgfvOKJzSosgXsfEDwQF fxFZbeVRj2Xayy5wD7Z4z1ZYp1uxaIohUZHgq1bQKdQO0kodhwvbbzt9KTm6NUnBZyB5 sdqWtHrHTP4I0nKwY1bBo/yEhZQ8qm8MSnI3idk9zFjvVIbACcJJIED0Cipiynm2cGa0 PQag== X-Gm-Message-State: AHQUAuaQtrSdbpJvt8EQunPqYsmqJGj4nMe3qdyP5CiMPS5JZqgdQUgM Xvtz9B0sU/I44419Ha9v6dU2DKKq X-Google-Smtp-Source: AHgI3IYEYUU/59Q2YVcADZeyBVDvwBWFsNluKo0uEGRhNrOXu5Q26UndRc5Oe6T5C/NfbXEQIRPG8A== X-Received: by 2002:adf:e487:: with SMTP id i7mr16902562wrm.202.1551203214497; Tue, 26 Feb 2019 09:46:54 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id d21sm39690378wrc.44.2019.02.26.09.46.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 09:46:53 -0800 (PST) From: luca.boccassi@gmail.com To: dev@dpdk.org Cc: bruce.richardson@intel.com, thomas@monjalon.net Date: Tue, 26 Feb 2019 17:46:33 +0000 Message-Id: <20190226174637.27452-2-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226174637.27452-1-luca.boccassi@gmail.com> References: <20190103175725.5836-1-bluca@debian.org> <20190226174637.27452-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v8 2/6] build: use dependency() instead of find_library() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Luca Boccassi 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 Acked-by: Bruce Richardson Tested-by: Bruce Richardson --- v2: split libbsd change in a separate commit, remove CC to stable as a meson bump will be required v4: update comment in drivers/meson.build to clarify role of pkgconfig_extra_libs v5: remove -lz from drivers/compress/zlib v7: remove change from pcap pmd, as it's causing issues with cross-compilation due to missing pkg-config file drivers/compress/zlib/meson.build | 1 - drivers/crypto/ccp/meson.build | 1 - drivers/crypto/openssl/meson.build | 1 - drivers/crypto/qat/meson.build | 1 - drivers/meson.build | 9 +++++---- drivers/net/bnx2x/meson.build | 2 +- drivers/net/mlx4/meson.build | 6 +++--- drivers/net/mlx5/meson.build | 6 +++--- lib/librte_bpf/meson.build | 4 ++-- lib/librte_telemetry/meson.build | 2 +- 10 files changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/compress/zlib/meson.build b/drivers/compress/zlib/meson.build index 7748de2df..b036703c7 100644 --- a/drivers/compress/zlib/meson.build +++ b/drivers/compress/zlib/meson.build @@ -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 diff --git a/drivers/crypto/ccp/meson.build b/drivers/crypto/ccp/meson.build index e43b00591..915c4c854 100644 --- a/drivers/crypto/ccp/meson.build +++ b/drivers/crypto/ccp/meson.build @@ -18,4 +18,3 @@ sources = files('rte_ccp_pmd.c', 'ccp_pmd_ops.c') ext_deps += dep -pkgconfig_extra_libs += '-lcrypto' diff --git a/drivers/crypto/openssl/meson.build b/drivers/crypto/openssl/meson.build index 77a6596d7..d56a32366 100644 --- a/drivers/crypto/openssl/meson.build +++ b/drivers/crypto/openssl/meson.build @@ -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' diff --git a/drivers/crypto/qat/meson.build b/drivers/crypto/qat/meson.build index 9cc98d2c2..21f969735 100644 --- a/drivers/crypto/qat/meson.build +++ b/drivers/crypto/qat/meson.build @@ -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 diff --git a/drivers/meson.build b/drivers/meson.build index e37d4fe2b..69d0556d3 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -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 = [] diff --git a/drivers/net/bnx2x/meson.build b/drivers/net/bnx2x/meson.build index e3c688869..dd189ffc4 100644 --- a/drivers/net/bnx2x/meson.build +++ b/drivers/net/bnx2x/meson.build @@ -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' diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build index 4bccd68e0..b4f9672e7 100644 --- a/drivers/net/mlx4/meson.build +++ b/drivers/net/mlx4/meson.build @@ -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 diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build index 4540c455b..0cf2f0873 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -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 diff --git a/lib/librte_bpf/meson.build b/lib/librte_bpf/meson.build index bc0cd78f9..c3b1f698e 100644 --- a/lib/librte_bpf/meson.build +++ b/lib/librte_bpf/meson.build @@ -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 diff --git a/lib/librte_telemetry/meson.build b/lib/librte_telemetry/meson.build index 9492f544e..cafb26f08 100644 --- a/lib/librte_telemetry/meson.build +++ b/lib/librte_telemetry/meson.build @@ -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']