From 7ef27db79a528263b17610444f4f85bafd0fa6fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Thu, 25 Apr 2013 21:42:16 +0200
Subject: swiften-config improvements.

Allow --libs and --cflags to be used in the same command.
Include Boost flags in --cflags.
Add documentation for using swiften-config with SCons.

Change-Id: I36d78cdecab7c2b7b6ef7861e09a43964357f23d

diff --git a/Documentation/SwiftenDevelopersGuide/Swiften Developers Guide.xml b/Documentation/SwiftenDevelopersGuide/Swiften Developers Guide.xml
index fae79e4..345d049 100644
--- a/Documentation/SwiftenDevelopersGuide/Swiften Developers Guide.xml	
+++ b/Documentation/SwiftenDevelopersGuide/Swiften Developers Guide.xml	
@@ -117,6 +117,21 @@
         whereas calling it with the <literal>--cflags</literal> option will return the
         list of C(++) compiler flags.
       </para>
+
+      <para>
+        An example of setting up a build of a Swiften application using SCons is shown
+        in <xref linkend="Example-SCons"/>.
+      </para>
+
+      <example id="Example-SCons">
+        <title><literal>SConstruct</literal> file to build Swiften application with SCons</title>
+        <programlisting>
+env = Environment()
+env["SWIFTEN_CONFIG"] = "/path/to/swiften-config"
+env.MergeFlags(env.subst("!$SWIFTEN_CONFIG --cflags --libs"))
+env.Program("EchoBot.cpp")
+        </programlisting>
+      </example>
     </sect1>
 
     <sect1>
diff --git a/Swiften/Config/SConscript b/Swiften/Config/SConscript
index 691e9e5..27dfc2e 100644
--- a/Swiften/Config/SConscript
+++ b/Swiften/Config/SConscript
@@ -20,7 +20,10 @@ swiften_env = env.Clone()
 swiften_env.UseFlags(swiften_env["SWIFTEN_FLAGS"])
 swiften_env.UseFlags(swiften_env["SWIFTEN_DEP_FLAGS"])
 
-cppflags = replaceSwiftenPath(" ".join([swiften_env.subst("$_CPPDEFFLAGS"), swiften_env.subst("$_CPPINCFLAGS")]))
+cppflags = replaceSwiftenPath(" ".join([
+	swiften_env.subst("$CPPFLAGS").replace("-isystem ","-I"),
+	swiften_env.subst("$_CPPDEFFLAGS"), 
+	swiften_env.subst("$_CPPINCFLAGS")]))
 config_flags += cStringVariable(swiften_env, "CPPFLAGS", cppflags)
 
 libflags = replaceSwiftenPath(" ".join([
diff --git a/Swiften/Config/swiften-config.cpp b/Swiften/Config/swiften-config.cpp
index de07d74..89df9cd 100644
--- a/Swiften/Config/swiften-config.cpp
+++ b/Swiften/Config/swiften-config.cpp
@@ -118,7 +118,7 @@ int main(int argc, char* argv[]) {
 	if (vm.count("libs") > 0) {
 		printFlags(libs);
 	}
-	else if (vm.count("cflags") > 0) {
+	if (vm.count("cflags") > 0) {
 		printFlags(cflags);
 	}
 	return 0;
-- 
cgit v0.10.2-6-g49f6