n/Makefile

38 lines
1.1 KiB
Makefile
Raw Permalink Normal View History

2022-07-07 23:31:13 +03:00
BIN := "nexclamation"
SYMLINK := "n!"
COMPL := "completion"
2022-07-07 23:35:19 +03:00
PREF := "./.installation_prefix"
2022-07-07 23:31:13 +03:00
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
2022-07-07 23:35:19 +03:00
$(eval PREFIX := $(shell cat $(PREF)))
2022-07-07 23:31:13 +03:00
@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:
2022-07-07 23:35:19 +03:00
$(eval PREFIX := $(shell cat $(PREF)))
2022-07-07 23:31:13 +03:00
@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 \
2022-07-07 23:35:19 +03:00
echo $${PREFIX:-/usr/local} > $(PREF); else \
echo $${PREFIX:-$$HOME/.local} > $(PREF); fi;