forked from inspektor-gadget/inspektor-gadget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.btfgen
47 lines (37 loc) · 1.43 KB
/
Makefile.btfgen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
# disable builtin rules (avoid trying to run cc for .o files)
MAKEFLAGS += --no-builtin-rules
ifndef BTFHUB_ARCHIVE
$(error BTFHUB_ARCHIVE is undefined)
endif
ifndef ARCH
$(error ARCH is undefined)
endif
SOURCE_BTF_FILES = $(shell find $(BTFHUB_ARCHIVE)/ -iregex ".*$(subst x86,x86_64,$(ARCH)).*" -type f -name '*.btf.tar.xz')
MIN_CORE_BTF_FILES = $(patsubst $(BTFHUB_ARCHIVE)/%.btf.tar.xz, $(OUTPUT)/%.btf, $(SOURCE_BTF_FILES))
BPF_ALL_O_FILES = $(shell find pkg/gadgets -type f -regex ".*\($(ARCH)\|bpfel\).o")
# Filter out BPF objects that only contain BPF maps without BPF programs
BPF_PROGS_O_FILES = $(filter-out pkg/gadgets/trace/network/tracer/graphmap_bpfel%,$(BPF_ALL_O_FILES))
.PHONY: all
all: $(MIN_CORE_BTF_FILES)
ifeq ($(V),1)
Q =
msg =
else
Q = @
msg = @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))";
MAKEFLAGS += --no-print-directory
endif
$(MIN_CORE_BTF_FILES): $(BPF_PROGS_O_FILES)
$(OUTPUT)/%.btf: BTF_FILE = $(<:.tar.xz=)
$(OUTPUT)/%.btf: $(BTFHUB_ARCHIVE)/%.btf.tar.xz
$(call msg,UNTAR,$@)
$(Q)tar xvfJ $< -C "$(dir $<)" --touch > /dev/null
$(call msg,BTFGEN,$@)
$(Q)mkdir -p "$(@D)"
$(Q)if [ -f $(BTF_FILE) ]; then $(BPFTOOL) gen min_core_btf $(BTF_FILE) $@ $(BPF_PROGS_O_FILES); else echo "$(BTF_FILE) does not exist!" >&2; fi
$(Q)rm -fr $(BTF_FILE)
# delete failed targets
.DELETE_ON_ERROR:
# keep intermediate (.skel.h, .bpf.o, etc) targets
.SECONDARY: