-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
41 lines (29 loc) · 916 Bytes
/
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
GIT_DATE := $(shell git log -1 --pretty='%aI')
GIT_HASH := $(shell git rev-parse HEAD)
GIT_BRANCH := $(shell git symbolic-ref --short HEAD)
# creates static binaries
LD_FLAGS := -ldflags "-w -s \
-X 'dnscoffee/version.GitDate=$(GIT_DATE)' \
-X 'dnscoffee/version.GitHash=$(GIT_HASH)' \
-X 'dnscoffee/version.GitBranch=$(GIT_BRANCH)'"
CC := CGO_ENABLED=0 go build -trimpath -a -installsuffix cgo $(LD_FLAGS)
MODULE_SOURCES := $(shell find */ -type f -name '*.go' )
SOURCES := $(shell find . -maxdepth 1 -type f -name '*.go')
BIN := dnscoffee
.PHONY: all fmt docker clean check
all: $(BIN)
docker: Dockerfile
docker build --network host -t="lanrat/dnscoffee" .
$(BIN): $(SOURCES) $(MODULE_SOURCES) go.mod go.sum
$(CC) -o $@ $(SOURCES)
clean:
rm $(BIN)
fmt:
gofmt -s -w -l .
check: | lint check1 check2
check1:
golangci-lint run
check2:
staticcheck -f stylish -checks all ./...
lint:
golint ./...