From bf9cfb6aa5bda0a33da6dfc12ef49321500256ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Sun, 29 Aug 2010 20:06:03 +0200
Subject: Put platform flags in PLATFORM_FLAGS variable.

This should avoid problems with --as-needed.

Resolves: #547

diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index 98feccd..5a64f2d 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -47,6 +47,9 @@ env = Environment(CPPPATH = "#", ENV = {
 
 Help(vars.GenerateHelpText(env))
 
+# Default environment variables
+env["PLATFORM_FLAGS"] = {}
+
 # Default custom tools
 env.Tool("Test", toolpath = ["#/BuildTools/SCons/Tools"])
 env.Tool("WriteVal", toolpath = ["#/BuildTools/SCons/Tools"])
@@ -275,16 +278,15 @@ if not conf.CheckCXX() or not conf.CheckCC() :
 
 env["HAVE_ZLIB"] = True
 if conf.CheckLib("z") :
-	env.Append(LIBS = "z")
-	env["ZLIB_FLAGS"] = ""
+	env["ZLIB_FLAGS"] = {"LIBS": ["z"]}
 else :
 	env["ZLIB_BUNDLED"] = True
 
-if conf.CheckLib("c") :
-	env.Append(LIBS = ["c"])
-
 if conf.CheckLib("resolv") :
-	env.Append(LIBS = ["resolv"])
+	env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["resolv"]
+
+if conf.CheckLib("c") :
+	env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["c"]
 
 # LibIDN
 if conf.CheckCHeader("idna.h") and conf.CheckLib("idn") :
diff --git a/QA/UnitTest/SConscript b/QA/UnitTest/SConscript
index d47474d..b5f382c 100644
--- a/QA/UnitTest/SConscript
+++ b/QA/UnitTest/SConscript
@@ -20,6 +20,7 @@ if env["TEST"] :
 		myenv.MergeFlags(env.get("LIBXML_FLAGS", ""))
 		myenv.MergeFlags(env.get("EXPAT_FLAGS", ""))
 		myenv.MergeFlags(env.get("ZLIB_FLAGS", ""))
+		myenv.MergeFlags(env["PLATFORM_FLAGS"])
 		if env.get("HAVE_LIBXML") :
 			myenv.Append(CPPDEFINES = ["HAVE_LIBXML"])
 		if env.get("HAVE_EXPAT") :
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 0d043fb..f119397 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -35,6 +35,7 @@ myenv.MergeFlags(env["ZLIB_FLAGS"])
 myenv.MergeFlags(env["OPENSSL_FLAGS"])
 myenv.MergeFlags(env.get("LIBXML_FLAGS", ""))
 myenv.MergeFlags(env.get("EXPAT_FLAGS", ""))
+myenv.MergeFlags(myenv["PLATFORM_FLAGS"])
 
 myenv.Tool("qt4", toolpath = ["#/BuildTools/SCons/Tools"])
 myenv.Tool("nsis", toolpath = ["#/BuildTools/SCons/Tools"])
diff --git a/Swiften/Examples/ConnectivityTest/SConscript b/Swiften/Examples/ConnectivityTest/SConscript
index 6563ded..f66c57f 100644
--- a/Swiften/Examples/ConnectivityTest/SConscript
+++ b/Swiften/Examples/ConnectivityTest/SConscript
@@ -9,4 +9,5 @@ myenv.MergeFlags(myenv["ZLIB_FLAGS"])
 myenv.MergeFlags(myenv["OPENSSL_FLAGS"])
 myenv.MergeFlags(myenv.get("LIBXML_FLAGS", ""))
 myenv.MergeFlags(myenv.get("EXPAT_FLAGS", ""))
+myenv.MergeFlags(myenv["PLATFORM_FLAGS"])
 tester = myenv.Program("ConnectivityTest", ["ConnectivityTest.cpp"])
diff --git a/Swiften/Examples/SendMessage/SConscript b/Swiften/Examples/SendMessage/SConscript
index bc9bde2..05ab4c3 100644
--- a/Swiften/Examples/SendMessage/SConscript
+++ b/Swiften/Examples/SendMessage/SConscript
@@ -9,4 +9,5 @@ myenv.MergeFlags(myenv["OPENSSL_FLAGS"])
 myenv.MergeFlags(myenv.get("SQLITE_FLAGS", {}))
 myenv.MergeFlags(myenv.get("LIBXML_FLAGS", ""))
 myenv.MergeFlags(myenv.get("EXPAT_FLAGS", ""))
+myenv.MergeFlags(myenv["PLATFORM_FLAGS"])
 tester = myenv.Program("SendMessage", ["SendMessage.cpp"])
-- 
cgit v0.10.2-6-g49f6