-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·46 lines (34 loc) · 1.16 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
export CGO_ENABLED ?= 0
GOFLAGS += -buildvcs -trimpath
LDFLAGS += -X main.version=$(VERSION)
INSTALL ?= install
INSTALL_PROGRAM ?= $(INSTALL)
prefix = /usr/local
bindir ?= $(prefix)/bin
builddir = bin
distdir = dist
tmpdir = tmp
all: test build
build: generate
go build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o "$(builddir)/" ./...
check:
golangci-lint run ./...
clean:
find . -type f -name '*_gen.go' -delete
rm -rf "$(builddir)" "$(distdir)" "$(tmpdir)"
dist:
$(MAKE) bindir="$(distdir)/$(notdir $(CURDIR))" install
tar -C $(distdir) -cvf "$(distdir)/$(notdir $(CURDIR)).tar.gz" "$(notdir $(CURDIR))"
generate:
@mkdir -p "$(builddir)"
GOOS= GOARCH= go generate -x ./...
install: all
$(INSTALL_PROGRAM) -Dt "$(DESTDIR)$(bindir)" "$(builddir)"/*
test:
@mkdir -p "$(tmpdir)/reports"
go test $(GOFLAGS) -ldflags "$(LDFLAGS)" -coverprofile "$(tmpdir)/reports/coverage.out" ./...
go tool cover -html "$(tmpdir)/reports/coverage.out" -o "$(tmpdir)/reports/coverage.html"
go tool cover -func "$(tmpdir)/reports/coverage.out" -o "$(tmpdir)/reports/coverage.txt"
uninstall:
rm -fv "$(bindir)/$(notdir $(CURDIR))"
.PHONY: all build check clean dist install test uninstall