-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (45 loc) · 1.48 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
APPNAME := CaOps
VERSION := $(shell git describe --all --always --dirty --long)
LDFLAGS := "-X main.appName=$(APPNAME) -X main.version=$(VERSION)"
PLATFORMS := darwin-amd64 linux-amd64 linux-arm windows-amd64
INSTALL_PKG := ./cmd/CaOps
BIN_DIR := ./bin
DIST_DIR := ./dist
APP_BIN := $(BIN_DIR)/$(APPNAME)
GO_FILES = $(shell find ./ -type f -name '*.go')
DEV_CASS_VER := c22
.PHONY: default
default: build
.PHONY: ignored
ignored:
git ls-files --others -i --exclude-standard
.PHONY: help
help:
@echo "make [target]"
@echo " Targets: "
@echo " build Build for current OS+Arch into $(BIN_DIR) "
@echo " dist Build for many platforms into $(DIST_DIR) "
@echo " clean Cleanup binaries "
@echo " deps Install deps for the project "
.PHONY: clean
clean:
go clean
rm -fv $(APP_BIN)
rm -fv $(DIST_DIR)/*
.PHONY: deps
deps:
go get -v .
build: $(APP_BIN)
$(APP_BIN): $(GO_FILES)
mkdir -p $(BIN_DIR)
go build -race -ldflags=$(LDFLAGS) -o $@ $(INSTALL_PKG)
dist: $(PLATFORMS)
$(PLATFORMS):
$(eval GOOS := $(firstword $(subst -, ,$@)))
$(eval GOARCH := $(lastword $(subst -, ,$@)))
mkdir -p $(DIST_DIR)
env GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags=$(LDFLAGS) -o $(DIST_DIR)/$(APPNAME).$@ $(INSTALL_PKG)
dev_vms: build
for i in `seq 1 2`; do vagrant up $(DEV_CASS_VER)x0$$i; done
provision: build
for i in `seq 1 2`; do vagrant up --provision $(DEV_CASS_VER)x0$$i; done