]> git.lizzy.rs Git - micro.git/blob - Makefile
Use GOHOSTARCH/GOHOSTOS to get version, date, Resolves #620
[micro.git] / Makefile
1 .PHONY: runtime
2
3 VERSION := $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) \
4         go run tools/build-version.go)
5 HASH := $(shell git rev-parse --short HEAD)
6 DATE := $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) \
7         go run tools/build-date.go)
8 ADDITIONAL_GO_LINKER_FLAGS := $(shell GOOS=$(shell go env GOHOSTOS) \
9         GOARCH=$(shell go env GOHOSTARCH) \
10         go run tools/info-plist.go "$(VERSION)")
11 GOBIN ?= $(shell go env GOPATH)/bin
12
13 # Builds micro after checking dependencies but without updating the runtime
14 build: deps
15         go build -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)' $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
16
17 # Builds micro after building the runtime and checking dependencies
18 build-all: runtime build
19
20 # Builds micro without checking for dependencies
21 build-quick:
22         go build -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)' $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
23
24 # Same as 'build' but installs to $GOBIN afterward
25 install: deps
26         go install -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)' $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
27
28 # Same as 'build-all' but installs to $GOBIN afterward
29 install-all: runtime install
30
31 # Same as 'build-quick' but installs to $GOBIN afterward
32 install-quick:
33         go install -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)' $(ADDITIONAL_GO_LINKER_FLAGS)"  ./cmd/micro
34
35 # Checks for dependencies
36 deps:
37         go get -d ./cmd/micro
38
39 update:
40         git pull
41         go get -u -d ./cmd/micro
42
43 # Builds the runtime
44 runtime:
45         go get -u github.com/jteeuwen/go-bindata/...
46         $(GOBIN)/go-bindata -nometadata -o runtime.go runtime/...
47         mv runtime.go cmd/micro
48
49 test:
50         go get -d ./cmd/micro
51         go test ./cmd/micro
52
53 clean:
54         rm -f micro