forked from vmware-archive/photon-controller-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (39 loc) · 1.15 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
# Makefile to help building go components
GO=godep go
COMMAND_NAME=photon
LDFLAGS="-X main.githash=`git rev-parse --short HEAD` -X main.commandName=$(COMMAND_NAME)"
GOBUILD=$(GO) build -ldflags $(LDFLAGS)
all: test build binaries
binaries: darwin/amd64 windows/amd64 linux/amd64
darwin/amd64:
$(eval export GOOS=darwin)
$(eval export GOARCH=amd64)
$(eval export fileext=)
make build
windows/amd64:
$(eval export GOOS=windows)
$(eval export GOARCH=amd64)
$(eval export fileext=.exe)
make build
linux/amd64:
$(eval export GOOS=linux)
$(eval export GOARCH=amd64)
$(eval export fileext=)
make build
# go build arch is controlled by env var GOOS and GOARCH, when not set it use current machine native arch
build:
$(GOBUILD) -o bin/$(GOOS)$(GOARCH)/$(COMMAND_NAME)$(fileext) ./photon
#
# get the tools
#
tools:
go get -u github.com/kisielk/errcheck
go get -u golang.org/x/tools/cmd/goimports
go get -u github.com/golang/lint/golint
go get -u github.com/tools/godep
test: tools
errcheck ./...
$(GO) vet ./...
golint
! gofmt -l photon 2>&1 | read || (gofmt -d photon; echo "ERROR: Fix gofmt errors. Run 'gofmt -w photon'"; exit 1)
$(GO) test -v ./...