forked from nanobox-io/nanobox
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (51 loc) · 2.62 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
75
TAG=$(shell git describe --always --tags --abbrev=0 | tr -d "[v\r\n]")
TAGDIR=$(shell echo $(TAG) | sed -E 's/([0-9]+)\..+/v\1/')
COMMIT=$(shell git rev-parse --short HEAD | tr -d "[ \r\n\']")
BUILD_DATE=$(shell date -u +%Y%m%dT%H%M%S)
GITSTATUS=$(shell git status 2> /dev/null | tail -n1)
DIRTY=$(shell [ "$(GITSTATUS)" = 'nothing to commit, working tree clean' ] || echo -n "+")
GO_LDFLAGS="-s -X github.com/mu-box/microbox/util/odin.apiKey=$(API_KEY) -X github.com/mu-box/microbox/models.microVersion=$(TAG) -X github.com/mu-box/microbox/models.microCommit=$(COMMIT)$(DIRTY) -X github.com/mu-box/microbox/models.microBuild=$(BUILD_DATE)"
default: all
local: linux windows darwin
clean:
@echo "Cleaning old builds"
@rm -rf "./.build"
all: build
# go get github.com/mitchellh/gox
build: clean
@echo "Building microbox"
@gox -ldflags=$(GO_LDFLAGS) -osarch "darwin/amd64 darwin/arm64 linux/amd64 linux/arm linux/arm64 linux/s390x windows/amd64" -output="./.build/$(TAGDIR)/{{.OS}}/{{.Arch}}/microbox"
@echo -n "Microbox Version $(TAG)-$(BUILD_DATE) ($(COMMIT)$(DIRTY))" > ./.build/$(TAGDIR)/version
@echo "Building microbox-update"
@cd ./updater && gox -osarch "darwin/amd64 darwin/arm64 linux/amd64 linux/arm linux/arm64 linux/s390x windows/amd64" -ldflags="-s" -output="../.build/$(TAGDIR)/{{.OS}}/{{.Arch}}/microbox-update"
native:
@echo "Building microbox (native os/arch)"
@go build -ldflags=$(GO_LDFLAGS) -o microbox
linux: linux-amd64 linux-arm32 linux-arm64 linux-s390x
linux-amd64:
@echo "Building microbox-linux-amd64"
@GOOS=linux GOARCH=amd64 go build -ldflags=$(GO_LDFLAGS) -o microbox-linux-amd64
linux-arm32:
@echo "Building microbox-linux-arm32"
@GOOS=linux GOARCH=arm go build -ldflags=$(GO_LDFLAGS) -o microbox-linux-arm32
linux-arm64:
@echo "Building microbox-linux-arm64"
@GOOS=linux GOARCH=arm64 go build -ldflags=$(GO_LDFLAGS) -o microbox-linux-arm64
linux-s390x:
@echo "Building microbox-linux-s390x"
@GOOS=linux GOARCH=s390x go build -ldflags=$(GO_LDFLAGS) -o microbox-linux-s390x
windows: windows-amd64
windows-amd64:
@echo "Building microbox-windows-amd64"
@GOOS=windows GOARCH=amd64 go build -ldflags=$(GO_LDFLAGS) -o microbox-windows-amd64
darwin: darwin-amd64 darwin-arm64
darwin-amd64:
@echo "Building microbox-darwin-amd64"
@GOOS=darwin GOARCH=amd64 go build -ldflags=$(GO_LDFLAGS) -o microbox-darwin-amd64
darwin-arm64:
@echo "Building microbox-darwin-arm64"
@GOOS=darwin GOARCH=arm64 go build -ldflags=$(GO_LDFLAGS) -o microbox-darwin-arm64
# go get github.com/kardianos/govendor
test:
@go test -v ./...
.PHONY: test clean all build native linux windows windows-amd64 darwin darwin-amd64 darwin-arm64