-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
79 lines (60 loc) · 1.94 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
all: build
.PHONY: build
ifeq ($(GOPATH),)
PATH := $(HOME)/go/bin:$(PATH)
else
PATH := $(GOPATH)/bin:$(PATH)
endif
export GO111MODULE=on
PATH := $(GOPATH)/bin:$(PATH)
VERSION = $(shell git describe --tags --always --dirty)
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
REVISION = $(shell git rev-parse HEAD)
REVSHORT = $(shell git rev-parse --short HEAD)
USER = $(shell whoami)
GOVERSION = $(shell go version | awk '{print $$3}')
NOW = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
SHELL = /bin/bash
ifneq ($(OS), Windows_NT)
CURRENT_PLATFORM = linux
ifeq ($(shell uname), Darwin)
SHELL := /bin/bash
CURRENT_PLATFORM = darwin
endif
else
CURRENT_PLATFORM = windows
endif
BUILD_VERSION = "\
-X github.com/micromdm/go4/version.appName=${APP_NAME} \
-X github.com/micromdm/go4/version.version=${VERSION} \
-X github.com/micromdm/go4/version.branch=${BRANCH} \
-X github.com/micromdm/go4/version.buildUser=${USER} \
-X github.com/micromdm/go4/version.buildDate=${NOW} \
-X github.com/micromdm/go4/version.revision=${REVISION} \
-X github.com/micromdm/go4/version.goVersion=${GOVERSION}"
gomodcheck:
@go help mod > /dev/null || (@echo micromdm requires Go version 1.11 or higher && exit 1)
deps: gomodcheck
@go mod download
test:
go test -cover -race ./...
build: squirrel
clean:
rm -rf build/
rm -f *.zip
.pre-build:
mkdir -p build/darwin
mkdir -p build/linux
install-local: \
install-squirrel
.pre-squirrel:
$(eval APP_NAME = squirrel)
squirrel: .pre-build .pre-squirrel
go build -i -o build/$(CURRENT_PLATFORM)/squirrel -ldflags ${BUILD_VERSION} ./cmd/squirrel
install-squirrel: .pre-squirrel
go install -ldflags ${BUILD_VERSION} ./cmd/squirrel
xp-squirrel: .pre-build .pre-squirrel
GOOS=darwin go build -i -o build/darwin/squirrel -ldflags ${BUILD_VERSION} ./cmd/squirrel
GOOS=linux CGO_ENABLED=0 go build -i -o build/linux/squirrel -ldflags ${BUILD_VERSION} ./cmd/squirrel
release-zip: xp-squirrel
zip -r squirrel_${VERSION}.zip build/