-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
45 lines (35 loc) · 1.1 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
PROJECT := michael
SOURCES := $(shell find . -name '*.go')
VERSION := 1.1.6
GIT_REVISION := $$(git rev-parse HEAD | cut -c -6)
GOVERSION := $(shell go version)
BUILDDATE := $(shell date -u +"%B %d, %Y")
BUILDER := $(shell echo "`git config user.name` <`git config user.email`>")
LDFLAGS := -X 'main.version=$(VERSION)' \
-X 'main.buildDate=$(BUILDDATE)' \
-X 'main.builder=$(BUILDER)' \
-X 'main.buildRev=$(GIT_REVISION)' \
-X 'main.buildGoVersion=$(GOVERSION)'
OS ?= $(shell go env GOOS)
ARCH ?= $(shell go env GOARCH)
PACKAGES := $$(go list ./... | grep -v /vendor/ | grep -v /cmd/)
test:
go test $(PACKAGES)
build: $(PROJECT)
$(PROJECT): $(SOURCES)
GOGC=off GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags "$(LDFLAGS)" -o $(PROJECT)
compress:
ifeq (, $(shell command -v upx 2>/dev/null))
@echo "upx not found in PATH, proceeding with unpacked binary"
else
upx -q $(PROJECT)
endif
all: test build
.DEFAULT_GOAL := all
container: OS = linux
container: ARCH = amd64
container: all
docker build .
clean:
go clean
.PHONY: test build michael compress all container clean