ALR/Makefile

67 lines
1.9 KiB
Makefile
Raw Normal View History

2024-07-10 11:34:35 +00:00
NAME := alr
2024-01-22 10:36:06 +00:00
GIT_VERSION = $(shell git describe --tags )
2024-07-10 11:34:35 +00:00
DESTDIR ?=
PREFIX ?= /usr/local
BIN := ./$(NAME)
2024-07-10 11:46:11 +00:00
INSTALED_BIN := $(DESTDIR)/$(PREFIX)/bin/$(NAME)
2024-07-10 11:34:35 +00:00
COMPLETIONS_DIR := ./scripts/completion
BASH_COMPLETION := $(COMPLETIONS_DIR)/bash
ZSH_COMPLETION := $(COMPLETIONS_DIR)/zsh
INSTALLED_BASH_COMPLETION := $(DESTDIR)$(PREFIX)/share/bash-completion/completions/$(NAME)
INSTALLED_ZSH_COMPLETION := $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_$(NAME)
2025-01-14 12:28:54 +00:00
ADD_LICENSE_BIN := go run github.com/google/addlicense@4caba19b7ed7818bb86bc4cd20411a246aa4a524
2025-01-14 12:45:29 +00:00
GOLANGCI_LINT_BIN := go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
2025-01-22 11:40:11 +00:00
XGOTEXT_BIN := go run github.com/Tom5521/xgotext@v1.2.0
2025-01-14 12:28:54 +00:00
2024-07-10 11:46:11 +00:00
.PHONY: build install clean clear uninstall check-no-root
build: check-no-root $(BIN)
2024-07-10 11:34:35 +00:00
export CGO_ENABLED := 0
2024-07-10 11:46:11 +00:00
$(BIN):
go build -ldflags="-X 'gitea.plemya-x.ru/xpamych/ALR/internal/config.Version=$(GIT_VERSION)'" -o $@
2024-07-10 11:34:35 +00:00
check-no-root:
@if [[ "$$(whoami)" == 'root' ]]; then \
echo "This target shouldn't run as root" 1>&2; \
exit 1; \
fi
2024-07-10 11:46:11 +00:00
install: \
$(INSTALED_BIN) \
$(INSTALLED_BASH_COMPLETION) \
$(INSTALLED_ZSH_COMPLETION)
2024-07-10 11:34:35 +00:00
@echo "Installation done!"
2024-01-22 10:36:06 +00:00
2024-07-10 11:34:35 +00:00
$(INSTALED_BIN): $(BIN)
install -Dm755 $< $@
2024-01-22 10:36:06 +00:00
2024-07-10 11:34:35 +00:00
$(INSTALLED_BASH_COMPLETION): $(BASH_COMPLETION)
install -Dm755 $< $@
2024-01-22 10:36:06 +00:00
2024-07-10 11:34:35 +00:00
$(INSTALLED_ZSH_COMPLETION): $(ZSH_COMPLETION)
install -Dm755 $< $@
2024-01-22 10:36:06 +00:00
uninstall:
2024-07-10 11:34:35 +00:00
rm -f \
$(INSTALED_BIN) \
$(INSTALLED_BASH_COMPLETION) \
$(INSTALLED_ZSH_COMPLETION)
2024-01-22 10:36:06 +00:00
2024-07-10 11:34:35 +00:00
clean clear:
rm -f $(BIN)
2025-01-14 12:24:24 +00:00
2025-01-14 12:28:54 +00:00
OLD_FILES=$$(< old-files)
2025-01-14 12:24:24 +00:00
IGNORE_OLD_FILES := $(foreach file,$(shell cat old-files),-ignore $(file))
update-license:
2025-01-14 12:28:54 +00:00
$(ADD_LICENSE_BIN) -v -f license-header-old-files.tmpl $(OLD_FILES)
$(ADD_LICENSE_BIN) -v -f license-header.tmpl $(IGNORE_OLD_FILES) .
2025-01-14 12:45:29 +00:00
fmt:
$(GOLANGCI_LINT_BIN) run --fix
2025-01-22 11:40:11 +00:00
i18n:
$(XGOTEXT_BIN) --output ./internal/translations/default.pot
msgmerge --backup=off -U ./internal/translations/po/ru/default.po ./internal/translations/default.pot