-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (42 loc) · 1.13 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
.PHONY: all default install uninstall test build release clean package version
PREFIX := /usr/local
DESTDIR :=
VERSION = $(shell if test -f VERSION; then cat VERSION; else git describe | sed 's/-/./g;s/^v//;'; fi)
LDFLAGS := -ldflags '-s -w -X main.version=${VERSION}'
MOD := -mod=vendor
ARCH := $(shell uname -m)
OS := $(shell uname -o)
GOCC := $(shell go version)
PKGNAME := pgb
BINNAME := pgb
PACKAGE := ${PKGNAME}-${VERSION}-${OS}
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}
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/${BINNAME}
test:
gofmt -l *.go
@test -z "$$(gofmt -l *.go)" || (echo "Files need to be linted" && false)
go vet ${MOD}
go test -v ${MOD}
build:
go build -v ${LDFLAGS} -o ${BINNAME} ${MOD}
release: | test build
mkdir ${PACKAGE}
cp ./${BINNAME} ${PACKAGE}/
cp ./LICENSE ${PACKAGE}/
cp ./README.md ${PACKAGE}/
package: release
tar -czvf ${PACKAGE}.tar.gz ${PACKAGE}
clean:
rm -rf ${PKGNAME}-*
rm -f ${BINNAME}
version:
@echo $(VERSION)