From: Mike Hommey <glandium@debian.org>
Date: Thu, 13 Mar 2008 08:22:05 +0100
Subject: Add soname to appropriate libraries.

This is a stripped down version, compared to the dpatch version, because we
actually are never going to use minor and micro version numbers. Also, we
now don't set a SO version on libxul and libxpcom because they will now
be dlloaded() by the standalone xpcomglue.
---
 config/rules.mk        |   20 ++++++++++++++++++--
 js/src/Makefile.in     |    4 ++++
 js/src/config/rules.mk |   20 ++++++++++++++++++--
 3 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/config/rules.mk b/config/rules.mk
index 9c55eed..5bae201 100644
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -251,6 +251,18 @@ else
 SHARED_LIBRARY		:= $(DLL_PREFIX)$(LIBRARY_NAME)$(DLL_SUFFIX)
 endif
 
+ifdef SO_VERSION
+UNVERSIONED_LIBRARY	:= $(notdir $(SHARED_LIBRARY))
+
+ifeq ($(strip $(SHARED_LIBRARY)),$(strip $(SDK_LIBRARY)))
+SDK_LIBRARY		:= $(SHARED_LIBRARY)
+endif
+
+SHARED_LIBRARY		:= $(SHARED_LIBRARY).$(SO_VERSION)
+
+MKSHLINKS		= rm -f $(1)/$(UNVERSIONED_LIBRARY); ln -s $(SHARED_LIBRARY) $(1)/$(UNVERSIONED_LIBRARY)
+endif
+
 ifeq ($(OS_ARCH),OS2)
 DEF_FILE		:= $(SHARED_LIBRARY:.dll=.def)
 endif
@@ -364,7 +376,7 @@ HOST_PDBFILE=$(basename $(@F)).pdb
 endif
 
 ifndef TARGETS
-TARGETS			= $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
+TARGETS			= $(LIBRARY) $(UNVERSIONED_LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
 endif
 
 ifndef OBJS
@@ -867,7 +879,7 @@ $(PARALLEL_DIRS_libs): %_libs: %/Makefile
 	+@$(UPDATE_TITLE_libs) $(MAKE) -C $* libs
 endif
 
-libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
+libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(UNVERSIONED_LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
 ifndef NO_DIST_INSTALL
 ifdef LIBRARY
 ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build
@@ -897,8 +909,10 @@ ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
 	$(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib
 else
 	$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib
+	$(call MKSHLINKS,$(DIST)/lib)
 endif
 	$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)
+	$(call MKSHLINKS,$(FINAL_TARGET))
 ifdef BEOS_ADDON_WORKAROUND
 	( cd $(FINAL_TARGET) && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
 endif
@@ -1240,6 +1254,8 @@ endif
 # so instead of deleting .o files after repacking them into a dylib, we make
 # symlinks back to the originals. The symlinks are a no-op for stabs debugging,
 # so no need to conditionalize on OS version or debugging format.
+$(UNVERSIONED_LIBRARY): $(SHARED_LIBRARY)
+	$(call MKSHLINKS,.)
 
 $(SHARED_LIBRARY): $(OBJS) $(LOBJS) $(DEF_FILE) $(RESFILE) $(SHARED_LIBRARY_LIBS) $(EXTRA_DEPS) $(DSO_LDOPTS_DEPS) $(GLOBAL_DEPS)
 ifndef INCREMENTAL_LINKER
diff --git a/js/src/Makefile.in b/js/src/Makefile.in
index 95a59fb..1bc8a6b 100644
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -49,6 +49,7 @@ include $(DEPTH)/config/autoconf.mk
 MODULE		= js
 LIBRARY_NAME	= mozjs
 GRE_MODULE	= 1
+SO_VERSION	= 2d
 
 SIMPLE_PROGRAMS	= js$(BIN_SUFFIX)
 LIBS		= -L. $(MOZ_JS_LIBS) $(NSPR_LIBS)
@@ -612,6 +613,9 @@ ifneq (,$(LIBRARY))
 endif
 ifneq (,$(SHARED_LIBRARY))
 	$(SYSINSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(libdir)
+ifneq (,$(UNVERSIONED_LIBRARY))
+	ln -s $(SHARED_LIBRARY) $(libdir)/$(UNVERSIONED_LIBRARY)
+endif
 endif
 ifneq (,$(IMPORT_LIBRARY))
 	$(SYSINSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(libdir)
diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk
index 9c55eed..5bae201 100644
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -251,6 +251,18 @@ else
 SHARED_LIBRARY		:= $(DLL_PREFIX)$(LIBRARY_NAME)$(DLL_SUFFIX)
 endif
 
+ifdef SO_VERSION
+UNVERSIONED_LIBRARY	:= $(notdir $(SHARED_LIBRARY))
+
+ifeq ($(strip $(SHARED_LIBRARY)),$(strip $(SDK_LIBRARY)))
+SDK_LIBRARY		:= $(SHARED_LIBRARY)
+endif
+
+SHARED_LIBRARY		:= $(SHARED_LIBRARY).$(SO_VERSION)
+
+MKSHLINKS		= rm -f $(1)/$(UNVERSIONED_LIBRARY); ln -s $(SHARED_LIBRARY) $(1)/$(UNVERSIONED_LIBRARY)
+endif
+
 ifeq ($(OS_ARCH),OS2)
 DEF_FILE		:= $(SHARED_LIBRARY:.dll=.def)
 endif
@@ -364,7 +376,7 @@ HOST_PDBFILE=$(basename $(@F)).pdb
 endif
 
 ifndef TARGETS
-TARGETS			= $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
+TARGETS			= $(LIBRARY) $(UNVERSIONED_LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
 endif
 
 ifndef OBJS
@@ -867,7 +879,7 @@ $(PARALLEL_DIRS_libs): %_libs: %/Makefile
 	+@$(UPDATE_TITLE_libs) $(MAKE) -C $* libs
 endif
 
-libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
+libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(UNVERSIONED_LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
 ifndef NO_DIST_INSTALL
 ifdef LIBRARY
 ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build
@@ -897,8 +909,10 @@ ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
 	$(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib
 else
 	$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib
+	$(call MKSHLINKS,$(DIST)/lib)
 endif
 	$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)
+	$(call MKSHLINKS,$(FINAL_TARGET))
 ifdef BEOS_ADDON_WORKAROUND
 	( cd $(FINAL_TARGET) && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
 endif
@@ -1240,6 +1254,8 @@ endif
 # so instead of deleting .o files after repacking them into a dylib, we make
 # symlinks back to the originals. The symlinks are a no-op for stabs debugging,
 # so no need to conditionalize on OS version or debugging format.
+$(UNVERSIONED_LIBRARY): $(SHARED_LIBRARY)
+	$(call MKSHLINKS,.)
 
 $(SHARED_LIBRARY): $(OBJS) $(LOBJS) $(DEF_FILE) $(RESFILE) $(SHARED_LIBRARY_LIBS) $(EXTRA_DEPS) $(DSO_LDOPTS_DEPS) $(GLOBAL_DEPS)
 ifndef INCREMENTAL_LINKER
