forked from aktau/gofinance
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
74 lines (56 loc) · 2.16 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
71
72
73
74
.PHONY: all gofinance test build fmt vet clean release lint errcheck install update release release-check release-copy release-build release-dirs dep_install dep_update
DIST := dist
EXECUTABLE := gofinance
TAGS ?=
TARGETS ?= linux darwin windows
PACKAGES=$(shell go list ./... | grep -v /vendor/)
SOURCES ?= $(shell find . -name "*.go" -type f)
VERSION ?= $(shell git describe --abbrev=0 --tags --always || git rev-parse --short HEAD)
LDFLAGS += -X 'main.Version=$(VERSION)'
LDFLAGS += -X 'main.Githash=$(shell git rev-parse --short HEAD)'
LDFLAGS += -X 'main.Buildstamp=$(shell date -u '+%Y-%m-%d_%I:%M:%S%p')'
LDFLAGS += -X 'main.AppName=$(EXECUTABLE)'
all:build
fmt:
go fmt $(PACKAGES)
vet:
go vet $(PACKAGES)
dep_install:
glide install
dep_update:
glide up
build:$(EXECUTABLE)
go build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o bin/${EXECUTABLE} "./cmd/cli"
test:
for PKG in $(PACKAGES); do go test -v -cover -coverprofile $$GOPATH/src/$$PKG/coverage.txt $$PKG || exit 1; done;
release: release-dirs release-build release-copy release-check
release-dirs:
mkdir -p $(DIST)/binaries $(DIST)/release
release-build:
@which gox > /dev/null; if [ $$? -ne 0 ]; then \
go get -u github.com/mitchellh/gox; \
fi
gox -os="$(TARGETS)" -arch="amd64 386" -tags="$(TAGS)" -ldflags="$(EXTLDFLAGS)-s -w $(LDFLAGS)" -output="$(DIST)/binaries/$(EXECUTABLE)-$(VERSION)-{{.OS}}-{{.Arch}}" "./cmd/cli"
release-copy:
$(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
release-check:
cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha1sum $(notdir $(file)) > $(notdir $(file)).sha1;)
errcheck:
@which errcheck > /dev/null; if [ $$? -ne 0 ]; then \
go get -u github.com/kisielk/errcheck; \
fi
errcheck -verbose $(PACKAGES)
lint:
@which golint > /dev/null; if [ $$? -ne 0 ]; then \
go get -u github.com/golang/lint/golint; \
fi
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
clean:
go clean -x -i ./...
find . -name coverage.txt -delete
find . -name *.tar.gz -delete
find . -name *.db -delete
-rm -rf bin/* \
.cover
version:
@echo $(VERSION)