2020-07-11 21:53:21 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
include ../../scripts/Makefile.include
|
2020-09-23 18:57:35 +00:00
|
|
|
include ../../scripts/Makefile.arch
|
2020-07-11 21:53:21 +00:00
|
|
|
|
2021-02-05 12:40:19 +00:00
|
|
|
srctree := $(abspath $(CURDIR)/../../../)
|
2020-07-11 21:53:21 +00:00
|
|
|
|
|
|
|
ifeq ($(V),1)
|
|
|
|
Q =
|
|
|
|
msg =
|
|
|
|
else
|
|
|
|
Q = @
|
2022-02-01 21:25:04 +00:00
|
|
|
ifeq ($(silent),1)
|
|
|
|
msg =
|
|
|
|
else
|
|
|
|
msg = @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))";
|
|
|
|
endif
|
2020-07-11 21:53:21 +00:00
|
|
|
MAKEFLAGS=--no-print-directory
|
|
|
|
endif
|
|
|
|
|
2023-02-02 22:42:53 +00:00
|
|
|
# Overrides for the prepare step libraries.
|
2023-01-24 06:43:24 +00:00
|
|
|
HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)" \
|
2023-02-09 14:37:35 +00:00
|
|
|
CROSS_COMPILE="" EXTRA_CFLAGS="$(HOSTCFLAGS)"
|
2023-01-24 06:43:24 +00:00
|
|
|
|
2021-02-05 12:40:19 +00:00
|
|
|
RM ?= rm
|
2023-02-02 11:28:39 +00:00
|
|
|
HOSTCC ?= gcc
|
|
|
|
HOSTLD ?= ld
|
|
|
|
HOSTAR ?= ar
|
2021-12-16 16:38:39 +00:00
|
|
|
CROSS_COMPILE =
|
2020-07-14 10:25:34 +00:00
|
|
|
|
2020-07-11 21:53:21 +00:00
|
|
|
OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
|
|
|
|
|
|
|
|
LIBBPF_SRC := $(srctree)/tools/lib/bpf/
|
|
|
|
SUBCMD_SRC := $(srctree)/tools/lib/subcmd/
|
|
|
|
|
2021-02-05 12:40:17 +00:00
|
|
|
BPFOBJ := $(OUTPUT)/libbpf/libbpf.a
|
libbpf: Add LIBBPF_DEPRECATED_SINCE macro for scheduling API deprecations
Introduce a macro LIBBPF_DEPRECATED_SINCE(major, minor, message) to prepare
the deprecation of two API functions. This macro marks functions as deprecated
when libbpf's version reaches the values passed as an argument.
As part of this change libbpf_version.h header is added with recorded major
(LIBBPF_MAJOR_VERSION) and minor (LIBBPF_MINOR_VERSION) libbpf version macros.
They are now part of libbpf public API and can be relied upon by user code.
libbpf_version.h is installed system-wide along other libbpf public headers.
Due to this new build-time auto-generated header, in-kernel applications
relying on libbpf (resolve_btfids, bpftool, bpf_preload) are updated to
include libbpf's output directory as part of a list of include search paths.
Better fix would be to use libbpf's make_install target to install public API
headers, but that clean up is left out as a future improvement. The build
changes were tested by building kernel (with KBUILD_OUTPUT and O= specified
explicitly), bpftool, libbpf, selftests/bpf, and resolve_btfids builds. No
problems were detected.
Note that because of the constraints of the C preprocessor we have to write
a few lines of macro magic for each version used to prepare deprecation (0.6
for now).
Also, use LIBBPF_DEPRECATED_SINCE() to schedule deprecation of
btf__get_from_id() and btf__load(), which are replaced by
btf__load_from_kernel_by_id() and btf__load_into_kernel(), respectively,
starting from future libbpf v0.6. This is part of libbpf 1.0 effort ([0]).
[0] Closes: https://github.com/libbpf/libbpf/issues/278
Co-developed-by: Quentin Monnet <quentin@isovalent.com>
Co-developed-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210908213226.1871016-1-andrii@kernel.org
2021-09-08 21:32:26 +00:00
|
|
|
LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/
|
2021-02-05 12:40:17 +00:00
|
|
|
SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a
|
2023-01-24 06:43:23 +00:00
|
|
|
SUBCMD_OUT := $(abspath $(dir $(SUBCMDOBJ)))/
|
2020-07-11 21:53:21 +00:00
|
|
|
|
2021-10-07 19:44:30 +00:00
|
|
|
LIBBPF_DESTDIR := $(LIBBPF_OUT)
|
|
|
|
LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include
|
|
|
|
|
2023-01-24 06:43:23 +00:00
|
|
|
SUBCMD_DESTDIR := $(SUBCMD_OUT)
|
|
|
|
SUBCMD_INCLUDE := $(SUBCMD_DESTDIR)include
|
|
|
|
|
2020-07-11 21:53:21 +00:00
|
|
|
BINARY := $(OUTPUT)/resolve_btfids
|
|
|
|
BINARY_IN := $(BINARY)-in.o
|
|
|
|
|
|
|
|
all: $(BINARY)
|
|
|
|
|
2023-01-24 06:43:23 +00:00
|
|
|
prepare: $(BPFOBJ) $(SUBCMDOBJ)
|
|
|
|
|
2021-10-07 19:44:30 +00:00
|
|
|
$(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT):
|
2020-07-11 21:53:21 +00:00
|
|
|
$(call msg,MKDIR,,$@)
|
2021-02-05 12:40:17 +00:00
|
|
|
$(Q)mkdir -p $(@)
|
2020-07-11 21:53:21 +00:00
|
|
|
|
2021-02-05 12:40:17 +00:00
|
|
|
$(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
|
2023-01-24 06:43:23 +00:00
|
|
|
$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(SUBCMD_OUT) \
|
2023-01-24 06:43:24 +00:00
|
|
|
DESTDIR=$(SUBCMD_DESTDIR) $(HOST_OVERRIDES) prefix= subdir= \
|
2023-01-24 06:43:23 +00:00
|
|
|
$(abspath $@) install_headers
|
2020-07-11 21:53:21 +00:00
|
|
|
|
2021-10-07 19:44:30 +00:00
|
|
|
$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT)
|
|
|
|
$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \
|
2023-01-24 06:43:24 +00:00
|
|
|
DESTDIR=$(LIBBPF_DESTDIR) $(HOST_OVERRIDES) prefix= subdir= \
|
2021-10-07 19:44:30 +00:00
|
|
|
$(abspath $@) install_headers
|
2020-07-11 21:53:21 +00:00
|
|
|
|
2022-12-15 04:47:03 +00:00
|
|
|
LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
|
|
|
|
LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
|
|
|
|
|
2023-05-30 12:33:52 +00:00
|
|
|
HOSTCFLAGS_resolve_btfids += -g \
|
2020-07-11 21:53:21 +00:00
|
|
|
-I$(srctree)/tools/include \
|
|
|
|
-I$(srctree)/tools/include/uapi \
|
2021-10-07 19:44:30 +00:00
|
|
|
-I$(LIBBPF_INCLUDE) \
|
2023-01-24 06:43:23 +00:00
|
|
|
-I$(SUBCMD_INCLUDE) \
|
2022-12-15 04:47:03 +00:00
|
|
|
$(LIBELF_FLAGS)
|
2020-07-11 21:53:21 +00:00
|
|
|
|
2022-12-15 04:47:03 +00:00
|
|
|
LIBS = $(LIBELF_LIBS) -lz
|
2020-07-11 21:53:21 +00:00
|
|
|
|
2023-05-30 12:33:52 +00:00
|
|
|
export srctree OUTPUT HOSTCFLAGS_resolve_btfids Q HOSTCC HOSTLD HOSTAR
|
2020-07-11 21:53:21 +00:00
|
|
|
include $(srctree)/tools/build/Makefile.include
|
|
|
|
|
2023-01-24 06:43:23 +00:00
|
|
|
$(BINARY_IN): fixdep FORCE prepare | $(OUTPUT)
|
2023-02-02 11:28:39 +00:00
|
|
|
$(Q)$(MAKE) $(build)=resolve_btfids
|
2020-07-11 21:53:21 +00:00
|
|
|
|
|
|
|
$(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
|
|
|
|
$(call msg,LINK,$@)
|
2023-01-24 06:43:24 +00:00
|
|
|
$(Q)$(HOSTCC) $(BINARY_IN) $(KBUILD_HOSTLDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
|
2020-07-11 21:53:21 +00:00
|
|
|
|
2021-02-05 12:40:18 +00:00
|
|
|
clean_objects := $(wildcard $(OUTPUT)/*.o \
|
|
|
|
$(OUTPUT)/.*.o.cmd \
|
|
|
|
$(OUTPUT)/.*.o.d \
|
2021-10-07 19:44:30 +00:00
|
|
|
$(LIBBPF_OUT) \
|
|
|
|
$(LIBBPF_DESTDIR) \
|
2023-01-24 06:43:23 +00:00
|
|
|
$(SUBCMD_OUT) \
|
|
|
|
$(SUBCMD_DESTDIR) \
|
2021-02-05 12:40:18 +00:00
|
|
|
$(OUTPUT)/resolve_btfids)
|
|
|
|
|
|
|
|
ifneq ($(clean_objects),)
|
2021-02-05 12:40:17 +00:00
|
|
|
clean: fixdep-clean
|
2020-07-11 21:53:21 +00:00
|
|
|
$(call msg,CLEAN,$(BINARY))
|
2021-02-05 12:40:18 +00:00
|
|
|
$(Q)$(RM) -rf $(clean_objects)
|
|
|
|
else
|
|
|
|
clean:
|
|
|
|
endif
|
2020-07-11 21:53:21 +00:00
|
|
|
|
|
|
|
tags:
|
|
|
|
$(call msg,GEN,,tags)
|
|
|
|
$(Q)ctags -R . $(LIBBPF_SRC) $(SUBCMD_SRC)
|
|
|
|
|
|
|
|
FORCE:
|
|
|
|
|
2023-01-24 06:43:23 +00:00
|
|
|
.PHONY: all FORCE clean tags prepare
|