forked from cilium/hubble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (55 loc) · 2.15 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
GO := go
INSTALL = $(QUIET)install
BINDIR ?= /usr/local/bin
IMAGE_REPOSITORY ?= quay.io/cilium/hubble
CONTAINER_ENGINE ?= docker
TARGET=hubble
VERSION=0.7.0-dev
GIT_BRANCH != which git >/dev/null 2>&1 && git rev-parse --abbrev-ref HEAD
GIT_HASH != which git >/dev/null 2>&1 && git rev-parse --short HEAD
GO_TAGS ?=
TEST_TIMEOUT ?= 5s
all: hubble
hubble:
$(GO) build $(if $(GO_TAGS),-tags $(GO_TAGS)) -ldflags "-w -s -X 'github.com/cilium/hubble/pkg.GitBranch=${GIT_BRANCH}' -X 'github.com/cilium/hubble/pkg.GitHash=$(GIT_HASH)' -X 'github.com/cilium/hubble/pkg.Version=${VERSION}'" -o $(TARGET)
release:
for OS in darwin linux windows; do \
EXT=; \
if test $$OS = "windows"; then \
EXT=".exe"; \
fi; \
for ARCH in 386 amd64; do \
test -d release/$$OS/$$ARCH|| mkdir -p release/$$OS/$$ARCH; \
env GOOS=$$OS GOARCH=$$ARCH $(GO) build $(if $(GO_TAGS),-tags $(GO_TAGS)) -ldflags "-w -s -X 'github.com/cilium/hubble/pkg.Version=${VERSION}'" -o release/$$OS/$$ARCH/$(TARGET)$$EXT; \
tar -czf release/$(TARGET)-v$(VERSION)-$$OS-$$ARCH.tar.gz -C release/$$OS/$$ARCH $(TARGET)$$EXT; \
cd release && sha256sum $(TARGET)-v$(VERSION)-$$OS-$$ARCH.tar.gz > $(TARGET)-v$(VERSION)-$$OS-$$ARCH.tar.gz.sha256sum && cd $(CURDIR); \
done; \
done
install: hubble
$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(INSTALL) -m 0755 ./hubble $(DESTDIR)$(BINDIR)
clean:
rm -f $(TARGET)
rm -rf ./release
test:
go test -timeout=$(TEST_TIMEOUT) -race -cover $$(go list ./...)
bench:
go test -timeout=30s -bench=. $$(go list ./...)
check: check-fmt ineffassign lint vet
check-fmt:
./contrib/scripts/check-fmt.sh
ineffassign:
ifeq (, $(shell which ineffassign))
$(error "ineffassign not installed; you can install it with `go get -u github.com/gordonklaus/ineffassign`")
endif
ineffassign .
lint:
ifeq (, $(shell which golint))
$(error "golint not installed; you can install it with `go get -u golang.org/x/lint/golint`")
endif
golint -set_exit_status $$(go list ./...)
vet:
go vet $$(go list ./...)
image:
$(CONTAINER_ENGINE) build -t $(IMAGE_REPOSITORY)$(if $(IMAGE_TAG),:$(IMAGE_TAG)) .
.PHONY: all hubble release install clean test bench check check-fmt ineffassign lint vet image