[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Uninstall-target for Makefile



Heya,

so.. I searched for a bug which didn't exist, then I figured out I
accidentally installed herbstluftwm to /usr/local/bin via make install
at some point... Stupid me.

So I implemented a "make uninstall". By default it only removes the
directories which are unique to herbstluftwm (so e.g. it won't attempt
to remove /usr/local/bin aka. $(BINDIR), but it will remove
/etc/xdg/herbstluftwm aka. $(CONFIGDIR).

Florian

-- 
() ascii ribbon campaign - stop html mail    www.asciiribbon.org
/\ www.the-compiler.org  | I love long mails http://email.is-not-s.ms/
There's something the technicians need to learn from the artists. If it isn't 
aesthetically pleasing, it's probably wrong. 
>From 28fdd531ea838583b1f383a749e6e8bab23d5d65 Mon Sep 17 00:00:00 2001
From: Florian Bruhin <git _at_ the _minus_ compiler _dot_ org>
Date: Mon, 12 Nov 2012 00:02:08 +0100
Subject: [PATCH] Add an 'uninstall' target to the Makefile.

---
 Makefile  | 26 ++++++++++++++++++++++++++
 config.mk |  2 ++
 2 files changed, 28 insertions(+)

diff --git a/Makefile b/Makefile
index dd23bbd..07b5ca3 100644
--- a/Makefile
+++ b/Makefile
@@ -123,6 +123,32 @@ install: all
 	$(INSTALL) -m 644 scripts/README '$(DESTDIR)/$(EXAMPLESDIR)/'
 	$(INSTALL) -m 755 scripts/*.sh '$(DESTDIR)/$(EXAMPLESDIR)/'
 
+uninstall:
+	@echo "==> deleting files..."
+	$(foreach TARGET,$(TARGETS),-$(RM) '$(DESTDIR)/$(BINDIR)/$(TARGET)';)
+	-$(RM) '$(DESTDIR)/$(LICENSEDIR)/LICENSE'
+	-$(RM) '$(DESTDIR)/$(MAN1DIR)/herbstclient.1'
+	-$(RM) '$(DESTDIR)/$(MAN1DIR)/herbstluftwm.1'
+	-$(RM) '$(DESTDIR)/$(MAN7DIR)/herbstluftwm-tutorial.7'
+	-$(RM) '$(DESTDIR)/$(DOCDIR)/herbstclient.html'
+	-$(RM) '$(DESTDIR)/$(DOCDIR)/herbstluftwm.html'
+	-$(RM) '$(DESTDIR)/$(DOCDIR)/herbstluftwm-tutorial.html'
+	-$(RM) '$(DESTDIR)/$(DOCDIR)/BUGS'
+	-$(RM) '$(DESTDIR)/$(DOCDIR)/NEWS'
+	-$(RM) '$(DESTDIR)/$(DOCDIR)/README'
+	-$(RM) '$(DESTDIR)/$(CONFIGDIR)/autostart'
+	-$(RM) '$(DESTDIR)/$(CONFIGDIR)/panel.sh'
+	-$(RM) '$(DESTDIR)/$(CONFIGDIR)/restartpanels.sh'
+	-$(RM) '$(DESTDIR)/$(BASHCOMPLETIONDIR)/herbstclient-completion'
+	-$(RM) '$(DESTDIR)/$(ZSHCOMPLETIONDIR)/_herbstclient'
+	-$(RM) '$(DESTDIR)/$(XSESSIONSDIR)/herbstluftwm.desktop'
+	-$(RM) '$(DESTDIR)/$(EXAMPLESDIR)/README'
+	$(foreach SCRIPT,$(wildcard '$(DESTDIR)/$(EXAMPLESDIR)/*.sh'),-$(RM) '$(SCRIPT)';)
+	@echo "==> deleting directories..."
+	-$(RMDIR) '$(EXAMPLESDIR)'
+	-$(RMDIR) '$(DOCDIR)'
+	-$(RMDIR) '$(CONFIGDIR)'
+
 www:
 	make -C www
 
diff --git a/config.mk b/config.mk
index 8391a6c..1f7410a 100644
--- a/config.mk
+++ b/config.mk
@@ -48,6 +48,8 @@ ASCIIDOC = asciidoc
 TMPTARDIR = herbstluftwm-$(VERSION)
 MKDIR = mkdir -p
 INSTALL = install
+RM = rm -f
+RMDIR = rmdir
 
 # Controls verbose build
 # Remove the @ to see the actual compiler invocations
-- 
1.8.0