]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
build: Warn if asterisk is installed in both 32 and 64 bit sys dirs
authorGeorge Joseph <gjoseph@digium.com>
Mon, 27 Feb 2017 18:25:01 +0000 (11:25 -0700)
committerGeorge Joseph <gjoseph@digium.com>
Mon, 27 Feb 2017 18:55:41 +0000 (11:55 -0700)
... and clean them both up on uninstall.

We've fixed the issue where 'make install' was installing to
/usr/lib on 64-bit systems that use /usr/lib64.  Now we need
to clean up the remnants in /usr/lib.

* 'make install' now prints a warning if DESTDIR/ASTLIBDIR
  contains 'lib64' and libasterisk* shared libraries or modules
  are also found in DESTDIR/ASTLIBDIR with 'lib64' transformed
  to 'lib'.

* 'make uninstall' ALWAYS cleans up both DESTDIR/ASTLIBDIR and
  DESTDIR/ASTLIBDIR with 'lib64' transformed to 'lib'.

ASTERISK-26705

Change-Id: I6edddeb3c07a51e7c7ba7cac3c05e4bf3ec3f01f

Makefile
main/Makefile

index 687ab966f43a29e63671e15a7339246e904a601a..0487abdd4ccc391b691b2734ae2f1778c568b973 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -653,6 +653,37 @@ ifneq ($(LDCONFIG),)
        fi
 endif
 
+ifeq ($(and $(findstring 64,$(HOST_CPU)),$(findstring lib64,$(DESTDIR)$(ASTLIBDIR))),lib64)
+_oldlibdir = $(subst lib64,lib,$(DESTDIR)$(ASTLIBDIR))
+
+check-old-libdir:
+       @oldfiles=`find "$(_oldlibdir)" -name libasterisk* -print -quit -o \( -path *asterisk/modules/* -a -name *.so \) -print -quit` ;\
+       if [ "x$$oldfiles" != "x" ] ; then \
+               echo " WARNING WARNING WARNING" ;\
+               echo "" ;\
+               echo " Installation is to: " ;\
+               echo "   $(DESTDIR)$(ASTLIBDIR)" ;\
+               echo " but there are asterisk shared libraries in: " ;\
+               echo "   $(_oldlibdir)" ;\
+               echo " or" ;\
+               echo "   $(_oldlibdir)/asterisk/modules" ;\
+               echo "" ;\
+               echo " It is unlikely that asterisk will start." ;\
+               echo "" ;\
+               echo " You should do one of the following..." ;\
+               echo "  * Run 'make uninstall' to remove the incorrect libraries" ;\
+               echo "    then run 'make install' again." ;\
+               echo "  * Manually remove the libraries from" ;\
+               echo "   $(_oldlibdir)" ;\
+               echo "   and run 'ldconfig' to rebuild the linker cache." ;\
+               echo "" ;\
+               echo " WARNING WARNING WARNING" ;\
+       fi
+else
+check-old-libdir:
+
+endif
+
 badshell:
 ifneq ($(filter ~%,$(DESTDIR)),)
        @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
@@ -692,6 +723,7 @@ install: badshell bininstall datafiles
        @echo " +-------------------------------------------+"
        @$(MAKE) -s oldmodcheck
        @$(MAKE) -s ld-cache-update
+       @$(MAKE) -s check-old-libdir
 
 isntall: install
 
@@ -912,6 +944,7 @@ main-binuninstall:
 
 _uninstall: $(SUBDIRS_UNINSTALL) main-binuninstall
        rm -f "$(DESTDIR)$(ASTMODDIR)/"*
+       rm -f "$(subst lib64,lib,$(DESTDIR)$(ASTMODDIR))/"*
        rm -f "$(DESTDIR)$(ASTSBINDIR)/astgenkey"
        rm -f "$(DESTDIR)$(ASTSBINDIR)/autosupport"
        rm -rf "$(DESTDIR)$(ASTHEADERDIR)"
@@ -944,6 +977,7 @@ uninstall: _uninstall
 
 uninstall-all: _uninstall
        rm -rf "$(DESTDIR)$(ASTMODDIR)"
+       rm -rf "$(subst lib64,lib,$(DESTDIR)$(ASTMODDIR))"
        rm -rf "$(DESTDIR)$(ASTVARLIBDIR)"
        rm -rf "$(DESTDIR)$(ASTDATADIR)"
        rm -rf "$(DESTDIR)$(ASTSPOOLDIR)"
@@ -1058,6 +1092,7 @@ check-alembic: makeopts
 .PHONY: basic-pbx
 .PHONY: check-alembic
 .PHONY: ld-cache-update
+.PHONY: check-old-libdir
 .PHONY: $(SUBDIRS_INSTALL)
 .PHONY: $(SUBDIRS_DIST_CLEAN)
 .PHONY: $(SUBDIRS_CLEAN)
index fb473141e96c1427f9e7713d7f7c4bae36df32fb..599803a10a08363d3c27fc0253ab17458a997c9d 100644 (file)
@@ -359,16 +359,8 @@ endif
 binuninstall:
        rm -f "$(DESTDIR)$(ASTSBINDIR)/$(MAIN_TGT)"
        rm -f "$(DESTDIR)$(ASTSBINDIR)/rasterisk"
-ifneq ($(ASTSSL_LIB).$(ASTSSL_SO_VERSION),.)
-#   ASTSSL_SO_VERSION may not exist on Darwin
-       rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTSSL_LIB).$(ASTSSL_SO_VERSION)" || :
-       rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTSSL_LIB)"
-endif
-ifneq ($(ASTPJ_LIB).$(ASTPJ_SO_VERSION),.)
-#   ASTSSL_SO_VERSION may not exist on Darwin
-       rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTPJ_LIB).$(ASTPJ_SO_VERSION)" || :
-       rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTPJ_LIB)"
-endif
+       rm -f "$(DESTDIR)$(ASTLIBDIR)/libasterisk"* || :
+       rm -f "$(subst lib64,lib,$(DESTDIR)$(ASTLIBDIR))/libasterisk"* || :
 
 clean::
        rm -f asterisk libasteriskssl.o