From d81d2608c35bef14ba1fd024b0ec4d48de03dfcc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Sat, 30 Apr 2011 12:11:43 +0200
Subject: Split off libswiften package.


diff --git a/BuildTools/GetBuildVersion.py b/BuildTools/GetBuildVersion.py
index a362574..007fec8 100755
--- a/BuildTools/GetBuildVersion.py
+++ b/BuildTools/GetBuildVersion.py
@@ -1,9 +1,21 @@
 #!/usr/bin/env python
 
-import sys
+import sys, re
 sys.path.append("SCons")
 import Version, os.path
 
-assert(len(sys.argv) == 2)
+assert(len(sys.argv) >= 2)
 
-print Version.getBuildVersion(os.path.dirname(sys.argv[0] + "/.."), sys.argv[1])
+only_major = False
+if "--major" in sys.argv :
+  only_major = True
+
+if only_major :
+  v = Version.getBuildVersion(os.path.dirname(sys.argv[0] + "/.."), sys.argv[1])
+  version_match = re.match("(\d+)\.(\d+).*", v)
+  if version_match :
+    print version_match.group(1)
+  else :
+    print "0"
+else :
+  print Version.getBuildVersion(os.path.dirname(sys.argv[0] + "/.."), sys.argv[1])
diff --git a/Swift/Packaging/Debian/.gitignore b/Swift/Packaging/Debian/.gitignore
index d67fb54..5401ae0 100644
--- a/Swift/Packaging/Debian/.gitignore
+++ b/Swift/Packaging/Debian/.gitignore
@@ -1,2 +1,3 @@
 /swift-*
 /swift_*
