From mboxrd@z Thu Jan 1 00:00:00 1970 From: luca.boccassi@gmail.com Subject: [PATCH v8 6/6] build: use dependency for pcap and fallback to find_library Date: Tue, 26 Feb 2019 17:46:37 +0000 Message-ID: <20190226174637.27452-6-luca.boccassi@gmail.com> References: <20190103175725.5836-1-bluca@debian.org> <20190226174637.27452-1-luca.boccassi@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: bruce.richardson@intel.com, thomas@monjalon.net To: dev@dpdk.org Return-path: Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 893A42BF5 for ; Tue, 26 Feb 2019 18:47:02 +0100 (CET) Received: by mail-wr1-f67.google.com with SMTP id i12so14973321wrw.0 for ; Tue, 26 Feb 2019 09:47:02 -0800 (PST) In-Reply-To: <20190226174637.27452-1-luca.boccassi@gmail.com> 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 pcap has historically shipped a custom pcap-config binary tool which does the job of pkg-config. It was never compatible with cross compilation. Meson uses it when using dependency(), which then means cross compilation fails. Set pcap-config to empty in the meson cross compilation files so that Meson will not use it, and add a fallback in case dependency() fails. libpcap 1.9.0 finally ships a pkg-config file so everything will work out of the box in the future. Signed-off-by: Luca Boccassi --- v8: added back pcap change separately. Tested with bootlin cross-compilation toolchain, everything seems to work. config/arm/arm64_armv8_linuxapp_gcc | 1 + config/arm/arm64_dpaa2_linuxapp_gcc | 1 + config/arm/arm64_dpaa_linuxapp_gcc | 1 + config/arm/arm64_thunderx_linuxapp_gcc | 1 + drivers/net/pcap/meson.build | 16 ++++++++++++---- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/config/arm/arm64_armv8_linuxapp_gcc b/config/arm/arm64_armv8_linuxapp_gcc index 987c02fbb..513760917 100644 --- a/config/arm/arm64_armv8_linuxapp_gcc +++ b/config/arm/arm64_armv8_linuxapp_gcc @@ -3,6 +3,7 @@ c = 'aarch64-linux-gnu-gcc' cpp = 'aarch64-linux-gnu-cpp' ar = 'aarch64-linux-gnu-gcc-ar' strip = 'aarch64-linux-gnu-strip' +pcap-config = '' [host_machine] system = 'linux' diff --git a/config/arm/arm64_dpaa2_linuxapp_gcc b/config/arm/arm64_dpaa2_linuxapp_gcc index 7ec74ec4b..0df8c8f7d 100644 --- a/config/arm/arm64_dpaa2_linuxapp_gcc +++ b/config/arm/arm64_dpaa2_linuxapp_gcc @@ -4,6 +4,7 @@ cpp = 'aarch64-linux-gnu-cpp' ar = 'aarch64-linux-gnu-ar' as = 'aarch64-linux-gnu-as' strip = 'aarch64-linux-gnu-strip' +pcap-config = '' [host_machine] system = 'linux' diff --git a/config/arm/arm64_dpaa_linuxapp_gcc b/config/arm/arm64_dpaa_linuxapp_gcc index 73a8f0b81..f4b85a84b 100644 --- a/config/arm/arm64_dpaa_linuxapp_gcc +++ b/config/arm/arm64_dpaa_linuxapp_gcc @@ -4,6 +4,7 @@ cpp = 'aarch64-linux-gnu-cpp' ar = 'aarch64-linux-gnu-ar' as = 'aarch64-linux-gnu-as' strip = 'aarch64-linux-gnu-strip' +pcap-config = '' [host_machine] system = 'linux' diff --git a/config/arm/arm64_thunderx_linuxapp_gcc b/config/arm/arm64_thunderx_linuxapp_gcc index 967d9d46d..14b801998 100644 --- a/config/arm/arm64_thunderx_linuxapp_gcc +++ b/config/arm/arm64_thunderx_linuxapp_gcc @@ -3,6 +3,7 @@ c = 'aarch64-linux-gnu-gcc' cpp = 'aarch64-linux-gnu-cpp' ar = 'aarch64-linux-gnu-gcc-ar' strip = 'aarch64-linux-gnu-strip' +pcap-config = '' [host_machine] system = 'linux' diff --git a/drivers/net/pcap/meson.build b/drivers/net/pcap/meson.build index 0c4e0201a..2c2fd11e4 100644 --- a/drivers/net/pcap/meson.build +++ b/drivers/net/pcap/meson.build @@ -1,12 +1,20 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -pcap_dep = cc.find_library('pcap', required: false) -if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep) +pcap_dep = dependency('pcap', required: false) +if pcap_dep.found() build = true else - build = false + # pcap got a pkg-config file only in 1.9.0 and before that meson uses + # an internal pcap-config finder, which is not compatible with + # cross-compilation, so try to fallback to find_library + pcap_dep = cc.find_library('pcap', required: false) + if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep) + build = true + pkgconfig_extra_libs += '-lpcap' + else + build = false + endif endif sources = files('rte_eth_pcap.c') ext_deps += pcap_dep -pkgconfig_extra_libs += '-lpcap' -- 2.20.1