-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (44 loc) · 1.31 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
# The binary to build (just the basename).
BIN := dasher
# This repo's root import path (under GOPATH).
PKG := github.com/eguevara/dasher
# Where to push the docker image.
REGISTRY ?= eguevara
# This version-strategy uses git tags to set the version string
VERSION := $(shell git describe --tags --always --dirty)
# Set an output prefix, which is the local directory if not specified
PREFIX?=$(shell pwd)
BUILDTAGS=
.PHONY: clean all fmt vet lint build test install static
.DEFAULT: default
all: clean build fmt lint test vet install
build:
@echo "+ $@"
@go build -tags "$(BUILDTAGS) cgo" .
static:
@echo "+ $@"
CGO_ENABLED=1 go build -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static" -o $(BIN) .
fmt:
@echo "+ $@"
@gofmt -s -l . | grep -v vendor | tee /dev/stderr
lint:
@echo "+ $@"
@go list ./... | grep -v /vendor/ | xargs -L1 golint
test: fmt lint vet
@echo "+ $@"
@go test -v -tags "$(BUILDTAGS) cgo" $(shell go list ./... | grep -v vendor)
vet:
@echo "+ $@"
@go vet $(shell go list ./... | grep -v vendor)
clean:
@echo "+ $@"
@rm -rf $(BIN)
install:
@echo "+ $@"
@go install .
version:
@echo $(VERSION)
$(BIN):
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s" -a -installsuffix cgo -ldflags "-w" -o $(BIN) .
dbuild: $(BIN)
docker build --rm --force-rm -t eguevara/$(BIN):1.0 .