From 4547f13811ca133205ad70c1c9939818670ac0eb Mon Sep 17 00:00:00 2001 From: Jonathan-M-C <> Date: Sat, 29 May 2021 19:03:45 -0400 Subject: [PATCH] Add local install option Add install-local and uninstall-local in Makefile --- Makefile | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5cd5bf2..3a23d95 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,34 @@ endif ifndef MANPREFIX MANPREFIX = $(PREFIX)/share/man endif +ifndef XDG_DATA_HOME + XDG_DATA_HOME = $(HOME)/.local/share +endif + +DESTDIR = mutt-wizard +PREFIX_LOCAL = $(XDG_DATA_HOME) +BIN_LOCAL = $(HOME)/.local/bin +MANPREFIX_LOCAL = $(PREFIX_LOCAL)/man + +install-local: + cp -f bin/mw bin/mailsync bin/openfile $(BIN_LOCAL) + mkdir -p $(PREFIX_LOCAL)/$(DESTDIR) + cp -f share/mailcap share/domains.csv share/mutt-wizard.muttrc $(PREFIX_LOCAL)/$(DESTDIR) + mkdir -p $(MANPREFIX_LOCAL)/man1 + cp -f mw.1 $(MANPREFIX_LOCAL)/man1/mw.1 + if [ "$(PREFIX_LOCAL)" ]; then \ + sed -iba 's:/usr/local:$(PREFIX_LOCAL):' $(PREFIX_LOCAL)/$(DESTDIR)/mutt-wizard.muttrc; \ + rm -f $(PREFIX_LOCAL)/$(DESTDIR)/mutt-wizard.muttrcba; \ + sed -iba 's:/usr/local:$(PREFIX_LOCAL):' $(BIN_LOCAL)/mw; \ + rm -f $(BIN_LOCAL)/mwba; \ + sed -iba 's:/usr/local:$(PREFIX_LOCAL):' $(MANPREFIX_LOCAL)/man1/mw.1; \ + rm -f $(MANPREFIX_LOCAL)/man1/mw.1ba; \ + fi + +uninstall-local: + rm -f $(BIN_LOCAL)/mw $(BIN_LOCAL)/mailsync $(BIN_LOCAL)/openfile + rm -rf $(PREFIX_LOCAL)/$(DESTDIR) + rm -f $(MANPREFIX_LOCAL)/man1/mw.1 install: mkdir -p $(DESTDIR)$(PREFIX)/bin @@ -33,4 +61,4 @@ uninstall: rm -rf $(DESTDIR)$(PREFIX)/share/mutt-wizard rm -f $(DESTDIR)$(MANPREFIX)/man1/mw.1 -.PHONY: install uninstall +.PHONY: install-local uninstall-local install uninstall