forked from monitoring-mixins/mixtool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (37 loc) · 1.37 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
all: check-license build generate test
GITHUB_URL=github.com/monitoring-mixins/mixtool
GOOS?=$(shell uname -s | tr A-Z a-z)
GOARCH?=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m)))
OUT_DIR=_output
BIN?=mixtool
VERSION?=$(shell cat VERSION)
PKGS=$(shell go list ./... | grep -v /vendor/)
BUILDFLAGS?=-ldflags="-s -w -X main.version=$(VERSION)" -gcflags="-trimpath=$(GOPATH)" -asmflags="-trimpath=$(GOPATH)"
check-license:
@echo ">> checking license headers"
@./scripts/check_license.sh
crossbuild:
@GOOS=linux ARCH=amd64 $(MAKE) -s build
build: packr
@echo ">> generating with packr"
@packr
@$(eval OUTPUT=$(OUT_DIR)/$(GOOS)/$(GOARCH)/$(BIN))
@echo ">> building for $(GOOS)/$(GOARCH) to $(OUTPUT)"
@mkdir -p $(OUT_DIR)/$(GOOS)/$(GOARCH)
@CGO_ENABLED=0 go build --installsuffix cgo -o $(OUTPUT) $(BUILDFLAGS) $(GITHUB_URL)/cmd/$(BIN)
install: build
@$(eval OUTPUT=$(OUT_DIR)/$(GOOS)/$(GOARCH)/$(BIN))
@echo ">> copying $(BIN) into $(GOPATH)/bin/$(BIN)"
@cp $(OUTPUT) $(GOPATH)/bin/$(BIN)
test:
@echo ">> running all tests"
@go test $(PKGS)
generate: embedmd
@echo ">> generating docs"
@./scripts/generate-help-txt.sh
@$(GOPATH)/bin/embedmd -w `find ./ -path ./vendor -prune -o -name "*.md" -print`
embedmd:
@go get github.com/campoy/embedmd
packr:
@go get github.com/gobuffalo/packr/...
.PHONY: all check-license crossbuild build install test generate embedmd