Makefile: add uninstall targets
authorFerry Huberts <f.huberts@mindef.nl>
Mon, 25 Jul 2011 14:21:48 +0000 (16:21 +0200)
committerFerry Huberts <f.huberts@mindef.nl>
Thu, 11 Aug 2011 11:57:34 +0000 (13:57 +0200)
Signed-off-by: Ferry Huberts <f.huberts@mindef.nl>
Makefile
Makefile.inc

index 7dbc383..c0c6391 100644 (file)
--- 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,5 @@ watchdog_uninstall:
 
 build_all:     all switch libs
 install_all:   install install_libs
+uninstall_all: uninstall uninstall_libs
 clean_all:     uberclean clean_libs
index ec77d1a..3c46fab 100644 (file)
@@ -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),.)