-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (32 loc) · 1.05 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
export CGO_ENABLED ?= 0
GOFLAGS += -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:
@mkdir -p "$(builddir)"
go build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o "$(builddir)/" ./...
check:
golangci-lint run ./...
clean:
rm -rf "$(builddir)" "$(distdir)" "$(tmpdir)"
dist:
$(MAKE) bindir="$(distdir)/$(notdir $(CURDIR))" install
tar -C $(distdir) -cvf "$(distdir)/$(notdir $(CURDIR)).tar.gz" "$(notdir $(CURDIR))"
install: all
$(INSTALL_PROGRAM) -Dt "$(DESTDIR)$(bindir)" "$(builddir)"/*
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
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"
uninstall:
rm -fv "$(bindir)/$(notdir $(CURDIR))"
.PHONY: all build check clean dist install install-strip test uninstall