2018-09-23 20:52:06 +00:00
|
|
|
.PHONY: all default install uninstall test build release clean package
|
2018-03-23 04:23:16 +00:00
|
|
|
|
2018-09-15 16:32:44 +00:00
|
|
|
PREFIX := /usr/local
|
2018-03-23 04:23:16 +00:00
|
|
|
DESTDIR :=
|
|
|
|
|
2018-12-03 14:51:17 +00:00
|
|
|
MAJORVERSION := 9
|
2019-01-20 15:52:21 +00:00
|
|
|
MINORVERSION ?= 1
|
|
|
|
PATCHVERSION := 0
|
2018-10-08 17:46:51 +00:00
|
|
|
VERSION ?= ${MAJORVERSION}.${MINORVERSION}.${PATCHVERSION}
|
2018-03-23 04:23:16 +00:00
|
|
|
|
|
|
|
LDFLAGS := -ldflags '-s -w -X main.version=${VERSION}'
|
2018-12-07 13:37:44 +00:00
|
|
|
MOD := -mod=vendor
|
|
|
|
export GO111MODULE=on
|
2018-03-23 04:23:16 +00:00
|
|
|
ARCH := $(shell uname -m)
|
2018-12-07 13:37:44 +00:00
|
|
|
GOCC := $(shell go version)
|
2018-03-23 04:23:16 +00:00
|
|
|
PKGNAME := yay
|
|
|
|
BINNAME := yay
|
|
|
|
PACKAGE := ${PKGNAME}_${VERSION}_${ARCH}
|
2016-12-02 18:22:21 +00:00
|
|
|
|
2018-12-07 13:37:44 +00:00
|
|
|
ifneq (,$(findstring gccgo,$(GOCC)))
|
2018-12-07 13:50:57 +00:00
|
|
|
export GOPATH=$(shell pwd)/.go
|
2018-12-07 13:37:44 +00:00
|
|
|
LDFLAGS := -gccgoflags '-s -w'
|
|
|
|
MOD :=
|
|
|
|
endif
|
|
|
|
|
2016-09-05 02:32:57 +00:00
|
|
|
default: build
|
|
|
|
|
2018-03-23 04:23:16 +00:00
|
|
|
all: | clean package
|
2018-02-17 18:25:43 +00:00
|
|
|
|
2016-10-05 16:04:16 +00:00
|
|
|
install:
|
2018-03-23 04:23:16 +00:00
|
|
|
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
|
|
|
|
|
2016-12-02 18:22:21 +00:00
|
|
|
test:
|
2018-03-23 04:23:16 +00:00
|
|
|
gofmt -l *.go
|
|
|
|
@test -z "$$(gofmt -l *.go)" || (echo "Files need to be linted" && false)
|
|
|
|
go vet
|
|
|
|
go test -v
|
|
|
|
|
2016-09-05 02:32:57 +00:00
|
|
|
build:
|
2018-12-07 13:37:44 +00:00
|
|
|
go build -v ${LDFLAGS} -o ${BINNAME} ${MOD}
|
2018-03-23 04:23:16 +00:00
|
|
|
|
|
|
|
release: | test build
|
2018-02-17 18:25:43 +00:00
|
|
|
mkdir ${PACKAGE}
|
2018-03-23 04:23:16 +00:00
|
|
|
cp ./${BINNAME} ${PACKAGE}/
|
|
|
|
cp ./doc/${PKGNAME}.8 ${PACKAGE}/
|
2018-03-22 16:02:40 +00:00
|
|
|
cp ./completions/zsh ${PACKAGE}/
|
|
|
|
cp ./completions/fish ${PACKAGE}/
|
|
|
|
cp ./completions/bash ${PACKAGE}/
|
2018-03-23 04:23:16 +00:00
|
|
|
|
|
|
|
package: release
|
2017-07-04 17:54:03 +00:00
|
|
|
tar -czvf ${PACKAGE}.tar.gz ${PACKAGE}
|
2016-09-05 02:32:57 +00:00
|
|
|
clean:
|
2018-03-23 04:23:16 +00:00
|
|
|
rm -rf ${PKGNAME}_*
|
|
|
|
rm -f ${BINNAME}
|
2016-09-05 02:32:57 +00:00
|
|
|
|