-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
69 lines (59 loc) · 1.55 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
NAME := wcc
VERSION := $(shell git describe --tags --abbrev=0)
REVISION := $(shell git rev-parse --short HEAD)
GODEP := $(shell command -v dep 2> /dev/null)
GOLINT := $(shell command -v golint 2> /dev/null)
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.revision=$(REVISION)'
DISTDIR :=./dist
VENDORDIR :=./vendor
EXEC_DIRS := find * -type d -exec
.PHONY: test
test: lint
go test -race -v ./...
.PHONY: godep
godep:
ifndef GODEP
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
endif
.PHONY: golint
golint:
ifndef GOLINT
go get -u golang.org/x/lint/golint
endif
.PHONY: deps
deps: godep
dep ensure
.PHONY: build
build: deps
go build -ldflags "$(LDFLAGS)" -o $(NAME)
.PHONY: clean
clean:
go clean
rm -rf $(DISTDIR)/*
rm -rf $(VENDORDIR)/*
.PHONY: lint
lint: golint deps
go vet ./...
golint -set_exit_status `go list ./... | grep -v /vendor/`
.PHONY: install
install: test
go install -ldflags "$(LDFLAGS)"
.PHONY: cross-build
cross-build: test
rm -rf $(DISTDIR)/*
for os in darwin linux windows; do \
for arch in amd64 386; do \
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build -a -ldflags "$(LDFLAGS)" -o dist/$$os-$$arch/$(NAME); \
if [ "$${os}" = "windows" ]; then \
mv dist/$$os-$$arch/$(NAME) dist/$$os-$$arch/$(NAME).exe; \
fi; \
done; \
done
.PHONY: dist
dist: cross-build
cd dist && \
$(EXEC_DIRS) cp ../LICENSE {} \; && \
$(EXEC_DIRS) cp ../README.md {} \; && \
$(EXEC_DIRS) tar -zcf $(NAME)-${VERSION}-{}.tar.gz {} \; && \
$(EXEC_DIRS) zip -r $(NAME)-${VERSION}-{}.zip {} \; && \
cd ..