2020-01-13 07:31:42 +00:00
|
|
|
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
|
2020-11-10 16:43:08 +00:00
|
|
|
include ../../scripts/Makefile.include
|
|
|
|
|
2020-11-10 16:43:09 +00:00
|
|
|
OUTPUT ?= $(abspath .output)/
|
|
|
|
|
|
|
|
BPFTOOL_OUTPUT := $(OUTPUT)bpftool/
|
2022-07-14 02:46:11 +00:00
|
|
|
DEFAULT_BPFTOOL := $(BPFTOOL_OUTPUT)bootstrap/bpftool
|
2020-01-13 07:31:42 +00:00
|
|
|
BPFTOOL ?= $(DEFAULT_BPFTOOL)
|
|
|
|
LIBBPF_SRC := $(abspath ../../lib/bpf)
|
2020-11-10 16:43:09 +00:00
|
|
|
BPFOBJ_OUTPUT := $(OUTPUT)libbpf/
|
|
|
|
BPFOBJ := $(BPFOBJ_OUTPUT)libbpf.a
|
tools/runqslower: Install libbpf headers when building
API headers from libbpf should not be accessed directly from the
library's source directory. Instead, they should be exported with "make
install_headers". Let's make sure that runqslower installs the
headers properly when building.
We use a libbpf_hdrs target to mark the logical dependency on libbpf's
headers export for a number of object files, even though the headers
should have been exported at this time (since bpftool needs them, and is
required to generate the skeleton or the vmlinux.h).
When descending from a parent Makefile, the specific output directories
for building the library and exporting the headers are configurable with
BPFOBJ_OUTPUT and BPF_DESTDIR, respectively. This is in addition to
OUTPUT, on top of which those variables are constructed by default.
Also adjust the Makefile for the BPF selftests. We pass a number of
variables to the "make" invocation, because we want to point runqslower
to the (target) libbpf shared with other tools, instead of building its
own version. In addition, runqslower relies on (target) bpftool, and we
also want to pass the proper variables to its Makefile so that bpftool
itself reuses the same libbpf.
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211007194438.34443-6-quentin@isovalent.com
2021-10-07 19:44:31 +00:00
|
|
|
BPF_DESTDIR := $(BPFOBJ_OUTPUT)
|
|
|
|
BPF_INCLUDE := $(BPF_DESTDIR)/include
|
|
|
|
INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../include/uapi)
|
2021-12-16 16:38:42 +00:00
|
|
|
CFLAGS := -g -Wall $(CLANG_CROSS_FLAGS)
|
2023-02-10 00:11:56 +00:00
|
|
|
CFLAGS += $(EXTRA_CFLAGS)
|
|
|
|
LDFLAGS += $(EXTRA_LDFLAGS)
|
2020-01-13 07:31:42 +00:00
|
|
|
|
|
|
|
# Try to detect best kernel BTF source
|
|
|
|
KERNEL_REL := $(shell uname -r)
|
2021-02-25 23:43:18 +00:00
|
|
|
VMLINUX_BTF_PATHS := $(if $(O),$(O)/vmlinux) \
|
|
|
|
$(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \
|
|
|
|
../../../vmlinux /sys/kernel/btf/vmlinux \
|
|
|
|
/boot/vmlinux-$(KERNEL_REL)
|
2020-01-20 13:06:42 +00:00
|
|
|
VMLINUX_BTF_PATH := $(or $(VMLINUX_BTF),$(firstword \
|
|
|
|
$(wildcard $(VMLINUX_BTF_PATHS))))
|
2020-01-13 07:31:42 +00:00
|
|
|
|
|
|
|
ifeq ($(V),1)
|
|
|
|
Q =
|
|
|
|
else
|
|
|
|
Q = @
|
|
|
|
MAKEFLAGS += --no-print-directory
|
|
|
|
submake_extras := feature_display=0
|
|
|
|
endif
|
|
|
|
|
|
|
|
.DELETE_ON_ERROR:
|
|
|
|
|
tools/runqslower: Install libbpf headers when building
API headers from libbpf should not be accessed directly from the
library's source directory. Instead, they should be exported with "make
install_headers". Let's make sure that runqslower installs the
headers properly when building.
We use a libbpf_hdrs target to mark the logical dependency on libbpf's
headers export for a number of object files, even though the headers
should have been exported at this time (since bpftool needs them, and is
required to generate the skeleton or the vmlinux.h).
When descending from a parent Makefile, the specific output directories
for building the library and exporting the headers are configurable with
BPFOBJ_OUTPUT and BPF_DESTDIR, respectively. This is in addition to
OUTPUT, on top of which those variables are constructed by default.
Also adjust the Makefile for the BPF selftests. We pass a number of
variables to the "make" invocation, because we want to point runqslower
to the (target) libbpf shared with other tools, instead of building its
own version. In addition, runqslower relies on (target) bpftool, and we
also want to pass the proper variables to its Makefile so that bpftool
itself reuses the same libbpf.
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211007194438.34443-6-quentin@isovalent.com
2021-10-07 19:44:31 +00:00
|
|
|
.PHONY: all clean runqslower libbpf_hdrs
|
2020-01-13 07:31:42 +00:00
|
|
|
all: runqslower
|
|
|
|
|
|
|
|
runqslower: $(OUTPUT)/runqslower
|
|
|
|
|
|
|
|
clean:
|
2020-11-10 16:43:08 +00:00
|
|
|
$(call QUIET_CLEAN, runqslower)
|
2020-11-10 16:43:09 +00:00
|
|
|
$(Q)$(RM) -r $(BPFOBJ_OUTPUT) $(BPFTOOL_OUTPUT)
|
|
|
|
$(Q)$(RM) $(OUTPUT)*.o $(OUTPUT)*.d
|
|
|
|
$(Q)$(RM) $(OUTPUT)*.skel.h $(OUTPUT)vmlinux.h
|
|
|
|
$(Q)$(RM) $(OUTPUT)runqslower
|
|
|
|
$(Q)$(RM) -r .output
|
2020-01-13 07:31:42 +00:00
|
|
|
|
tools/runqslower: Install libbpf headers when building
API headers from libbpf should not be accessed directly from the
library's source directory. Instead, they should be exported with "make
install_headers". Let's make sure that runqslower installs the
headers properly when building.
We use a libbpf_hdrs target to mark the logical dependency on libbpf's
headers export for a number of object files, even though the headers
should have been exported at this time (since bpftool needs them, and is
required to generate the skeleton or the vmlinux.h).
When descending from a parent Makefile, the specific output directories
for building the library and exporting the headers are configurable with
BPFOBJ_OUTPUT and BPF_DESTDIR, respectively. This is in addition to
OUTPUT, on top of which those variables are constructed by default.
Also adjust the Makefile for the BPF selftests. We pass a number of
variables to the "make" invocation, because we want to point runqslower
to the (target) libbpf shared with other tools, instead of building its
own version. In addition, runqslower relies on (target) bpftool, and we
also want to pass the proper variables to its Makefile so that bpftool
itself reuses the same libbpf.
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211007194438.34443-6-quentin@isovalent.com
2021-10-07 19:44:31 +00:00
|
|
|
libbpf_hdrs: $(BPFOBJ)
|
|
|
|
|
2020-01-20 13:06:51 +00:00
|
|
|
$(OUTPUT)/runqslower: $(OUTPUT)/runqslower.o $(BPFOBJ)
|
2020-11-10 16:43:08 +00:00
|
|
|
$(QUIET_LINK)$(CC) $(CFLAGS) $^ -lelf -lz -o $@
|
2020-01-13 07:31:42 +00:00
|
|
|
|
|
|
|
$(OUTPUT)/runqslower.o: runqslower.h $(OUTPUT)/runqslower.skel.h \
|
tools/runqslower: Install libbpf headers when building
API headers from libbpf should not be accessed directly from the
library's source directory. Instead, they should be exported with "make
install_headers". Let's make sure that runqslower installs the
headers properly when building.
We use a libbpf_hdrs target to mark the logical dependency on libbpf's
headers export for a number of object files, even though the headers
should have been exported at this time (since bpftool needs them, and is
required to generate the skeleton or the vmlinux.h).
When descending from a parent Makefile, the specific output directories
for building the library and exporting the headers are configurable with
BPFOBJ_OUTPUT and BPF_DESTDIR, respectively. This is in addition to
OUTPUT, on top of which those variables are constructed by default.
Also adjust the Makefile for the BPF selftests. We pass a number of
variables to the "make" invocation, because we want to point runqslower
to the (target) libbpf shared with other tools, instead of building its
own version. In addition, runqslower relies on (target) bpftool, and we
also want to pass the proper variables to its Makefile so that bpftool
itself reuses the same libbpf.
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211007194438.34443-6-quentin@isovalent.com
2021-10-07 19:44:31 +00:00
|
|
|
$(OUTPUT)/runqslower.bpf.o | libbpf_hdrs
|
2020-01-13 07:31:42 +00:00
|
|
|
|
tools/runqslower: Install libbpf headers when building
API headers from libbpf should not be accessed directly from the
library's source directory. Instead, they should be exported with "make
install_headers". Let's make sure that runqslower installs the
headers properly when building.
We use a libbpf_hdrs target to mark the logical dependency on libbpf's
headers export for a number of object files, even though the headers
should have been exported at this time (since bpftool needs them, and is
required to generate the skeleton or the vmlinux.h).
When descending from a parent Makefile, the specific output directories
for building the library and exporting the headers are configurable with
BPFOBJ_OUTPUT and BPF_DESTDIR, respectively. This is in addition to
OUTPUT, on top of which those variables are constructed by default.
Also adjust the Makefile for the BPF selftests. We pass a number of
variables to the "make" invocation, because we want to point runqslower
to the (target) libbpf shared with other tools, instead of building its
own version. In addition, runqslower relies on (target) bpftool, and we
also want to pass the proper variables to its Makefile so that bpftool
itself reuses the same libbpf.
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211007194438.34443-6-quentin@isovalent.com
2021-10-07 19:44:31 +00:00
|
|
|
$(OUTPUT)/runqslower.bpf.o: $(OUTPUT)/vmlinux.h runqslower.h | libbpf_hdrs
|
2020-01-13 07:31:42 +00:00
|
|
|
|
|
|
|
$(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(BPFTOOL)
|
2020-11-10 16:43:08 +00:00
|
|
|
$(QUIET_GEN)$(BPFTOOL) gen skeleton $< > $@
|
2020-01-13 07:31:42 +00:00
|
|
|
|
2020-01-20 13:06:51 +00:00
|
|
|
$(OUTPUT)/%.bpf.o: %.bpf.c $(BPFOBJ) | $(OUTPUT)
|
2020-11-10 16:43:08 +00:00
|
|
|
$(QUIET_GEN)$(CLANG) -g -O2 -target bpf $(INCLUDES) \
|
2020-01-13 07:31:42 +00:00
|
|
|
-c $(filter %.c,$^) -o $@ && \
|
|
|
|
$(LLVM_STRIP) -g $@
|
|
|
|
|
|
|
|
$(OUTPUT)/%.o: %.c | $(OUTPUT)
|
2020-11-10 16:43:08 +00:00
|
|
|
$(QUIET_CC)$(CC) $(CFLAGS) $(INCLUDES) -c $(filter %.c,$^) -o $@
|
2020-01-13 07:31:42 +00:00
|
|
|
|
2020-11-10 16:43:09 +00:00
|
|
|
$(OUTPUT) $(BPFOBJ_OUTPUT) $(BPFTOOL_OUTPUT):
|
|
|
|
$(QUIET_MKDIR)mkdir -p $@
|
2020-01-13 07:31:42 +00:00
|
|
|
|
2020-01-20 13:06:42 +00:00
|
|
|
$(OUTPUT)/vmlinux.h: $(VMLINUX_BTF_PATH) | $(OUTPUT) $(BPFTOOL)
|
2021-03-03 00:40:10 +00:00
|
|
|
ifeq ($(VMLINUX_H),)
|
2020-01-20 13:06:42 +00:00
|
|
|
$(Q)if [ ! -e "$(VMLINUX_BTF_PATH)" ] ; then \
|
|
|
|
echo "Couldn't find kernel BTF; set VMLINUX_BTF to" \
|
|
|
|
"specify its location." >&2; \
|
|
|
|
exit 1;\
|
|
|
|
fi
|
2020-11-10 16:43:08 +00:00
|
|
|
$(QUIET_GEN)$(BPFTOOL) btf dump file $(VMLINUX_BTF_PATH) format c > $@
|
2021-03-03 00:40:10 +00:00
|
|
|
else
|
|
|
|
$(Q)cp "$(VMLINUX_H)" $@
|
|
|
|
endif
|
2020-01-13 07:31:42 +00:00
|
|
|
|
2020-11-10 16:43:09 +00:00
|
|
|
$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(BPFOBJ_OUTPUT)
|
tools/runqslower: Install libbpf headers when building
API headers from libbpf should not be accessed directly from the
library's source directory. Instead, they should be exported with "make
install_headers". Let's make sure that runqslower installs the
headers properly when building.
We use a libbpf_hdrs target to mark the logical dependency on libbpf's
headers export for a number of object files, even though the headers
should have been exported at this time (since bpftool needs them, and is
required to generate the skeleton or the vmlinux.h).
When descending from a parent Makefile, the specific output directories
for building the library and exporting the headers are configurable with
BPFOBJ_OUTPUT and BPF_DESTDIR, respectively. This is in addition to
OUTPUT, on top of which those variables are constructed by default.
Also adjust the Makefile for the BPF selftests. We pass a number of
variables to the "make" invocation, because we want to point runqslower
to the (target) libbpf shared with other tools, instead of building its
own version. In addition, runqslower relies on (target) bpftool, and we
also want to pass the proper variables to its Makefile so that bpftool
itself reuses the same libbpf.
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211007194438.34443-6-quentin@isovalent.com
2021-10-07 19:44:31 +00:00
|
|
|
$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(BPFOBJ_OUTPUT) \
|
|
|
|
DESTDIR=$(BPFOBJ_OUTPUT) prefix= $(abspath $@) install_headers
|
2020-01-13 07:31:42 +00:00
|
|
|
|
2022-07-14 02:46:11 +00:00
|
|
|
$(DEFAULT_BPFTOOL): | $(BPFTOOL_OUTPUT)
|
|
|
|
$(Q)$(MAKE) $(submake_extras) -C ../bpftool OUTPUT=$(BPFTOOL_OUTPUT) bootstrap
|