kuma

Форк
0
/
ebpf.mk 
54 строки · 2.4 Кб
1
# Explanation of used GNU Make concepts used in the file:
2
#
3
# "| $(DIRECTORY_NAME)" is an order-only prerequisite, which means prerequisite
4
#   that is never checked when determining if the target is out of date;
5
#   even order-only prerequisites marked as phony will not cause the target
6
#   to be rebuilt. In our case it's used to make $(DIRECTORY_NAME) directory,
7
#   if it doesn't exist.
8
# ref. https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html
9
#
10
# "$(@D)" is the directory part of the file name of the target, with the trailing
11
#   slash removed. If the value of $(@) is "dir/foo.o" then $(@D) will be
12
#   equal "dir". This value will be equal "." if $(@) does not contain a slash.
13
# ref. https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html#Automatic-Variables
14

15
RELEASE_TAG ?= main-dd8b1946a31a8ce03009a2743b18ebcc716cda61
16
RELEASE_REPO ?= https://github.com/kumahq/merbridge
17
# You can provide your own url if the tarball with all ebpf programs should be
18
# fetched from somewhere else
19
TARBALL_URL ?= $(RELEASE_REPO)/releases/download/$(RELEASE_TAG)
20
# Where should be placed directory with $(RELEASE_TAG) as name placed. We don't
21
# allow to overwrite the final $(BUILD_OUTPUT) variable,  because without $(RELEASE_TAG) and $(GOARCH), it may result in situation
22
# where without realizing, ebpf programs are not re-fetched when $(RELEASE_TAG) or $(GOARCH) changes
23
BASE_BUILD_OUTPUT = build/ebpf/$(RELEASE_TAG)
24
# Path where ebpf programs should be placed, to be compiled in when building kumactl
25
COMPILE_IN_PATH ?= ./pkg/transparentproxy/ebpf/programs
26

27
# We are placing ebpf programs inside $(BUILD_OUTPUT_WITH_TAG) directory first,
28
# as by default it contains $(RELEASE_TAG) in the path, which means
29
# if the tag changes, we will re-fetch programs
30

31
define make_ebpf_targets
32
$(1)/mb_*: | $(1)
33
	curl --progress-bar --location $(TARBALL_URL)/all-$(3).tar.gz | tar -C $$(@D) -xz
34

35
$(2)/mb_*: | $(2) $(1)/mb_*
36
	cp $(1)/mb_* $(2)
37

38
# Make $(2) $(1) directories if they don't
39
# exist
40
$(1) $(2):
41
	mkdir -p $$@
42
endef
43

44
EBF_ARCH:=amd64 arm64
45
$(foreach elt,$(EBF_ARCH),$(eval $(call make_ebpf_targets,$(BASE_BUILD_OUTPUT)/$(elt),$(COMPILE_IN_PATH)/$(elt),$(elt))))
46

47
EBF_TARGETS:=$(foreach elt,$(EBF_ARCH),$(BASE_BUILD_OUTPUT)/$(elt)/mb_* $(COMPILE_IN_PATH)/$(elt)/mb_*)
48
.PHONY: build/ebpf
49
build/ebpf: $(EBF_TARGETS)
50

51
.PHONY: clean/ebpf
52
clean/ebpf :
53
	-rm -rf $(BUILD_DIR)/ebpf
54
	find $(COMPILE_IN_PATH) -type f -name 'mb_*' -exec rm {} \;
55

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.