-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
45 lines (33 loc) · 1.27 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
NAME ?= kt
VERSION ?= $(shell git describe --tags || echo "unknown")
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT := $(shell git rev-parse HEAD)
GO_LDFLAGS='-X "github.com/knight42/kt/pkg/version.Version=$(VERSION)" \
-X "github.com/knight42/kt/pkg/version.BuildDate=$(BUILD_DATE)" \
-X "github.com/knight42/kt/pkg/version.GitCommit=$(GIT_COMMIT)" \
-w -s'
GOBUILD=CGO_ENABLED=0 go build -trimpath -ldflags $(GO_LDFLAGS)
PLATFORM_LIST = \
darwin-amd64 \
linux-amd64
WINDOWS_ARCH_LIST = \
windows-amd64
all: linux-amd64 darwin-amd64 windows-amd64 # Most used
darwin-amd64:
GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(NAME)-$(VERSION)-$@/$(NAME)
linux-amd64:
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(NAME)-$(VERSION)-$@/$(NAME)
windows-amd64:
GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(NAME)-$(VERSION)-$@/$(NAME).exe
all-arch: $(PLATFORM_LIST) $(WINDOWS_ARCH_LIST)
install:
CGO_ENABLED=0 go install -trimpath -ldflags $(GO_LDFLAGS)
gz_releases=$(addsuffix .tar.gz, $(PLATFORM_LIST))
zip_releases=$(addsuffix .zip, $(WINDOWS_ARCH_LIST))
$(gz_releases): %.tar.gz : %
tar czf $(NAME)-$(VERSION)-$@ $(NAME)-$(VERSION)-$</
$(zip_releases): %.zip : %
zip -r $(NAME)-$(VERSION)-$@ $(NAME)-$(VERSION)-$</
releases: $(gz_releases) $(zip_releases)
clean:
rm -r $(NAME)-*