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
|
|
|
|
|
2020-07-14 10:25:34 +00:00
|
|
|
# always use the host compiler
|
|
|
|
AR = $(HOSTAR)
|
|
|
|
CC = $(HOSTCC)
|
|
|
|
LD = $(HOSTLD)
|
2020-09-23 18:57:35 +00:00
|
|
|
ARCH = $(HOSTARCH)
|
2021-02-05 12:40:19 +00:00
|
|
|
RM ?= rm
|
2021-12-16 16:38:39 +00:00
|
|
|
CROSS_COMPILE =
|
2022-01-12 00:25:03 +00:00
|
|
|
CFLAGS := $(KBUILD_HOSTCFLAGS)
|
|
|
|
LDFLAGS := $(KBUILD_HOSTLDFLAGS)
|
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
|
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
|
|
|
|
|
2020-07-11 21:53:21 +00:00
|
|
|
BINARY := $(OUTPUT)/resolve_btfids
|
|
|
|
BINARY_IN := $(BINARY)-in.o
|
|
|
|
|
|
|
|
all: $(BINARY)
|
|
|
|
|
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
|
|
|
|
$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
|
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) \
|
2022-01-12 00:25:03 +00:00
|
|
|
DESTDIR=$(LIBBPF_DESTDIR) prefix= EXTRA_CFLAGS="$(CFLAGS)" \
|
2021-10-07 19:44:30 +00:00
|
|
|
$(abspath $@) install_headers
|
2020-07-11 21:53:21 +00:00
|
|
|
|
2022-01-12 00:25:03 +00:00
|
|
|
CFLAGS += -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) \
|
2020-07-11 21:53:21 +00:00
|
|
|
-I$(SUBCMD_SRC)
|
|
|
|
|
|
|
|
LIBS = -lelf -lz
|
|
|
|
|
|
|
|
export srctree OUTPUT CFLAGS Q
|
|
|
|
include $(srctree)/tools/build/Makefile.include
|
|
|
|
|
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
|
|
|
$(BINARY_IN): $(BPFOBJ) fixdep FORCE | $(OUTPUT)
|
2020-07-11 21:53:21 +00:00
|
|
|
$(Q)$(MAKE) $(build)=resolve_btfids
|
|
|
|
|
|
|
|
$(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
|
|
|
|
$(call msg,LINK,$@)
|
|
|
|
$(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
|
|
|
|
|
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) \
|
2021-02-05 12:40:18 +00:00
|
|
|
$(OUTPUT)/libsubcmd \
|
|
|
|
$(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:
|
|
|
|
|
|
|
|
.PHONY: all FORCE clean tags
|