forked from felixb/swamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
39 lines (28 loc) · 862 Bytes
/
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
.PHONY: all build clean test
BIN_DIR := build
BIN_NAME := swamp
CGO0_BINS := $(BIN_DIR)/$(BIN_NAME)-alpine-amd64 $(BIN_DIR)/$(BIN_NAME)-darwin-amd64 $(BIN_DIR)/$(BIN_NAME)-windows-amd64.exe
CGO1_BINS := $(BIN_DIR)/$(BIN_NAME)-linux-amd64
LOCAL_BIN := $(BIN_DIR)/$(BIN_NAME)
BINS := $(CGO0_BINS) $(CGO1_BINS) $(LOCAL_BIN)
TARGET ?= $(HOME)/bin
VERSION=$(shell git describe --tags)
temp=$(subst -, ,$@)
os=$(subst alpine,linux,$(word 2, $(temp)))
arch=$(subst .exe,,$(word 3, $(temp)))
all: test build
build: $(BINS)
install: $(LOCAL_BIN)
cp $(LOCAL_BIN) $(TARGET)/
clean:
rm -rf $(BIN_DIR)
test:
go test -v -cover ./...
$(CGO0_BINS): *.go
GOOS=$(os) GOARCH=$(arch) CGO_ENABLED=0 go build -o '$@' *.go
$(CGO1_BINS): *.go
GOOS=$(os) GOARCH=$(arch) CGO_ENABLED=1 go build -o '$@' *.go
$(LOCAL_BIN): *.go
go build -o '$@' *.go
fmt: *.go
go fmt *.go