Skip to content

Commit

Permalink
tools/resolve_btfids: Use pkg-config to locate libelf
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LuminousXLB authored and borkmann committed Dec 15, 2022
1 parent 4fb877a commit 0e43662
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/bpf/resolve_btfids/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0e43662

Please sign in to comment.