+/libswiften*
diff --git a/Swift/Packaging/Debian/debian/control b/Swift/Packaging/Debian/debian/control
deleted file mode 100644
index ec4bb29..0000000
--- a/Swift/Packaging/Debian/debian/control
+++ /dev/null
@@ -1,23 +0,0 @@
-Source: swift-im
-Section: net
-Priority: optional
-Maintainer: Swift Package Maintainer <packages@swift.im>
-Build-Depends: debhelper (>= 7), scons (>= 1.2.0), libssl-dev (>= 0.9.8g), libqt4-dev (>= 4.5.0), libexpat1-dev (>= 2.0.1), lintian (>= 2.2.5), libxss-dev (>= 1.2.0), libboost-dev (>= 1.34.1), libboost-filesystem-dev (>= 1.34.1), libboost-program-options-dev (>= 1.34.1), libboost-regex-dev (>= 1.34.1), libboost-signals-dev (>= 1.34.1), libboost-system-dev (>= 1.34.1), libboost-thread-dev (>= 1.34.1), libboost-date-time-dev (>= 1.34.1), libidn11-dev (>= 1.10), docbook-xsl (>= 1.75.0), docbook-xml (>= 4.5), xsltproc, libxml2-utils
-Standards-Version: 3.8.4
-Homepage: http://swift.im
-
-Package: swift-im
-Architecture: any
-Section: net
-Priority: optional
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: XMPP Client.
-	The Swift IM client.
-
-Package: swift-im-dbg
-Architecture: any
-Section: debug
-Priority: optional
-Depends: swift-im (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
-Description: Debugging symbols for swift-im.
-	The Swift IM client.
diff --git a/Swift/Packaging/Debian/debian/control.in b/Swift/Packaging/Debian/debian/control.in
new file mode 100644
index 0000000..56428d4
--- /dev/null
+++ b/Swift/Packaging/Debian/debian/control.in
@@ -0,0 +1,39 @@
+Source: swift-im
+Section: net
+Priority: optional
+Maintainer: Swift Package Maintainer <packages@swift.im>
+Build-Depends: debhelper (>= 7), scons (>= 1.2.0), libssl-dev (>= 0.9.8g), libqt4-dev (>= 4.5.0), libexpat1-dev (>= 2.0.1), lintian (>= 2.2.5), libxss-dev (>= 1.2.0), libboost-dev (>= 1.34.1), libboost-filesystem-dev (>= 1.34.1), libboost-program-options-dev (>= 1.34.1), libboost-regex-dev (>= 1.34.1), libboost-signals-dev (>= 1.34.1), libboost-system-dev (>= 1.34.1), libboost-thread-dev (>= 1.34.1), libboost-date-time-dev (>= 1.34.1), libidn11-dev (>= 1.10), docbook-xsl (>= 1.75.0), docbook-xml (>= 4.5), xsltproc, libxml2-utils
+Standards-Version: 3.8.4
+Homepage: http://swift.im
+
+Package: libswiften%SWIFTEN_SOVERSION%
+Architecture: any
+Section: net
+Priority: optional
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: XMPP Library.
+	The Swiften XMPP library.
+
+Package: libswiften%SWIFTEN_SOVERSION%-dev
+Architecture: any
+Section: libdevel
+Priority: optional
+Depends: libswiften%SWIFTEN_SOVERSION% (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
+Description: XMPP Library.
+	The Swiften XMPP library.
+
+Package: swift-im
+Architecture: any
+Section: net
+Priority: optional
+Depends: libswiften%SWIFTEN_SOVERSION% (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
+Description: XMPP Client.
+	The Swift IM client.
+
+Package: swift-im-dbg
+Architecture: any
+Section: debug
+Priority: optional
+Depends: swift-im (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
+Description: Debugging symbols for swift-im.
+	The Swift IM client.
diff --git a/Swift/Packaging/Debian/debian/libswiften-dev.install b/Swift/Packaging/Debian/debian/libswiften-dev.install
new file mode 100644
index 0000000..84e0d21
--- /dev/null
+++ b/Swift/Packaging/Debian/debian/libswiften-dev.install
@@ -0,0 +1,4 @@
+usr/lib/libSwiften.so
+usr/lib/libSwiften.so.?.*
+usr/include
+usr/bin/swiften-config
diff --git a/Swift/Packaging/Debian/debian/libswiften.install b/Swift/Packaging/Debian/debian/libswiften.install
new file mode 100644
index 0000000..04f6608
--- /dev/null
+++ b/Swift/Packaging/Debian/debian/libswiften.install
@@ -0,0 +1 @@
+usr/lib/libSwiften.so.?
diff --git a/Swift/Packaging/Debian/debian/shlibs.in b/Swift/Packaging/Debian/debian/shlibs.in
new file mode 100644
index 0000000..9e80b9b
--- /dev/null
+++ b/Swift/Packaging/Debian/debian/shlibs.in
@@ -0,0 +1 @@
+libSwiften %SWIFTEN_SOVERSION% libswiften%SWIFTEN_SOVERSION%
diff --git a/Swift/Packaging/Debian/debian/swift-im.install b/Swift/Packaging/Debian/debian/swift-im.install
index d4cf441..3144192 100644
--- a/Swift/Packaging/Debian/debian/swift-im.install
+++ b/Swift/Packaging/Debian/debian/swift-im.install
@@ -1,3 +1,2 @@
 usr/bin/swift
 usr/share
-usr/lib/libSwiften.so.?
diff --git a/Swift/Packaging/Debian/package.sh b/Swift/Packaging/Debian/package.sh
index a7017c5..0cbc886 100755
--- a/Swift/Packaging/Debian/package.sh
+++ b/Swift/Packaging/Debian/package.sh
@@ -6,6 +6,7 @@ export PYTHONPATH=../../../BuildTools/SCons
 VERSION=`../../../BuildTools/GetBuildVersion.py swift`
 DEBIAN_VERSION=`../../../BuildTools/DebianizeVersion.py $VERSION`
 DIRNAME=swift-im-$DEBIAN_VERSION
+SWIFTEN_SOVERSION=`../../../BuildTools/GetBuildVersion.py swift --major`
 
 if [ -z "$DEBIAN_VERSION" ]; then
 	echo "Unable to determine version"
@@ -14,6 +15,7 @@ fi
 
 echo "Cleaning up old packages ..."
 rm -f swift-im_*
+rm -f libswiften*
 rm -rf swift-im-*
 
 echo "Checking out a fresh copy ..."
@@ -28,6 +30,10 @@ cp -r $DIRNAME/3rdParty/Boost/src/boost/uuid $DIRNAME/3rdParty/Boost/uuid/boost
 
 ln -s Swift/Packaging/Debian/debian $DIRNAME/debian
 ../../../BuildTools/UpdateDebianChangelog.py $DIRNAME/debian/changelog $DEBIAN_VERSION
+cat $DIRNAME/debian/control.in | sed -e "s/%SWIFTEN_SOVERSION%/$SWIFTEN_SOVERSION/g" > $DIRNAME/debian/control
+cat $DIRNAME/debian/shlibs.in | sed -e "s/%SWIFTEN_SOVERSION%/$SWIFTEN_SOVERSION/g" > $DIRNAME/debian/shlibs
+mv $DIRNAME/debian/libswiften.install $DIRNAME/debian/libswiften$SWIFTEN_SOVERSION.install
+mv $DIRNAME/debian/libswiften-dev.install $DIRNAME/debian/libswiften$SWIFTEN_SOVERSION-dev.install
 
 echo "Building ..."
 cd $DIRNAME
diff --git a/Swiften/SConscript b/Swiften/SConscript
index 641aadc..803ed8b 100644
--- a/Swiften/SConscript
+++ b/Swiften/SConscript
@@ -335,25 +335,29 @@ if env["SCONS_STAGE"] == "build" :
 	swiften_header = "#pragma once\n"
 	swiften_includes = []
 	top_path = env.Dir("..").abspath
-	public_dirs = ["Avatars", "Base", "Chat", "Client", "Component", "Disco", "Entity", "Elements", "JID", "MUC", "Network", "Parser", "Presence", "Queries", "Roster", "Serializer", "StringCodecs", "TLS", "VCards"]
-	for public_dir in public_dirs :
-		for root, dirs, files in os.walk(env.Dir(public_dir).abspath) :
-			if root.endswith("UnitTest") :
+	for root, dirs, files in os.walk(env.Dir(".").abspath) :
+		if root.endswith("UnitTest") :
+			continue
+		for file in files :
+			if not file.endswith(".h") :
 				continue
-			for file in files :
-				if not file.endswith(".h") :
-					continue
-				include = os.path.relpath(os.path.join(root, file), top_path)
-				swiften_includes.append(include)
-				if root.endswith("OpenSSL") :
-					continue
-				if file.startswith("CAres") or file.startswith("LibXML") or file.startswith("Expat") :
-					continue
-				swiften_header += "#include <" + include + ">\n"
-				swiften_includes.append(include)
-	for file in ["EventLoop/SimpleEventLoop.h"] :
-				swiften_header += "#include <Swiften/" + file + ">\n"		
-				swiften_includes.append("Swiften/" + file)
+			include = os.path.relpath(os.path.join(root, file), top_path)
+			swiften_includes.append(include)
+			# Private modules
+			if root.endswith("Config") or root.endswith("Compress") :
+				continue
+
+			# Library-specfifc private modules
+			if root.endswith("OpenSSL") or root.endswith("Cocoa") or root.endswith("Qt") or root.endswith("IDN") or root.endswith("Avahi") or root.endswith("Bonjour") :
+				continue
+
+			# Library-specific files
+			if file.startswith("CAres") or file.startswith("LibXML") or file.startswith("Expat") :
+				continue
+			if file == "Swiften.h" :
+				continue
+			swiften_header += "#include <" + include + ">\n"
+			swiften_includes.append(include)
 	swiften_env.WriteVal("Swiften.h", swiften_env.Value(swiften_header))
 	swiften_includes.append("Swiften/Swiften.h")
 
-- 
cgit v0.10.2-6-g49f6