n/Makefile

38 lines
1.1 KiB
Makefile
Raw Normal View History

2022-07-07 23:31:13 +03:00
BIN := "nexclamation"
SYMLINK := "n!"
COMPL := "completion"
TMP := "./.installation_prefix"
all:
@echo Nothing to do. Available targets: install, uninstall, set-prefix
@echo
@echo Deafult PREFIX for root user: /usr/local
@echo Deafult PREFIX for non-root user: ~/.local
@echo Set up custom installation PREFIX by:
@echo make PREFIX=/your/path install
install: set-prefix
$(eval PREFIX := $(shell cat $(TMP)))
@echo Installation PREFIX $(PREFIX)
COMPDIR="$(PREFIX)/share/bash-completion/completions"; \
mkdir -p "$(PREFIX)" && \
mkdir -p "$$COMPDIR" && \
cp "$(BIN)" "$(PREFIX)/bin/$(BIN)" && \
ln -s "$(PREFIX)/bin/$(BIN)" "$(PREFIX)/bin/$(SYMLINK)" && \
cp "$(COMPL)" "$$COMPDIR/$(BIN)"
@echo Successfully installed
uninstall:
$(eval PREFIX := $(shell cat $(TMP)))
@echo Installation PREFIX $(PREFIX)
COMPDIR="$(PREFIX)/share/bash-completion/completions"; \
rm -f "$(PREFIX)/bin/$(BIN)" && \
rm -f "$(PREFIX)/bin/$(SYMLINK)" && \
rm -f "$$COMPDIR/$(BIN)"
@echo Successfully uninstalled
set-prefix:
if [ "$$UID" == "0" ]; then \
echo $${PREFIX:-/usr/local} > $(TMP); else \
echo $${PREFIX:-$$HOME/.local} > $(TMP); fi;