#! /bin/sh /usr/share/dpatch/dpatch-run
## 20-versioned_libs.dpatch by Thomas Girard <thomas.g.girard@free.fr>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Change versioning from libACE.so.x.y.z to libACE-x.y.z.so.

@DPATCH@
--- ACE_wrappers.orig/include/makeinclude/wrapper_macros.GNU	2010-10-05 09:27:20.000000000 +0200
+++ ACE_wrappers/include/makeinclude/wrapper_macros.GNU	2010-12-22 15:40:14.126127937 +0100
@@ -78,7 +78,10 @@
 #                   If versioned_so is 1 (enabled), the SOVERSION make
 #                   variable can also be set to specify the version info
 #                   to append to the name - it should have a leading '.' -
-#                   else it defaults to .ACE_MAJOR.ACE_MINOR.ACE_BETA.
+#                   else it defaults to .ACE_MAJOR.ACE_MINOR.ACE_BETA. If 2,
+#                   the version will be appended to the name but *before* the
+#                   $(SOEXT) - it should have a lead '-' - else it defaults to
+#                   -ACE_MAJOR.ACE_MINOR.ACE_BETA.
 #  wfmo             Build with wfmo support (Win32 only)
 #  winregistry      Build with windows registry support (Win32 only)
 #  winnt            Build WinNT-specific projects (Win32 only)
