summaryrefslogtreecommitdiff
path: root/tools/bpf
diff options
context:
space:
mode:
authorShen Jiamin <shen_jiamin@comp.nus.edu.sg>2022-12-15 12:47:03 +0800
committerDaniel Borkmann <daniel@iogearbox.net>2022-12-15 22:53:10 +0100
commit0e43662e61f2569500ab83b8188c065603530785 (patch)
treedce398ff9fd8c89a5cbf95e58278786244252642 /tools/bpf
parent4fb877aaa179dcdb1676d55216482febaada457e (diff)
downloadlinux-next-0e43662e61f2569500ab83b8188c065603530785.tar.gz
tools/resolve_btfids: Use pkg-config to locate libelf
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 <shen_jiamin@comp.nus.edu.sg> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/bpf/20221215044703.400139-1-shen_jiamin@comp.nus.edu.sg
Diffstat (limited to 'tools/bpf')
-rw-r--r--tools/bpf/resolve_btfids/Makefile8
1 files changed, 6 insertions, 2 deletions
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