[Olsr-dev] [PATCH 19/20] Makefile: add uninstall targets

Ferry Huberts (spam-protected)
Mon Jul 25 17:38:12 CEST 2011


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 Makefile     |   26 +++++++++++++++++++++++++-
 Makefile.inc |   20 +++++++++++---------
 2 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 7dbc383..f512eaf 100644
--- a/Makefile
+++ b/Makefile
@@ -81,7 +81,7 @@ src/builddata.c:
 	@echo "const char build_host[] = \"$(shell hostname)\";" >> "$@" 
 
 
-.PHONY: help libs clean_libs libs_clean clean uberclean install_libs libs_install install_bin install_olsrd install build_all install_all clean_all 
+.PHONY: help libs clean_libs libs_clean clean uberclean install_libs uninstall_libs libs_install libs_uninstall install_bin uninstall_bin install_olsrd uninstall_olsrd install uninstall build_all install_all uninstall_all clean_all 
 
 clean:
 	-rm -f $(OBJS) $(SRCS:%.c=%.d) $(EXENAME) $(EXENAME).exe src/builddata.c $(TMPFILES)
@@ -101,11 +101,17 @@ uberclean:	clean clean_libs
 
 install: install_olsrd
 
+uninstall: uninstall_olsrd
+
 install_bin:
 		mkdir -p $(SBINDIR)
 		install -m 755 $(EXENAME) $(SBINDIR)
 		$(STRIP) $(SBINDIR)/$(EXENAME)
 
+uninstall_bin:
+		rm -f $(SBINDIR)/$(EXENAME)
+		rmdir -p --ignore-fail-on-non-empty $(SBINDIR)
+
 install_olsrd:	install_bin
 		@echo ========= C O N F I G U R A T I O N - F I L E ============
 		@echo $(EXENAME) uses the configfile $(CFGFILE)
@@ -129,6 +135,16 @@ ifneq ($(MANDIR),)
 		cp files/olsrd.conf.5.gz $(MANDIR)/man5/$(CFGNAME).5.gz
 endif
 
+uninstall_olsrd:	uninstall_bin
+ifneq ($(MANDIR),)
+		rm -f $(MANDIR)/man5/$(CFGNAME).5.gz
+		rmdir -p --ignore-fail-on-non-empty $(MANDIR)/man5/
+		rm -f $(MANDIR)/man8/$(EXENAME).8.gz
+		rmdir -p --ignore-fail-on-non-empty $(MANDIR)/man8/
+endif
+		rm -f $(CFGFILE)
+		rmdir -p --ignore-fail-on-non-empty $(ETCDIR)
+
 tags:
 		$(TAGCMD) -o $(TAGFILE) $(TAG_SRCS)
 
@@ -166,6 +182,10 @@ libs_clean clean_libs:
 libs_install install_libs:
 		set -e;for dir in $(SUBDIRS);do $(MAKECMD) -C lib/$$dir LIBDIR=$(LIBDIR) install;done
 
+libs_uninstall uninstall_libs:
+		set -e;for dir in $(SUBDIRS);do $(MAKECMD) -C lib/$$dir LIBDIR=$(LIBDIR) uninstall;done
+		rmdir -p --ignore-fail-on-non-empty $(LIBDIR)
+
 httpinfo:
 		$(MAKECMD) -C lib/httpinfo clean
 		$(MAKECMD) -C lib/httpinfo 
@@ -319,4 +339,8 @@ watchdog_uninstall:
 
 build_all:	all switch libs
 install_all:	install install_libs
+uninstall_all:	uninstall uninstall_libs
+ifneq ($(DESTDIR),)
+	mkdir -p $(DESTDIR)
+endif
 clean_all:	uberclean clean_libs
diff --git a/Makefile.inc b/Makefile.inc
index be273f7..5b73434 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -47,15 +47,17 @@ FLEX ?=		flex
 TAGCMD ?=	etags
 
 # target directories and names
-DESTDIR ?=
-SBINDIR ?= $(DESTDIR)/usr/sbin
-ETCDIR  ?= $(DESTDIR)/etc
-LIBDIR  ?= $(DESTDIR)/usr/lib
-DOCDIR  ?= $(DESTDIR)/usr/share/doc
-MANDIR  ?= $(DESTDIR)/usr/share/man
-EXENAME ?= olsrd
-CFGNAME ?= $(EXENAME).conf
-CFGFILE ?= $(ETCDIR)/$(CFGNAME)
+DESTDIR  ?=
+ETCDIR   ?= $(DESTDIR)/etc
+USRDIR   ?= $(DESTDIR)/usr
+LIBDIR   ?= $(USRDIR)/lib
+SBINDIR  ?= $(USRDIR)/sbin
+SHAREDIR ?= $(USRDIR)/share
+DOCDIR   ?= $(SHAREDIR)/doc
+MANDIR   ?= $(SHAREDIR)/man
+EXENAME  ?= olsrd
+CFGNAME  ?= $(EXENAME).conf
+CFGFILE  ?= $(ETCDIR)/$(CFGNAME)
 
 CPPFLAGS =	-Isrc
 ifneq ($(TOPDIR),.)
-- 
1.7.6





More information about the Olsr-dev mailing list