forked from jthomas/copyenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (45 loc) · 1.26 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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOENV=$(GOCMD) env
SED=sed
BUILD_FOLDER=bin
BINARY_NAME=copyenv
SHASUM=shasum
CF=cf
CURARCH=$(shell $(GOENV) | $(SED) -n 's@GOHOSTARCH="\([^"]*\).*@\1@p')
CUROS=$(shell $(GOENV) | $(SED) -n 's@GOHOSTOS="\([^"]*\).*@\1@p')
ARCHWIDTH=$(shell echo $(CURARCH) | $(SED) s'@.*\(..\)@\1@')
# Parameters for the cross platform release binaries
PLATFORMS := linux/amd64/linux64 linux/386/linux32 windows/amd64/win64 windows/386/win32 darwin/amd64/osx
BINARIES = $(wildcard bin/copyenv.*)
TEMP = $(subst /, ,$@)
OS = $(word 1, $(TEMP))
ARCH = $(word 2, $(TEMP))
EXT = $(word 3, $(TEMP))
# DEFAULT
all: deps test release
release: $(PLATFORMS)
$(PLATFORMS):
GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/$(BINARY_NAME).'$(EXT)'
$(SHASUM) -a 1 bin/$(BINARY_NAME).'$(EXT)'
test: deps
$(GOTEST) -v ./...
clean:
$(GOCLEAN)
install-plugin: release
ifeq ($(CUROS),darwin)
$(CF) install-plugin -f bin/$(BINARY_NAME).osx
endif
ifeq ($(CUROS),linux)
$(CF) install-plugin -f bin/$(BINARY_NAME).linux$(ARCHWIDTH)
endif
ifeq ($(CUROS),windows)
$(CF) install-plugin -f bin/$(BINARY_NAME).win$(ARCHWIDTH)
endif
deps:
$(GOGET) -t ./...
.PHONY: deps clean test install-plugin $(PLATFORMS)