-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
39 lines (33 loc) · 1.05 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
GOOS := linux
GOARCH := amd64
CGO_ENABLED := 1
TAGS := -tags 'netgo'
BINARY := cloudctl-$(GOOS)-$(GOARCH)
SHA := $(shell git rev-parse --short=8 HEAD)
GITVERSION := $(shell git describe --long --all)
# gnu date format iso-8601 is parsable with Go RFC3339
BUILDDATE := $(shell date --iso-8601=seconds)
VERSION := $(or ${VERSION},$(shell git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD || git rev-parse --short HEAD))
ifeq ($(CGO_ENABLED),1)
ifeq ($(GOOS),linux)
LINKMODE := -linkmode external -extldflags '-static -s -w'
TAGS := -tags 'osusergo netgo static_build'
endif
endif
LINKMODE := $(LINKMODE) \
-X 'github.com/metal-stack/v.Version=$(VERSION)' \
-X 'github.com/metal-stack/v.Revision=$(GITVERSION)' \
-X 'github.com/metal-stack/v.GitSHA1=$(SHA)' \
-X 'github.com/metal-stack/v.BuildDate=$(BUILDDATE)'
.PHONY: build
build:
go build \
$(TAGS) \
-ldflags \
"$(LINKMODE)" \
-o bin/$(BINARY) \
github.com/fi-ts/cloudctl
md5sum bin/$(BINARY) > bin/$(BINARY).md5
.PHONY: test
test: build
go test -cover ./...