From patchwork Thu Dec 15 04:47:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shen Jiamin X-Patchwork-Id: 13073900 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 464EDC4332F for ; Thu, 15 Dec 2022 04:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbiLOErx (ORCPT ); Wed, 14 Dec 2022 23:47:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229704AbiLOErv (ORCPT ); Wed, 14 Dec 2022 23:47:51 -0500 Received: from mailgw1.comp.nus.edu.sg (84-20.comp.nus.edu.sg [137.132.84.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 16500532E3 for ; Wed, 14 Dec 2022 20:47:47 -0800 (PST) Received: from localhost (avs2.comp.nus.edu.sg [192.168.49.6]) by mailgw1.comp.nus.edu.sg (Postfix) with ESMTP id 495BD11A0FF; Thu, 15 Dec 2022 12:47:47 +0800 (+08) X-Virus-Scanned: amavisd-new at comp.nus.edu.sg Received: from mailgw1.comp.nus.edu.sg ([192.168.49.5]) by localhost (avs.comp.nus.edu.sg [192.168.49.6]) (amavisd-new, port 10024) with ESMTP id 3QxjVA-PDUwK; Thu, 15 Dec 2022 12:47:41 +0800 (+08) Received: from mailauth1.comp.nus.edu.sg (mailauth1.comp.nus.edu.sg [192.168.49.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailgw1.comp.nus.edu.sg (Postfix) with ESMTPS; Thu, 15 Dec 2022 12:47:41 +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 mailauth1.comp.nus.edu.sg (Postfix) with ESMTPSA id A57D0601AF6A5; Thu, 15 Dec 2022 12:47:41 +0800 (+08) From: Shen Jiamin To: Jiri Olsa , bpf@vger.kernel.org Cc: Shen Jiamin , Nathan Chancellor Subject: [PATCH v2] tools/resolve_btfids: Use pkg-config to locate libelf Date: Thu, 15 Dec 2022 12:47:03 +0800 Message-Id: <20221215044703.400139-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 Acked-by: Jiri Olsa --- tools/bpf/resolve_btfids/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.34.1 diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile index 19a3112e271a..f7375a119f54 100644 --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -56,13 +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) -LIBS = -lelf -lz +LIBS = $(LIBELF_LIBS) -lz export srctree OUTPUT CFLAGS Q include $(srctree)/tools/build/Makefile.include