-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
64 lines (47 loc) · 1.44 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
COMMANDS=kperf
CONTRIB_COMMANDS=runkperf
# PREFIX is base path to install.
PREFIX ?= /usr/local
GO_BUILDTAGS = -tags "osusergo netgo static_build"
# IMAGE_REPO is default repo for image-build recipe.
IMAGE_REPO ?= localhost:5000
IMAGE_TAG ?= latest
IMAGE_NAME = $(IMAGE_REPO)/kperf:$(IMAGE_TAG)
BINARIES=$(addprefix bin/,$(COMMANDS))
CONTRIB_BINARIES=$(addprefix bin/contrib/,$(CONTRIB_COMMANDS))
# default recipe is build
.DEFAULT_GOAL := build
# Always build
ALWAYS:
bin/%: cmd/% ALWAYS
@echo $@
@CGO_ENABLED=0 go build -o $@ ${GO_BUILDTAGS} ./$<
bin/contrib/%: contrib/cmd/% ALWAYS
@echo $@
@CGO_ENABLED=0 go build -o $@ ${GO_BUILDTAGS} ./$<
build: $(BINARIES) $(CONTRIB_BINARIES) ## build binaries
@echo "$@"
install: ## install binaries
@install -d $(PREFIX)/bin
@install $(BINARIES) $(PREFIX)/bin
@install $(CONTRIB_BINARIES) $(PREFIX)/bin
image-build: ## build image
@echo building ${IMAGE_NAME}
@docker build . -t ${IMAGE_NAME}
image-push: image-build ## push image
@echo pushing ${IMAGE_NAME}
@docker push ${IMAGE_NAME}
image-clean: ## clean image
@echo cleaning ${IMAGE_NAME}
@docker rmi ${IMAGE_NAME}
test: ## run test
@go test -v ./...
lint: ## run lint
@golangci-lint run --config .golangci.yml
.PHONY: clean
clean: ## clean up binaries
@rm -f $(BINARIES)
@rm -f $(CONTRIB_BINARIES)
.PHONY: help
help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-36s\033[0m%s\n", $$1, $$2}' $(MAKEFILE_LIST)