0
0
Fork 0
mirror of https://gitea.plemya-x.ru/Plemya-x/ALR.git synced 2025-01-10 17:26:45 +00:00
ALR/Makefile

51 lines
1.2 KiB
Makefile
Raw Permalink 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)
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)