forked from equinix/metal-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (31 loc) · 1.1 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
EXECUTABLES = git go find pwd
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH)))
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BINARY=packet
VERSION=0.0.4
BUILD=`git rev-parse --short HEAD`
PLATFORMS=darwin linux windows
ARCHITECTURES=amd64 arm64
# Setup linker flags option for build that interoperate with variable names in src code
LDFLAGS=-ldflags "-X github.com/packethost/packet-cli/cmd.Version=${VERSION} -X github.com/packethost/packet-cli/cmd.Build=${BUILD}"
default: generate-docs
go fmt ./...
build:
go build ${LDFLAGS} -o bin/${BINARY}
build-all:
$(foreach GOOS, $(PLATFORMS),\
$(foreach GOARCH, $(ARCHITECTURES), $(shell export GOOS=$(GOOS); export GOARCH=$(GOARCH); go build -v -o bin/$(BINARY)-$(GOOS)-$(GOARCH))))
clean:
rm -rf bin/
find ${ROOT_DIR} -name '${BINARY}[-?][a-zA-Z0-9]*[-?][a-zA-Z0-9]*' -delete
clean-docs:
rm -rf docs/
install:
go install ${LDFLAGS}
mv ${GOPATH}/bin/packet-cli ${GOPATH}/bin/packet
generate-docs: clean-docs
mkdir -p docs
GENDOCS=true go run main.go
test:
go test ./tests