2018-03-23 05:23:16 +01:00
|
|
|
.PHONY: all default install uninstall test build release clean
|
|
|
|
|
|
|
|
PREFIX := /usr
|
|
|
|
DESTDIR :=
|
|
|
|
|
|
|
|
ifndef VERSION
|
2018-06-19 12:31:39 +02:00
|
|
|
MAJORVERSION := 7
|
2018-03-23 05:23:16 +01:00
|
|
|
MINORVERSION ?= $(shell git rev-list --count master)
|
|
|
|
endif
|
|
|
|
VERSION := ${MAJORVERSION}.${MINORVERSION}
|
|
|
|
|
|
|
|
LDFLAGS := -ldflags '-s -w -X main.version=${VERSION}'
|
2016-10-05 18:04:16 +02:00
|
|
|
GOFILES := $(shell ls *.go | grep -v /vendor/)
|
2018-03-23 05:23:16 +01:00
|
|
|
ARCH := $(shell uname -m)
|
|
|
|
PKGNAME := yay
|
|
|
|
BINNAME := yay
|
|
|
|
PACKAGE := ${PKGNAME}_${VERSION}_${ARCH}
|
2016-12-02 19:22:21 +01:00
|
|
|
|
2018-03-23 05:23:16 +01:00
|
|
|
export GOPATH=$(shell pwd)/.go
|
|
|
|
export GOROOT=/usr/lib/go
|
2016-09-05 04:32:57 +02:00
|
|
|
|
|
|
|
default: build
|
|
|
|
|
2018-03-23 05:23:16 +01:00
|
|
|
all: | clean package
|
2018-02-17 19:25:43 +01:00
|
|
|
|
2016-10-05 18:04:16 +02:00
|
|
|
install:
|
2018-03-23 05:23:16 +01: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 19:22:21 +01:00
|
|
|
test:
|
2018-03-23 05:23:16 +01:00
|
|
|
gofmt -l *.go
|
|
|
|
@test -z "$$(gofmt -l *.go)" || (echo "Files need to be linted" && false)
|
|
|
|
go vet
|
|
|
|
go test -v
|
|
|
|
|
2016-09-05 04:32:57 +02:00
|
|
|
build:
|
2018-03-23 05:23:16 +01:00
|
|
|
go build -v ${LDFLAGS} -o ${BINNAME}
|
|
|
|
|
|
|
|
release: | test build
|
2018-02-17 19:25:43 +01:00
|
|
|
mkdir ${PACKAGE}
|
2018-03-23 05:23:16 +01:00
|
|
|
cp ./${BINNAME} ${PACKAGE}/
|
|
|
|
cp ./doc/${PKGNAME}.8 ${PACKAGE}/
|
2018-03-22 17:02:40 +01:00
|
|
|
cp ./completions/zsh ${PACKAGE}/
|
|
|
|
cp ./completions/fish ${PACKAGE}/
|
|
|
|
cp ./completions/bash ${PACKAGE}/
|
2018-03-23 05:23:16 +01:00
|
|
|
|
|
|
|
package: release
|
2017-07-04 19:54:03 +02:00
|
|
|
tar -czvf ${PACKAGE}.tar.gz ${PACKAGE}
|
2016-09-05 04:32:57 +02:00
|
|
|
clean:
|
2018-03-23 05:23:16 +01:00
|
|
|
rm -rf ${PKGNAME}_*
|
|
|
|
rm -f ${BINNAME}
|
2016-09-05 04:32:57 +02:00
|
|
|
|