--- ACE_wrappers.orig/MPC/prj_install.pl	2010-09-14 21:39:33.000000000 +0200
+++ ACE_wrappers/MPC/prj_install.pl	2010-12-22 15:38:28.746110985 +0100
@@ -186,7 +186,7 @@
     my $fh   = new FileHandle();
     if (opendir($fh, $odir)) {
       foreach my $file (grep(!/^\.\.?$/, readdir($fh))) {
-        if ($file =~ /^lib$name\.(a|so|sl)/ ||
+        if ($file =~ /^lib$name(-[0-9]+(\.[0-9]+)*)?\.(a|so|sl)/ ||
             $file =~ /^(lib)?$name.*\.(dll|lib)$/i) {
           push(@libs, "$dir$insdir$binarydir$file");
         }
--- ACE_wrappers.orig/include/makeinclude/platform_g++_common.GNU	2010-11-19 16:47:53.000000000 +0100
+++ ACE_wrappers/include/makeinclude/platform_g++_common.GNU	2010-12-22 16:16:05.914110606 +0100
@@ -72,7 +72,7 @@
 # If the platform file didn't already set versioned_so, default to 1.
 versioned_so ?= 1
 with_ld ?=
-ifeq ($(versioned_so),1)
+ifneq ($(versioned_so),0)
   ifeq ($(with_ld),hpux)
     SOFLAGS += -Wl,+h -Wl,$(SONAME)
   else
--- ACE_wrappers.orig/include/makeinclude/rules.lib.GNU	2010-09-23 18:17:42.000000000 +0200
+++ ACE_wrappers/include/makeinclude/rules.lib.GNU	2010-12-22 16:38:13.874115232 +0100
@@ -11,7 +11,7 @@
 #       Library versioning
 #---------------------------------------------------------------------------
 
-ifeq ($(versioned_so),1)
+ifneq ($(versioned_so),0)
   # Turn on symbol versioning. The scheme that we follow is to allow
   # applications dependent on libraries, with same version numbers (major,
   # minor and beta) to run, but applications with dependencies on libraries
@@ -20,13 +20,23 @@
   # Version number of the libraries
   #
   ifeq ($(SOVERSION),)
-    SOVERSION = .$(GNUACE_PROJECT_VERSION)
+    ifeq ($(versioned_so),1)
+      SOVERSION = .$(GNUACE_PROJECT_VERSION)
+    else ifeq ($(versioned_so),2)
+      SOVERSION = -$(GNUACE_PROJECT_VERSION)
+    else
+      $(error unknown value for versioned_so: $(versioned_so))
+    endif
   endif # SOVERSION
 
   # Name that will be written into the dynamic library
   #
   ifeq ($(SONAME),)
-    SONAME = $(SHLIB)$(SOVERSION)
+    ifeq ($(versioned_so),1)
+      SONAME = $(SHLIB)$(SOVERSION)
+    else ifeq ($(versioned_so),2)
+      SONAME = $(patsubst %.$(SOEXT),%,$(SHLIB))$(SOVERSION).$(SOEXT)
+    endif
   endif # SONAME
 endif # versioned_so
 
@@ -47,9 +57,15 @@
 # Setup shared library variables, including versions.
 VSHLIB_NO_VER = $(ARCH_SHLIB:%.$(SOEXT)=%$(VAR).$(SOEXT))
 CLEANUP_VSHLIB_NO_VER = $(CLEANUP_SHLIB:%.$(SOEXT)=%$(VAR).$(SOEXT))
-VSHLIB = $(VSHLIB_NO_VER:%=%$(SOVERSION))
-CLEANUP_VSHLIB = $(CLEANUP_VSHLIB_NO_VER:%=%$(SOVERSION))
-SHLIB_WITH_VER = $(SHLIB:%=%$(SOVERSION))
+ifneq ($(versioned_so),2)
+  VSHLIB = $(VSHLIB_NO_VER:%=%$(SOVERSION))
+  CLEANUP_VSHLIB = $(CLEANUP_VSHLIB_NO_VER:%=%$(SOVERSION))
+  SHLIB_WITH_VER = $(SHLIB:%=%$(SOVERSION))
+else
+  VSHLIB = $(patsubst %.$(SOEXT),%,$(VSHLIB_NO_VER))$(SOVERSION).$(SOEXT)
+  CLEANUP_VSHLIB = $(patsubst %.$(SOEXT),%,$(CLEANUP_VSHLIB_NO_VER))$(SOVERSION).$(SOEXT)
+  SHLIB_WITH_VER = $(patsubst %.$(SOEXT),%,$(SHLIB))$(SOVERSION).$(SOEXT)
+endif
 
 SHLIBA ?=
 VSHLIBA = $(ARCH_SHLIBA:%.$(LIBEXT)=%$(VAR).$(LIBEXT))
--- ACE_wrappers.orig/include/makeinclude/rules.local.GNU	2010-11-05 15:31:15.000000000 +0100
+++ ACE_wrappers/include/makeinclude/rules.local.GNU	2010-12-22 17:21:40.474300601 +0100
@@ -297,13 +297,23 @@
 	fi
     else #firstword of LN_S is not cp, so we're using real symlinks
       ifneq ($(SOVERSION),)
-	@if test $(ARCH_SOURCE_DIR) != $(@D) ; then \
+       ifneq ($(versioned_so),2)
+	    @if test $(ARCH_SOURCE_DIR) != $(@D) ; then \
 		if test ! -s $@ ; then \
 			$(RM) $(@:%.$(SOEXT)$(SOVERSION)=%.$(SOEXT)); \
 			echo $(LN_S) $(ARCH_SOURCE_DIR)/$(@F) $(@:%.$(SOEXT)$(SOVERSION)=%.$(SOEXT)); \
 			$(LN_S) $(ARCH_SOURCE_DIR)/$(@F) $(@:%.$(SOEXT)$(SOVERSION)=%.$(SOEXT)); \
 		fi ; \
-	fi
+	    fi
+       else
+	    @if test $(ARCH_SOURCE_DIR) != $(@D) ; then \
+		if test ! -s $@ ; then \
+			$(RM) $(@:%$(SOVERSION).$(SOEXT)=%.$(SOEXT)); \
+			echo $(LN_S) $(ARCH_SOURCE_DIR)/$(@F) $(@:%$(SOVERSION).$(SOEXT)=%.$(SOEXT)); \
+			$(LN_S) $(ARCH_SOURCE_DIR)/$(@F) $(@:%$(SOVERSION).$(SOEXT)=%.$(SOEXT)); \
+		fi ; \
+	    fi
+        endif #versioned_so
       endif #SOVERSION
 	@if test $(ARCH_SOURCE_DIR) != $(@D) ; then \
 		if test ! -s $@ ; then \
@@ -336,6 +346,8 @@
 	-$(RM) $(SHLIB_UNCHECKED)
 ifeq ($(versioned_so),1)
 	-$(RM) $(SHLIB_UNCHECKED)$(SOVERSION)
+else ifeq ($(versioned_so),2)
+	-$(RM) $(SHLIB_UNCHECKED:.$(SOEXT)=$(SOVERSION).$(SOEXT))
 endif
 endif
 
