From patchwork Wed Dec 14 15:20:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shen Jiamin X-Patchwork-Id: 13073246 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5910FC4332F for ; Wed, 14 Dec 2022 15:28:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238478AbiLNP2f (ORCPT ); Wed, 14 Dec 2022 10:28:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238370AbiLNP2e (ORCPT ); Wed, 14 Dec 2022 10:28:34 -0500 X-Greylist: delayed 419 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 14 Dec 2022 07:28:31 PST Received: from mailgw0.comp.nus.edu.sg (84-20.comp.nus.edu.sg [137.132.84.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CFBFA33A for ; Wed, 14 Dec 2022 07:28:31 -0800 (PST) Received: from localhost (avs1.comp.nus.edu.sg [192.168.20.54]) by mailgw0.comp.nus.edu.sg (Postfix) with ESMTP id 7133A400D74D7; Wed, 14 Dec 2022 23:21:30 +0800 (+08) X-Virus-Scanned: amavisd-new at comp.nus.edu.sg Received: from mailgw0.comp.nus.edu.sg ([192.168.20.35]) by localhost (avs1.comp.nus.edu.sg [192.168.20.54]) (amavisd-new, port 10024) with ESMTP id YTcNfM64Ndjq; Wed, 14 Dec 2022 23:21:24 +0800 (+08) Received: from mailauth0.comp.nus.edu.sg (mailauth0.comp.nus.edu.sg [192.168.49.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailgw0.comp.nus.edu.sg (Postfix) with ESMTPS; Wed, 14 Dec 2022 23:21:24 +0800 (+08) Received: from soccf-srl-002.comp.nus.edu.sg (soccf-srl-002.d2.comp.nus.edu.sg [172.26.191.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: e0446373) by mailauth0.comp.nus.edu.sg (Postfix) with ESMTPSA id 242F820018080; Wed, 14 Dec 2022 23:21:20 +0800 (+08) From: Shen Jiamin To: bpf@vger.kernel.org Cc: Shen Jiamin , Nathan Chancellor Subject: [PATCH] tools/resolve_btfids: Use pkg-config to locate libelf Date: Wed, 14 Dec 2022 23:20:37 +0800 Message-Id: <20221214152037.395772-1-shen_jiamin@comp.nus.edu.sg> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net When libelf was not installed in the standard location, it cannot be located by the current building config. Use pkg-config to help locate libelf in such cases. Signed-off-by: Shen Jiamin --- tools/bpf/resolve_btfids/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.34.1 diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile index 19a3112e271a..5dcc31e01149 100644 --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -56,11 +56,17 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU DESTDIR=$(LIBBPF_DESTDIR) prefix= EXTRA_CFLAGS="$(CFLAGS)" \ $(abspath $@) install_headers +LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null) +LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf) + CFLAGS += -g \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ -I$(LIBBPF_INCLUDE) \ - -I$(SUBCMD_SRC) + -I$(SUBCMD_SRC) \ + $(LIBELF_FLAGS) + +LDFLAGS += $(LIBELF_LIBS) LIBS = -lelf -lz