forked from cilium/pwru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (47 loc) · 1.68 KB
/
Makefile
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
48
49
50
51
52
53
54
55
GO := go
GO_BUILD = CGO_ENABLED=0 $(GO) build
GO_GENERATE = $(GO) generate
GO_TAGS ?=
TARGET=pwru
INSTALL = $(QUIET)install
BINDIR ?= /usr/local/bin
VERSION=$(shell git describe --tags --always)
TEST_TIMEOUT ?= 5s
$(TARGET):
$(GO_GENERATE)
$(GO_BUILD) $(if $(GO_TAGS),-tags $(GO_TAGS)) \
-ldflags "-w -s \
-X 'github.com/cilium/pwru/internal/pwru.Version=${VERSION}'"
release:
docker run \
--rm \
--workdir /pwru \
--volume `pwd`:/pwru docker.io/library/golang:1.18.3-alpine3.16 \
sh -c "apk add --no-cache make git clang llvm && \
git config --global --add safe.directory /pwru && \
make local-release VERSION=${VERSION}"
local-release: clean
OS=linux; \
ARCHS='amd64 arm64'; \
for ARCH in $$ARCHS; do \
echo Building release binary for $$OS/$$ARCH...; \
test -d release/$$OS/$$ARCH|| mkdir -p release/$$OS/$$ARCH; \
$(GO_GENERATE) main_$$ARCH.go; \
env GOOS=$$OS GOARCH=$$ARCH $(GO_BUILD) $(if $(GO_TAGS),-tags $(GO_TAGS)) -ldflags "-w -s -X 'github.com/cilium/pwru/internal/pwru.Version=${VERSION}'" -o release/$$OS/$$ARCH/$(TARGET) ; \
tar -czf release/$(TARGET)-$$OS-$$ARCH.tar.gz -C release/$$OS/$$ARCH $(TARGET); \
(cd release && sha256sum $(TARGET)-$$OS-$$ARCH.tar.gz > $(TARGET)-$$OS-$$ARCH.tar.gz.sha256sum); \
rm -r release/$$OS; \
done; \
install: $(TARGET)
$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(INSTALL) -m 0755 $(TARGET) $(DESTDIR)$(BINDIR)
clean:
rm -f $(TARGET)
rm -f kprobepwru_bpf*
rm -f kprobemultipwru_bpf*
rm -f kprobepwruwithoutoutputskb_bpf*
rm -f kprobemultipwruwithoutoutputskb_bpf*
rm -rf ./release
test:
$(GO) test -timeout=$(TEST_TIMEOUT) -race -cover $$($(GO) list ./...)
.PHONY: $(TARGET) release local-release install clean test