2018-09-23 22:52:06 +02:00
|
|
|
.PHONY: all default install uninstall test build release clean package
|
2018-03-23 05:23:16 +01:00
|
|
|
|
2018-09-15 18:32:44 +02:00
|
|
|
PREFIX := /usr/local
|
2018-03-23 05:23:16 +01:00
|
|
|
DESTDIR :=
|
|
|
|
|
2018-12-03 15:51:17 +01:00
|
|
|
MAJORVERSION := 9
|
2019-09-20 19:37:42 +02:00
|
|
|
MINORVERSION ?= 3
|
2019-06-04 00:39:21 +02:00
|
|
|
PATCHVERSION := 1
|
2018-10-08 19:46:51 +02:00
|
|
|
VERSION ?= ${MAJORVERSION}.${MINORVERSION}.${PATCHVERSION}
|
2018-03-23 05:23:16 +01:00
|
|
|
|
2019-06-04 00:39:21 +02:00
|
|
|
LDFLAGS := -gcflags=all=-trimpath=${PWD} -asmflags=all=-trimpath=${PWD} -ldflags=-extldflags=-zrelro -ldflags=-extldflags=-znow -ldflags '-s -w -X main.version=${VERSION}'
|
2018-12-07 14:37:44 +01:00
|
|
|
MOD := -mod=vendor
|
|
|
|
export GO111MODULE=on
|
2018-03-23 05:23:16 +01:00
|
|
|
ARCH := $(shell uname -m)
|
2018-12-07 14:37:44 +01:00
|
|
|
GOCC := $(shell go version)
|
2018-03-23 05:23:16 +01:00
|
|
|
PKGNAME := yay
|
|
|
|
BINNAME := yay
|
|
|
|
PACKAGE := ${PKGNAME}_${VERSION}_${ARCH}
|
2016-12-02 19:22:21 +01:00
|
|
|
|
2018-12-07 14:37:44 +01:00
|
|
|
ifneq (,$(findstring gccgo,$(GOCC)))
|
2018-12-07 14:50:57 +01:00
|
|
|
export GOPATH=$(shell pwd)/.go
|
2018-12-07 14:37:44 +01:00
|
|
|
LDFLAGS := -gccgoflags '-s -w'
|
|
|
|
MOD :=
|
|
|
|
endif
|
|
|
|
|
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-12-07 14:37:44 +01:00
|
|
|
go build -v ${LDFLAGS} -o ${BINNAME} ${MOD}
|
2018-03-23 05:23:16 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-04-03 22:08:58 +02:00
|
|
|
docker-release-aarch64:
|
|
|
|
docker build -f build/aarch64.Dockerfile -t yay-aarch64:${VERSION} .
|
2019-04-04 00:06:22 +02:00
|
|
|
docker run --name yay-aarch64 yay-aarch64:${VERSION}
|
2019-04-03 22:08:58 +02:00
|
|
|
docker cp yay-aarch64:${PKGNAME}_${VERSION}_aarch64.tar.gz ${PKGNAME}_${VERSION}_aarch64.tar.gz
|
|
|
|
docker container rm yay-aarch64
|
|
|
|
|
2019-04-09 20:39:38 +02:00
|
|
|
docker-release-armv7h:
|
|
|
|
docker build -f build/armv7h.Dockerfile -t yay-armv7h:${VERSION} .
|
|
|
|
docker create --name yay-armv7h yay-armv7h:${VERSION}
|
|
|
|
docker cp yay-armv7h:${PKGNAME}_${VERSION}_armv7l.tar.gz ${PKGNAME}_${VERSION}_armv7h.tar.gz
|
|
|
|
docker container rm yay-armv7h
|
|
|
|
|
2019-04-03 22:08:58 +02:00
|
|
|
docker-release-x86_64:
|
|
|
|
docker build -f build/x86_64.Dockerfile -t yay-x86_64:${VERSION} .
|
|
|
|
docker create --name yay-x86_64 yay-x86_64:${VERSION}
|
|
|
|
docker cp yay-x86_64:${PKGNAME}_${VERSION}_x86_64.tar.gz ${PKGNAME}_${VERSION}_x86_64.tar.gz
|
|
|
|
docker container rm yay-x86_64
|
|
|
|
|
2019-04-09 20:39:38 +02:00
|
|
|
docker-release: | docker-release-x86_64 docker-release-aarch64 docker-release-armv7h
|
2019-04-04 00:06:22 +02:00
|
|
|
|
2019-04-04 13:14:34 +02:00
|
|
|
docker-build:
|
|
|
|
docker build -f build/${ARCH}.Dockerfile --build-arg MAKE_ARG=build -t yay-build-${ARCH}:${VERSION} .
|
|
|
|
docker create --name yay-build-${ARCH} yay-build-${ARCH}:${VERSION}
|
|
|
|
docker cp yay-build-${ARCH}:${BINNAME} ${BINNAME}
|
|
|
|
docker container rm yay-build-${ARCH}
|
|
|
|
|
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
|
|
|
|