38 lines
1.1 KiB
Makefile
38 lines
1.1 KiB
Makefile
BIN := "nexclamation"
|
|
SYMLINK := "n!"
|
|
COMPL := "completion"
|
|
PREF := "./.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 $(PREF)))
|
|
@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 $(PREF)))
|
|
@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} > $(PREF); else \
|
|
echo $${PREFIX:-$$HOME/.local} > $(PREF); fi;
|