-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
68 lines (56 loc) · 1.5 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
NAME := spm
SRCS := $(shell find . -type d -name vendor -prune -o -type f -name "*.go" -print)
VERSION := 0.2.1
REVISION := $(shell git rev-parse --short HEAD)
LDFLAGS := -ldflags="-s -w -X \"main.Version=$(VERSION)\" -X \"main.Revision=$(REVISION)\""
DIST_DIRS := find * -type d -exec
.DEFAULT_GOAL := bin/$(NAME)
.PHONY: test
test:
@go test -v ./...
.PHONY: install
install: bin/$(NAME)
mv bin/$(NAME) /usr/local/bin/$(NAME)
.PHONY: clean
clean:
@rm -rf bin/*
@rm -rf vendor/*
@rm -rf dist/*
.PHONY: format
format: import
-@goimports -w $(SRCS)
@gofmt -w $(SRCS)
.PHONY: import
import:
go get golang.org/x/tools/cmd/goimports
.PHONY: cross-build
cross-build: deps
-@goimports -w $(SRCS)
@gofmt -w $(SRCS)
@for os in darwin linux windows; do \
for arch in amd64 386; do \
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build -a -tags netgo \
-installsuffix netgo $(LDFLAGS) -o dist/$$os-$$arch/$(NAME); \
done; \
done
.PHONY: dep
dep:
ifeq ($(shell command -v dep 2> /dev/null),)
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
endif
.PHONY: deps
deps:
dep ensure
.PHONY: bin/$(NAME)
bin/$(NAME): $(SRCS)
go build -a -tags netgo -installsuffix netgo $(LDFLAGS) -o bin/$(NAME)
.PHONY: dist
dist:
@cd dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) cp ../completions/zsh/_$(NAME) {} \; && \
$(DIST_DIRS) tar zcf $(NAME)-$(VERSION)-{}.tar.gz {} \;
.PHONY: dist
docker-build:
docker build . -t spm