2019-09-26 10:45:48 +00:00
|
|
|
export GO111MODULE=on
|
2020-06-13 17:29:50 +00:00
|
|
|
GOPROXY ?= https://gocenter.io,direct
|
2020-03-13 09:55:30 +00:00
|
|
|
export GOPROXY
|
2018-03-23 04:23:16 +00:00
|
|
|
|
2020-02-27 23:08:35 +00:00
|
|
|
BUILD_TAG = devel
|
2019-10-04 19:43:42 +00:00
|
|
|
ARCH ?= $(shell uname -m)
|
2019-09-26 10:45:48 +00:00
|
|
|
BIN := yay
|
2018-03-23 04:23:16 +00:00
|
|
|
DESTDIR :=
|
2019-09-26 10:45:48 +00:00
|
|
|
GO ?= go
|
2019-10-04 19:43:42 +00:00
|
|
|
PKGNAME := yay
|
|
|
|
PREFIX := /usr/local
|
2018-03-23 04:23:16 +00:00
|
|
|
|
2020-06-13 17:29:50 +00:00
|
|
|
MAJORVERSION := 10
|
|
|
|
MINORVERSION := 0
|
|
|
|
PATCHVERSION := 0
|
2018-10-08 17:46:51 +00:00
|
|
|
VERSION ?= ${MAJORVERSION}.${MINORVERSION}.${PATCHVERSION}
|
2018-03-23 04:23:16 +00:00
|
|
|
|
2020-05-08 16:13:51 +00:00
|
|
|
LOCALEDIR := po
|
2020-05-29 23:04:03 +00:00
|
|
|
SYSTEMLOCALEPATH := $(PREFIX)/share/locale/
|
2020-05-04 07:24:32 +00:00
|
|
|
|
2020-06-17 13:13:57 +00:00
|
|
|
LANGS := pt pt_BR en es fr_FR pl_PL ru_RU zh_CN
|
2020-05-29 22:43:18 +00:00
|
|
|
POTFILE := default.pot
|
2020-05-04 07:24:32 +00:00
|
|
|
POFILES := $(addprefix $(LOCALEDIR)/,$(addsuffix .po,$(LANGS)))
|
|
|
|
MOFILES := $(POFILES:.po=.mo)
|
|
|
|
|
2020-06-15 07:42:46 +00:00
|
|
|
GOFLAGS ?= -v -trimpath -mod=readonly -modcacherw
|
|
|
|
EXTRA_GOFLAGS ?= -buildmode=pie
|
2020-05-29 22:43:18 +00:00
|
|
|
LDFLAGS := $(LDFLAGS) -X "main.yayVersion=${VERSION}" -X "main.localePath=${SYSTEMLOCALEPATH}"
|
2019-10-04 19:43:42 +00:00
|
|
|
|
2019-09-26 10:45:48 +00:00
|
|
|
RELEASE_DIR := ${PKGNAME}_${VERSION}_${ARCH}
|
|
|
|
PACKAGE := $(RELEASE_DIR).tar.gz
|
2020-05-29 22:43:18 +00:00
|
|
|
SOURCES ?= $(shell find . -name "*.go" -type f)
|
2016-12-02 18:22:21 +00:00
|
|
|
|
2020-05-04 07:24:32 +00:00
|
|
|
.PRECIOUS: ${LOCALEDIR}/%.po
|
|
|
|
|
2019-09-26 10:45:48 +00:00
|
|
|
.PHONY: default
|
2016-09-05 02:32:57 +00:00
|
|
|
default: build
|
|
|
|
|
2019-10-10 15:37:37 +00:00
|
|
|
.PHONY: all
|
|
|
|
all: | clean release
|
|
|
|
|
2019-09-26 10:45:48 +00:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2019-10-05 10:16:58 +00:00
|
|
|
$(GO) clean $(GOFLAGS) -i ./...
|
2020-02-27 23:08:35 +00:00
|
|
|
rm -rf $(BIN) $(PKGNAME)_*
|
2019-09-26 10:45:48 +00:00
|
|
|
|
|
|
|
.PHONY: test
|
2019-10-05 10:16:58 +00:00
|
|
|
test:
|
|
|
|
$(GO) vet $(GOFLAGS) ./...
|
2019-10-04 19:43:42 +00:00
|
|
|
@test -z "$$(gofmt -l *.go)" || (echo "Files need to be linted. Use make fmt" && false)
|
2019-10-05 10:16:58 +00:00
|
|
|
$(GO) test $(GOFLAGS) --race -covermode=atomic . ./pkg/...
|
2019-09-26 10:45:48 +00:00
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build: $(BIN)
|
|
|
|
|
|
|
|
.PHONY: release
|
|
|
|
release: $(PACKAGE)
|
|
|
|
|
|
|
|
.PHONY: docker-release-all
|
|
|
|
docker-release-all:
|
2020-02-27 23:08:35 +00:00
|
|
|
make docker-release-armv7h ARCH=armv7h
|
|
|
|
make docker-release-x86_64 ARCH=x86_64
|
|
|
|
make docker-release-aarch64 ARCH=aarch64
|
2018-02-17 18:25:43 +00:00
|
|
|
|
2020-02-27 23:08:35 +00:00
|
|
|
.PHONY: docker-release-armv7h
|
|
|
|
docker-release-armv7h:
|
|
|
|
docker build --build-arg="BUILD_TAG=arm32v7-devel" -t yay-$(ARCH):${VERSION} .
|
2020-06-13 22:56:42 +00:00
|
|
|
docker run -e="ARCH=$(ARCH)" --name yay-$(ARCH) yay-$(ARCH):${VERSION} make release VERSION=${VERSION} PREFIX=${PREFIX}
|
2020-02-27 23:08:35 +00:00
|
|
|
docker cp yay-$(ARCH):/app/${PACKAGE} $(PACKAGE)
|
|
|
|
docker container rm yay-$(ARCH)
|
|
|
|
|
|
|
|
.PHONY: docker-release-aarch64
|
|
|
|
docker-release-aarch64:
|
|
|
|
docker build --build-arg="BUILD_TAG=arm64v8-devel" -t yay-$(ARCH):${VERSION} .
|
2020-06-13 22:56:42 +00:00
|
|
|
docker run -e="ARCH=$(ARCH)" --name yay-$(ARCH) yay-$(ARCH):${VERSION} make release VERSION=${VERSION} PREFIX=${PREFIX}
|
2020-02-27 23:08:35 +00:00
|
|
|
docker cp yay-$(ARCH):/app/${PACKAGE} $(PACKAGE)
|
|
|
|
docker container rm yay-$(ARCH)
|
|
|
|
|
|
|
|
.PHONY: docker-release-x86_64
|
|
|
|
docker-release-x86_64:
|
|
|
|
docker build --build-arg="BUILD_TAG=devel" -t yay-$(ARCH):${VERSION} .
|
2020-06-13 22:56:42 +00:00
|
|
|
docker run -e="ARCH=$(ARCH)" --name yay-$(ARCH) yay-$(ARCH):${VERSION} make release VERSION=${VERSION} PREFIX=${PREFIX}
|
2019-09-26 10:45:48 +00:00
|
|
|
docker cp yay-$(ARCH):/app/${PACKAGE} $(PACKAGE)
|
|
|
|
docker container rm yay-$(ARCH)
|
|
|
|
|
|
|
|
.PHONY: docker-build
|
|
|
|
docker-build:
|
2020-02-27 23:08:35 +00:00
|
|
|
docker build -t yay-$(ARCH):${VERSION} .
|
2020-06-15 07:42:46 +00:00
|
|
|
docker run -e="ARCH=$(ARCH)" --name yay-$(ARCH) yay-$(ARCH):${VERSION} make build VERSION=${VERSION} PREFIX=${PREFIX}
|
2020-02-27 23:08:35 +00:00
|
|
|
docker cp yay-$(ARCH):/app/${BIN} $(BIN)
|
|
|
|
docker container rm yay-$(ARCH)
|
2019-09-26 10:45:48 +00:00
|
|
|
|
|
|
|
.PHONY: test-vendor
|
|
|
|
test-vendor: vendor
|
|
|
|
@diff=$$(git diff vendor/); \
|
|
|
|
if [ -n "$$diff" ]; then \
|
|
|
|
echo "Please run 'make vendor' and commit the result:"; \
|
|
|
|
echo "$${diff}"; \
|
|
|
|
exit 1; \
|
|
|
|
fi;
|
|
|
|
|
2019-10-13 19:10:46 +00:00
|
|
|
.PHONY: lint
|
2019-10-16 01:44:10 +00:00
|
|
|
lint:
|
2019-10-13 19:10:46 +00:00
|
|
|
golangci-lint run
|
|
|
|
golint -set_exit_status . ./pkg/...
|
|
|
|
|
2019-10-05 10:16:58 +00:00
|
|
|
.PHONY: fmt
|
|
|
|
fmt:
|
2020-05-29 22:43:18 +00:00
|
|
|
go fmt ./...
|
2019-10-05 10:16:58 +00:00
|
|
|
|
2019-09-26 10:45:48 +00:00
|
|
|
.PHONY: install
|
2020-05-04 07:24:32 +00:00
|
|
|
install: build ${MOFILES}
|
2019-09-26 10:45:48 +00:00
|
|
|
install -Dm755 ${BIN} $(DESTDIR)$(PREFIX)/bin/${BIN}
|
2018-03-23 04:23:16 +00:00
|
|
|
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
|
2020-05-29 22:43:18 +00:00
|
|
|
for lang in ${LANGS}; do \
|
|
|
|
install -Dm644 ${LOCALEDIR}/$${lang}.mo $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/${PKGNAME}.mo; \
|
|
|
|
done
|
2018-03-23 04:23:16 +00:00
|
|
|
|
2019-09-26 10:45:48 +00:00
|
|
|
.PHONY: uninstall
|
2018-03-23 04:23:16 +00:00
|
|
|
uninstall:
|
2019-09-26 10:45:48 +00:00
|
|
|
rm -f $(DESTDIR)$(PREFIX)/bin/${BIN}
|
2018-03-23 04:23:16 +00:00
|
|
|
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
|
2020-05-04 07:24:32 +00:00
|
|
|
for lang in ${LANGS}; do \
|
|
|
|
rm -f $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/${PKGNAME}.mo; \
|
|
|
|
done
|
|
|
|
|
2020-05-08 16:13:51 +00:00
|
|
|
$(BIN): $(SOURCES)
|
|
|
|
$(GO) build $(GOFLAGS) -ldflags '-s -w $(LDFLAGS)' $(EXTRA_GOFLAGS) -o $@
|
|
|
|
|
|
|
|
$(RELEASE_DIR):
|
|
|
|
mkdir $(RELEASE_DIR)
|
|
|
|
|
2020-06-13 21:20:22 +00:00
|
|
|
$(PACKAGE): $(BIN) $(RELEASE_DIR) ${MOFILES}
|
2020-05-08 16:13:51 +00:00
|
|
|
cp -t $(RELEASE_DIR) ${BIN} doc/${PKGNAME}.8 completions/* ${MOFILES}
|
|
|
|
tar -czvf $(PACKAGE) $(RELEASE_DIR)
|
|
|
|
|
2020-05-29 22:58:24 +00:00
|
|
|
locale:
|
2020-05-29 22:43:18 +00:00
|
|
|
xgotext -in . -out po
|
2020-05-04 07:24:32 +00:00
|
|
|
test -f $@ || msginit -l $* -i $< -o $@
|
|
|
|
msgmerge -U $@ $<
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
${LOCALEDIR}/%.mo: ${LOCALEDIR}/%.po
|
|
|
|
msgfmt $< -o $@
|