2020-07-11 23:53:21 +02:00
# SPDX-License-Identifier: GPL-2.0-only
i n c l u d e . . / . . / s c r i p t s / M a k e f i l e . i n c l u d e
2020-09-23 20:57:35 +02:00
i n c l u d e . . / . . / s c r i p t s / M a k e f i l e . a r c h
2020-07-11 23:53:21 +02:00
2021-02-05 13:40:19 +01:00
srctree := $( abspath $( CURDIR) /../../../)
2020-07-11 23:53:21 +02:00
i f e q ( $( V ) , 1 )
Q =
msg =
e l s e
Q = @
2022-02-01 14:25:04 -07:00
ifeq ( $( silent) ,1)
msg =
else
msg = @printf ' %-8s %s%s\n' " $( 1) " " $( notdir $( 2) ) " " $( if $( 3) , $( 3) ) " ;
endif
2020-07-11 23:53:21 +02:00
MAKEFLAGS = --no-print-directory
e n d i f
2023-02-02 14:42:53 -08:00
# Overrides for the prepare step libraries.
2023-01-23 22:43:24 -08:00
HOST_OVERRIDES := AR = " $( HOSTAR) " CC = " $( HOSTCC) " LD = " $( HOSTLD) " ARCH = " $( HOSTARCH) " \
2023-02-09 15:37:35 +01:00
CROSS_COMPILE = "" EXTRA_CFLAGS = " $( HOSTCFLAGS) "
2023-01-23 22:43:24 -08:00
2021-02-05 13:40:19 +01:00
RM ?= rm
2023-02-02 12:28:39 +01:00
HOSTCC ?= gcc
HOSTLD ?= ld
HOSTAR ?= ar
2021-12-16 16:38:39 +00:00
CROSS_COMPILE =
2020-07-14 12:25:34 +02:00
2020-07-11 23:53:21 +02:00
OUTPUT ?= $( srctree) /tools/bpf/resolve_btfids/
LIBBPF_SRC := $( srctree) /tools/lib/bpf/
SUBCMD_SRC := $( srctree) /tools/lib/subcmd/
2021-02-05 13:40:17 +01: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 14:32:26 -07:00
LIBBPF_OUT := $( abspath $( dir $( BPFOBJ) ) ) /
2021-02-05 13:40:17 +01:00
SUBCMDOBJ := $( OUTPUT) /libsubcmd/libsubcmd.a
2023-01-23 22:43:23 -08:00
SUBCMD_OUT := $( abspath $( dir $( SUBCMDOBJ) ) ) /
2020-07-11 23:53:21 +02:00
2021-10-07 20:44:30 +01:00
LIBBPF_DESTDIR := $( LIBBPF_OUT)
LIBBPF_INCLUDE := $( LIBBPF_DESTDIR) include
2023-01-23 22:43:23 -08:00
SUBCMD_DESTDIR := $( SUBCMD_OUT)
SUBCMD_INCLUDE := $( SUBCMD_DESTDIR) include
2020-07-11 23:53:21 +02:00
BINARY := $( OUTPUT) /resolve_btfids
BINARY_IN := $( BINARY) -in.o
all : $( BINARY )
2023-01-23 22:43:23 -08:00
prepare : $( BPFOBJ ) $( SUBCMDOBJ )
2021-10-07 20:44:30 +01:00
$(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT) :
2020-07-11 23:53:21 +02:00
$( call msg,MKDIR,,$@ )
2021-02-05 13:40:17 +01:00
$( Q) mkdir -p $( @)
2020-07-11 23:53:21 +02:00
2021-02-05 13:40:17 +01:00
$(SUBCMDOBJ) : fixdep FORCE | $( OUTPUT ) /libsubcmd
2023-01-23 22:43:23 -08:00
$( Q) $( MAKE) -C $( SUBCMD_SRC) OUTPUT = $( SUBCMD_OUT) \
2023-01-23 22:43:24 -08:00
DESTDIR = $( SUBCMD_DESTDIR) $( HOST_OVERRIDES) prefix = subdir = \
2023-01-23 22:43:23 -08:00
$( abspath $@ ) install_headers
2020-07-11 23:53:21 +02:00
2021-10-07 20:44:30 +01:00
$(BPFOBJ) : $( wildcard $ ( LIBBPF_SRC ) /*.[ch ] $ ( LIBBPF_SRC ) /Makefile ) | $( LIBBPF_OUT )
$( Q) $( MAKE) $( submake_extras) -C $( LIBBPF_SRC) OUTPUT = $( LIBBPF_OUT) \
2023-01-23 22:43:24 -08:00
DESTDIR = $( LIBBPF_DESTDIR) $( HOST_OVERRIDES) prefix = subdir = \
2021-10-07 20:44:30 +01:00
$( abspath $@ ) install_headers
2020-07-11 23:53:21 +02:00
2022-12-15 12:47:03 +08:00
LIBELF_FLAGS := $( shell $( HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
LIBELF_LIBS := $( shell $( HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
2023-02-02 12:28:39 +01:00
HOSTCFLAGS += -g \
2020-07-11 23:53:21 +02:00
-I$( srctree) /tools/include \
-I$( srctree) /tools/include/uapi \
2021-10-07 20:44:30 +01:00
-I$( LIBBPF_INCLUDE) \
2023-01-23 22:43:23 -08:00
-I$( SUBCMD_INCLUDE) \
2022-12-15 12:47:03 +08:00
$( LIBELF_FLAGS)
2020-07-11 23:53:21 +02:00
2022-12-15 12:47:03 +08:00
LIBS = $( LIBELF_LIBS) -lz
2020-07-11 23:53:21 +02:00
2023-02-02 12:28:39 +01:00
export srctree OUTPUT HOSTCFLAGS Q HOSTCC HOSTLD HOSTAR
2020-07-11 23:53:21 +02:00
i n c l u d e $( srctree ) / t o o l s / b u i l d / M a k e f i l e . i n c l u d e
2023-01-23 22:43:23 -08:00
$(BINARY_IN) : fixdep FORCE prepare | $( OUTPUT )
2023-02-02 12:28:39 +01:00
$( Q) $( MAKE) $( build) = resolve_btfids
2020-07-11 23:53:21 +02:00
$(BINARY) : $( BPFOBJ ) $( SUBCMDOBJ ) $( BINARY_IN )
$( call msg,LINK,$@ )
2023-01-23 22:43:24 -08:00
$( Q) $( HOSTCC) $( BINARY_IN) $( KBUILD_HOSTLDFLAGS) -o $@ $( BPFOBJ) $( SUBCMDOBJ) $( LIBS)
2020-07-11 23:53:21 +02:00
2021-02-05 13:40:18 +01:00
clean_objects := $( wildcard $( OUTPUT) /*.o \
$( OUTPUT) /.*.o.cmd \
$( OUTPUT) /.*.o.d \
2021-10-07 20:44:30 +01:00
$( LIBBPF_OUT) \
$( LIBBPF_DESTDIR) \
2023-01-23 22:43:23 -08:00
$( SUBCMD_OUT) \
$( SUBCMD_DESTDIR) \
2021-02-05 13:40:18 +01:00
$( OUTPUT) /resolve_btfids)
i f n e q ( $( clean_objects ) , )
2021-02-05 13:40:17 +01:00
clean : fixdep -clean
2020-07-11 23:53:21 +02:00
$( call msg,CLEAN,$( BINARY) )
2021-02-05 13:40:18 +01:00
$( Q) $( RM) -rf $( clean_objects)
e l s e
clean :
e n d i f
2020-07-11 23:53:21 +02:00
tags :
$( call msg,GEN,,tags)
$( Q) ctags -R . $( LIBBPF_SRC) $( SUBCMD_SRC)
FORCE :
2023-01-23 22:43:23 -08:00
.PHONY : all FORCE clean tags prepare