This repository has been archived by the owner on Mar 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (53 loc) · 1.8 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
.PHONY: all default install uninstall test build release clean package
PREFIX := /usr/local
DESTDIR :=
MAJORVERSION := 0
MINORVERSION ?= 0
PATCHVERSION := 1
VERSION ?= ${MAJORVERSION}.${MINORVERSION}.${PATCHVERSION}
LDFLAGS := -ldflags '-s -w -X main.version=${VERSION}'
MOD := -mod=vendor
export GO111MODULE=on
ARCH := $(shell uname -m)
GOCC := $(shell go version)
PKGNAME := kpi
BINNAME := kpi
PACKAGE := ${PKGNAME}_${VERSION}_${ARCH}
ifneq (,$(findstring gccgo,$(GOCC)))
export GOPATH=$(shell pwd)/.go
LDFLAGS := -gccgoflags '-s -w'
MOD :=
endif
default: build
all: | clean package
install:
install -Dm755 ${BINNAME} $(DESTDIR)$(PREFIX)/bin/${BINNAME}
install -Dm644 doc/${PKGNAME}.8 $(DESTDIR)$(PREFIX)/share/man/man8/${PKGNAME}.8
install -Dm644 completions/bash $(DESTDIR)$(PREFIX)/share/bash-completion/completions/${PKGNAME}
install -Dm644 completions/zsh $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_${PKGNAME}
install -Dm644 completions/fish $(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d/${PKGNAME}.fish
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/${BINNAME}
rm -f $(DESTDIR)$(PREFIX)/share/man/man8/${PKGNAME}.8
rm -f $(DESTDIR)$(PREFIX)/share/bash-completion/completions/${PKGNAME}
rm -f $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_${PKGNAME}
rm -f $(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d/${PKGNAME}.fish
test:
gofmt -l *.go
@test -z "$$(gofmt -l *.go)" || (echo "Files need to be linted" && false)
go vet
go test -v
build:
go build -v ${LDFLAGS} -o ${BINNAME} ${MOD}
release: | test build
mkdir ${PACKAGE}
cp ./${BINNAME} ${PACKAGE}/
cp ./doc/${PKGNAME}.8 ${PACKAGE}/
cp ./completions/zsh ${PACKAGE}/
cp ./completions/fish ${PACKAGE}/
cp ./completions/bash ${PACKAGE}/
package: release
tar -czvf ${PACKAGE}.tar.gz ${PACKAGE}
clean:
rm -rf ${PKGNAME}_*
rm -f ${BINNAME}