Introduce INSTALLDIR directory for DRY

This commit is contained in:
Marco Sirabella 2020-07-03 09:46:11 -04:00
parent cbf188cd3d
commit 2171be802f
No known key found for this signature in database
GPG key ID: 350CE23EFB20D1A7

View file

@ -4,27 +4,29 @@ WEECHAT_HOME ?= $(HOME)/.weechat
PREFIX ?= $(WEECHAT_HOME)
PYTHON ?= python
lib := $(patsubst matrix/%.py, $(DESTDIR)$(PREFIX)/python/matrix/%.py, \
INSTALLDIR := $(DESTDIR)$(PREFIX)/python/matrix
lib := $(patsubst matrix/%.py, $(INSTALLDIR)/%.py, \
$(wildcard matrix/*.py))
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
install: install-lib | $(DESTDIR)$(PREFIX)/python/matrix/ ## Install the plugin to $(DESTDIR)/$(PREFIX)
install: install-lib | $(INSTALLDIR) ## Install the plugin to $(DESTDIR)/$(PREFIX)
install -m644 main.py $(DESTDIR)$(PREFIX)/python/matrix.py
install-lib: $(lib)
$(DESTDIR)$(PREFIX)/python/matrix/:
$(INSTALLDIR):
install -d $@
uninstall: ## Uninstall the plugin from $(PREFIX)
rm $(DESTDIR)$(PREFIX)/python/matrix.py $(DESTDIR)$(PREFIX)/python/matrix/*
rmdir $(DESTDIR)$(PREFIX)/python/matrix
rm $(DESTDIR)$(PREFIX)/python/matrix.py $(INSTALLDIR)/*
rmdir $(INSTALLDIR)
phony:
$(DESTDIR)$(PREFIX)/python/matrix/%.py: matrix/%.py phony | $(DESTDIR)$(PREFIX)/python/matrix/
$(INSTALLDIR)/%.py: matrix/%.py phony | $(INSTALLDIR)
install -m644 $< $@
test: ## Run automated tests