]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - tools/bpf/runqslower/Makefile
1 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
2 include ..
/..
/scripts
/Makefile.
include
4 OUTPUT ?
= $(abspath .output
)/
6 BPFTOOL_OUTPUT
:= $(OUTPUT
)bpftool
/
7 DEFAULT_BPFTOOL
:= $(BPFTOOL_OUTPUT
)bpftool
8 BPFTOOL ?
= $(DEFAULT_BPFTOOL
)
9 LIBBPF_SRC
:= $(abspath ..
/..
/lib
/bpf
)
10 BPFOBJ_OUTPUT
:= $(OUTPUT
)libbpf
/
11 BPFOBJ
:= $(BPFOBJ_OUTPUT
)libbpf.a
12 BPF_INCLUDE
:= $(BPFOBJ_OUTPUT
)
13 INCLUDES
:= -I
$(OUTPUT
) -I
$(BPF_INCLUDE
) -I
$(abspath ..
/..
/lib
) \
14 -I
$(abspath ..
/..
/include/uapi
)
17 # Try to detect best kernel BTF source
18 KERNEL_REL
:= $(shell uname
-r
)
19 VMLINUX_BTF_PATHS
:= $(if
$(O
),$(O
)/vmlinux
) \
20 $(if
$(KBUILD_OUTPUT
),$(KBUILD_OUTPUT
)/vmlinux
) \
21 ..
/..
/..
/vmlinux
/sys
/kernel
/btf
/vmlinux \
22 /boot
/vmlinux-
$(KERNEL_REL
)
23 VMLINUX_BTF_PATH
:= $(or
$(VMLINUX_BTF
),$(firstword \
24 $(wildcard $(VMLINUX_BTF_PATHS
))))
30 MAKEFLAGS
+= --no-print-directory
31 submake_extras
:= feature_display
=0
36 .PHONY
: all clean runqslower
39 runqslower
: $(OUTPUT
)/runqslower
42 $(call QUIET_CLEAN
, runqslower
)
43 $(Q
)$(RM
) -r
$(BPFOBJ_OUTPUT
) $(BPFTOOL_OUTPUT
)
44 $(Q
)$(RM
) $(OUTPUT
)*.o
$(OUTPUT
)*.d
45 $(Q
)$(RM
) $(OUTPUT
)*.skel.h
$(OUTPUT
)vmlinux.h
46 $(Q
)$(RM
) $(OUTPUT
)runqslower
49 $(OUTPUT
)/runqslower
: $(OUTPUT
)/runqslower.o
$(BPFOBJ
)
50 $(QUIET_LINK
)$(CC
) $(CFLAGS
) $^
-lelf
-lz
-o
$@
52 $(OUTPUT
)/runqslower.o
: runqslower.h
$(OUTPUT
)/runqslower.skel.h \
53 $(OUTPUT
)/runqslower.bpf.o
55 $(OUTPUT
)/runqslower.bpf.o
: $(OUTPUT
)/vmlinux.h runqslower.h
57 $(OUTPUT
)/%.skel.h
: $(OUTPUT
)/%.bpf.o |
$(BPFTOOL
)
58 $(QUIET_GEN
)$(BPFTOOL
) gen skeleton
$< > $@
60 $(OUTPUT
)/%.bpf.o
: %.bpf.c
$(BPFOBJ
) |
$(OUTPUT
)
61 $(QUIET_GEN
)$(CLANG
) -g
-O2
-target bpf
$(INCLUDES
) \
62 -c
$(filter %.c
,$^
) -o
$@
&& \
65 $(OUTPUT
)/%.o
: %.c |
$(OUTPUT
)
66 $(QUIET_CC
)$(CC
) $(CFLAGS
) $(INCLUDES
) -c
$(filter %.c
,$^
) -o
$@
68 $(OUTPUT
) $(BPFOBJ_OUTPUT
) $(BPFTOOL_OUTPUT
):
69 $(QUIET_MKDIR
)mkdir
-p
$@
71 $(OUTPUT
)/vmlinux.h
: $(VMLINUX_BTF_PATH
) |
$(OUTPUT
) $(BPFTOOL
)
73 $(Q
)if
[ ! -e
"$(VMLINUX_BTF_PATH)" ] ; then \
74 echo
"Couldn't find kernel BTF; set VMLINUX_BTF to" \
75 "specify its location." >&2; \
78 $(QUIET_GEN
)$(BPFTOOL
) btf dump file
$(VMLINUX_BTF_PATH
) format c
> $@
80 $(Q
)cp
"$(VMLINUX_H)" $@
83 $(BPFOBJ
): $(wildcard $(LIBBPF_SRC
)/*.
[ch
] $(LIBBPF_SRC
)/Makefile
) |
$(BPFOBJ_OUTPUT
)
84 $(Q
)$(MAKE
) $(submake_extras
) -C
$(LIBBPF_SRC
) OUTPUT
=$(BPFOBJ_OUTPUT
) $@
86 $(DEFAULT_BPFTOOL
): |
$(BPFTOOL_OUTPUT
)
87 $(Q
)$(MAKE
) $(submake_extras
) -C ..
/bpftool OUTPUT
=$(BPFTOOL_OUTPUT
) \
88 CC
=$(HOSTCC
) LD
=$(HOSTLD
)