* [PATCH] tools/resolve_btfids: Use pkg-config to locate libelf
@ 2022-12-14 15:20 Shen Jiamin
2022-12-14 23:56 ` Jiri Olsa
0 siblings, 1 reply; 3+ messages in thread
From: Shen Jiamin @ 2022-12-14 15:20 UTC (permalink / raw)
To: bpf; +Cc: Shen Jiamin, Nathan Chancellor
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>
---
tools/bpf/resolve_btfids/Makefile | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
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
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] tools/resolve_btfids: Use pkg-config to locate libelf
2022-12-14 15:20 [PATCH] tools/resolve_btfids: Use pkg-config to locate libelf Shen Jiamin
@ 2022-12-14 23:56 ` Jiri Olsa
2022-12-15 4:57 ` Shen Jiamin
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Olsa @ 2022-12-14 23:56 UTC (permalink / raw)
To: Shen Jiamin; +Cc: bpf, Nathan Chancellor
On Wed, Dec 14, 2022 at 11:20:37PM +0800, Shen Jiamin wrote:
> 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>
> ---
> tools/bpf/resolve_btfids/Makefile | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> 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
now we can remove -lelf from LIBS.. or we could do:
LIBS = $(LIBELF_LIBS) -lz
jirka
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-15 4:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-14 15:20 [PATCH] tools/resolve_btfids: Use pkg-config to locate libelf Shen Jiamin
2022-12-14 23:56 ` Jiri Olsa
2022-12-15 4:57 ` Shen Jiamin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.