From 7d03c33e0a63d431b6551cbe2ef13f9fb2aaa636 Mon Sep 17 00:00:00 2001
From: Matt O'Gorman <mogorman@digium.com>
Date: Wed, 1 Feb 2006 18:39:41 +0000
Subject: [PATCH] Allows for user to uninstall asterisk binaries bug 6177

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9052 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 Makefile          | 34 ++++++++++++++++++++++++++++++++++
 agi/Makefile      |  3 +++
 apps/Makefile     |  2 ++
 cdr/Makefile      |  2 ++
 channels/Makefile |  3 ++-
 codecs/Makefile   |  2 ++
 formats/Makefile  |  2 ++
 funcs/Makefile    |  2 ++
 pbx/Makefile      |  2 ++
 res/Makefile      |  2 ++
 stdtime/Makefile  |  2 ++
 utils/Makefile    |  3 +++
 12 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 4b69318e35..56e385825f 100644
--- a/Makefile
+++ b/Makefile
@@ -912,3 +912,37 @@ cleantest:
 	if cmp -s .cleancount .lastclean ; then echo ; else \
 		$(MAKE) clean; cp -f .cleancount .lastclean;\
 	fi
+
+_uninstall:
+	rm -f $(DESTDIR)$(MODULES_DIR)/*
+	rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
+	rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
+	rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
+	rm -rf $(DESTDIR)$(ASTHEADERDIR)
+	rm -rf $(DESTDIR)$(ASTVARLIBDIR)/sounds
+	rm -rf $(DESTDIR)$(ASTVARLIBDIR)/firmware
+	rm -rf $(DESTDIR)$(ASTMANDIR)/man8
+	for x in $(SUBDIRS); do $(MAKE) -C $$x uninstall || exit 1 ; done
+
+uninstall: _uninstall
+	@echo " +--------- Asterisk Uninstall Complete -----+"  
+	@echo " + Asterisk binaries, sounds, man pages,     +"  
+	@echo " + headers, modules, and firmware builds,    +"  
+	@echo " + have all been uninstalled.                +"  
+	@echo " +                                           +"
+	@echo " + To remove ALL traces of Asterisk,         +"
+	@echo " + including configuration, spool            +"
+	@echo " + directories, and logs, run the following  +"
+	@echo " + command:                                  +"
+	@echo " +                                           +"
+	@echo " +            $(MAKE) uninstall-all             +"  
+	@echo " +-------------------------------------------+"  
+
+
+uninstall-all: _uninstall
+	rm -rf $(DESTDIR)$(ASTLIBDIR)
+	rm -rf $(DESTDIR)$(ASTVARLIBDIR)
+	rm -rf $(DESTDIR)$(ASTSPOOLDIR)
+	rm -rf $(DESTDIR)$(ASTETCDIR)
+	rm -rf $(DESTDIR)$(ASTLOGDIR)
+	
diff --git a/agi/Makefile b/agi/Makefile
index 8cea3499f4..5f2a6af9be 100644
--- a/agi/Makefile
+++ b/agi/Makefile
@@ -30,6 +30,9 @@ install: all
 	mkdir -p $(DESTDIR)$(AGI_DIR)
 	for x in $(AGIS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(AGI_DIR) ; done
 
+uninstall:
+	for x in $(AGIS); do rm -f $(DESTDIR)$(AGI_DIR)/$$x ; done
+
 eagi-test: eagi-test.o
 	$(CC) $(CFLAGS) -o eagi-test eagi-test.o $(LIBS)
 
diff --git a/apps/Makefile b/apps/Makefile
index a5e195f989..2182acb652 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -92,6 +92,8 @@ install: all
 	rm -f $(DESTDIR)$(MODULES_DIR)/app_datetime.so
 	rm -f $(DESTDIR)$(MODULES_DIR)/app_qcall.so
 
+uninstall:
+
 app_curl.so: app_curl.o
 	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CURLLIBS)
 
diff --git a/cdr/Makefile b/cdr/Makefile
index 49c3e4f4d9..8663754e67 100644
--- a/cdr/Makefile
+++ b/cdr/Makefile
@@ -112,6 +112,8 @@ all: depend $(MODS)
 install: all
 	for x in $(MODS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
 
+uninstall:
+
 clean:
 	rm -f *.so *.o .depend
 
diff --git a/channels/Makefile b/channels/Makefile
index 4c61b4854d..4eb9329531 100644
--- a/channels/Makefile
+++ b/channels/Makefile
@@ -234,6 +234,8 @@ install: all
 	for x in $(CHANNEL_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
 	if ! [ -f chan_iax.so ]; then rm -f $(DESTDIR)$(MODULES_DIR)/chan_iax.so ; fi
 
+uninstall:
+
 depend: .depend
 
 .depend:
@@ -241,4 +243,3 @@ depend: .depend
 
 env:
 	env
-
diff --git a/codecs/Makefile b/codecs/Makefile
index 49c041a4b9..9eb4dff908 100644
--- a/codecs/Makefile
+++ b/codecs/Makefile
@@ -134,6 +134,8 @@ endif
 install: all
 	for x in $(CODECS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
 
+uninstall:
+
 depend: .depend
 
 .depend:
diff --git a/formats/Makefile b/formats/Makefile
index 9858180bdf..636f1f3118 100644
--- a/formats/Makefile
+++ b/formats/Makefile
@@ -58,6 +58,8 @@ format_ogg_vorbis.so : format_ogg_vorbis.o
 install: all
 	for x in $(FORMAT_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
 
+uninstall:
+
 depend: .depend
 
 .depend:
diff --git a/funcs/Makefile b/funcs/Makefile
index 773594c64c..4169e2a154 100644
--- a/funcs/Makefile
+++ b/funcs/Makefile
@@ -75,6 +75,8 @@ func_odbc.so: func_odbc.o
 install: all
 	for x in $(FUNCS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
 
+uninstall:
+
 ifneq ($(wildcard .depend),)
   include .depend
 endif
diff --git a/pbx/Makefile b/pbx/Makefile
index c8fe28b2df..0bdb057c23 100644
--- a/pbx/Makefile
+++ b/pbx/Makefile
@@ -70,6 +70,8 @@ endif
 install: all
 	for x in $(PBX_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
 
+uninstall:
+
 depend: .depend
 
 .depend:
diff --git a/res/Makefile b/res/Makefile
index 5a2b050725..5b127713d9 100644
--- a/res/Makefile
+++ b/res/Makefile
@@ -83,6 +83,8 @@ install: all
 		echo "***       it if you want to use MusicOnHold       ***";\
 	fi
 
+uninstall:
+
 res_crypto.so: res_crypto.o
 	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CRYPTO_LIBS)
 
diff --git a/stdtime/Makefile b/stdtime/Makefile
index e97010f0fa..391b4550a8 100644
--- a/stdtime/Makefile
+++ b/stdtime/Makefile
@@ -8,6 +8,8 @@ libtime.a: $(OBJS)
 
 install:
 
+uninstall:
+
 clean:
 	rm -f libtime.a *.o test .depend
 
diff --git a/utils/Makefile b/utils/Makefile
index dd21bbee36..cc90f358e3 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -40,6 +40,9 @@ install:
 		fi; \
 	done 
 
+uninstall:
+	for x in $(TARGET); do rm -f $$x $(DESTDIR)$(ASTSBINDIR)/$$x; done
+
 clean:
 	rm -f *.o astman smsq stereorize streamplayer check_expr .depend
 	rm -f ast_expr2.o ast_expr2f.o
-- 
GitLab