From 8a2f97f752c146a0e35b3640d57e517319fd924e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Wed, 2 Jun 2010 21:36:28 +0200
Subject: Detect & use system Boost version if present.


diff --git a/3rdParty/Boost/SConscript b/3rdParty/Boost/SConscript
index 94ce893..a7019e1 100644
--- a/3rdParty/Boost/SConscript
+++ b/3rdParty/Boost/SConscript
@@ -1,107 +1,113 @@
 Import("env")
 
-cppdefines = ["BOOST_ALL_NO_LIB"]
+if env.get("BOOST_BUNDLED", False) :
+
+################################################################################
+# Common
+################################################################################
+
+	cppdefines = ["BOOST_ALL_NO_LIB"]
 
 ################################################################################
 # Flags
 ################################################################################
 
-if env["SCONS_STAGE"] == "flags" :
-	env["BOOST_FLAGS"] = {
-			"CPPFLAGS": ["-I" + Dir("src").abspath],
-			"CPPDEFINES": cppdefines,
-			"LIBPATH": [Dir(".")],
-			"LIBS": ["Boost"]
-		}
-	if env["PLATFORM"] != "win32" :
-		env["BOOST_FLAGS"]["LIBS"] += ["pthread"]
-	else :
-		env["BOOST_FLAGS"]["CPPDEFINES"] += [("_WIN32_WINNT", "0x0501")]
-		if env["PLATFORM"] == "cygwin" :
-			env["BOOST_FLAGS"]["CPPDEFINES"] += ["__USE_W32_SOCKETS"]
+	if env["SCONS_STAGE"] == "flags" :
+		env["BOOST_FLAGS"] = {
+				"CPPFLAGS": ["-I" + Dir("src").abspath],
+				"CPPDEFINES": cppdefines,
+				"LIBPATH": [Dir(".")],
+				"LIBS": ["Boost"]
+			}
+		if env["PLATFORM"] != "win32" :
+			env["BOOST_FLAGS"]["LIBS"] += ["pthread"]
+		else :
+			env["BOOST_FLAGS"]["CPPDEFINES"] += [("_WIN32_WINNT", "0x0501")]
+			if env["PLATFORM"] == "cygwin" :
+				env["BOOST_FLAGS"]["CPPDEFINES"] += ["__USE_W32_SOCKETS"]
 
 ################################################################################
 # Build
 ################################################################################
 
-if env["SCONS_STAGE"] == "build" :
-	myenv = env.Clone()
-	myenv.Replace(CCFLAGS = [flag for flag in env["CCFLAGS"] if flag not in ["-W", "-Wall"]])
+	if env["SCONS_STAGE"] == "build" :
+		myenv = env.Clone()
+		myenv.Replace(CCFLAGS = [flag for flag in env["CCFLAGS"] if flag not in ["-W", "-Wall"]])
 
-	sources = [
-			"src/libs/date_time/src/gregorian/date_generators.cpp",
-			"src/libs/date_time/src/gregorian/greg_month.cpp",
-			"src/libs/date_time/src/gregorian/greg_weekday.cpp",
-			"src/libs/date_time/src/gregorian/gregorian_types.cpp",
-			"src/libs/date_time/src/posix_time/posix_time_types.cpp",
-			"src/libs/system/src/error_code.cpp",
-			"src/libs/thread/src/tss_null.cpp",
-			"src/libs/signals/src/connection.cpp",
-			"src/libs/signals/src/named_slot_map.cpp",
-			"src/libs/signals/src/signal_base.cpp",
-			"src/libs/signals/src/slot.cpp",
-			"src/libs/signals/src/trackable.cpp",
-			"src/libs/filesystem/src/operations.cpp",
-			"src/libs/filesystem/src/path.cpp",
-			"src/libs/filesystem/src/portability.cpp",
-			"src/libs/filesystem/src/utf8_codecvt_facet.cpp",
-			"src/libs/regex/src/c_regex_traits.cpp",
-			"src/libs/regex/src/cpp_regex_traits.cpp",
-			"src/libs/regex/src/cregex.cpp",
-			"src/libs/regex/src/fileiter.cpp",
-			"src/libs/regex/src/icu.cpp",
-			"src/libs/regex/src/instances.cpp",
-			"src/libs/regex/src/posix_api.cpp",
-			"src/libs/regex/src/regex.cpp",
-			"src/libs/regex/src/regex_debug.cpp",
-			"src/libs/regex/src/regex_raw_buffer.cpp",
-			"src/libs/regex/src/regex_traits_defaults.cpp",
-			"src/libs/regex/src/static_mutex.cpp",
-			"src/libs/regex/src/w32_regex_traits.cpp",
-			"src/libs/regex/src/wc_regex_traits.cpp",
-			"src/libs/regex/src/wide_posix_api.cpp",
-			"src/libs/regex/src/winstances.cpp",
-			"src/libs/regex/src/usinstances.cpp",
-			"src/libs/program_options/src/cmdline.cpp",
-			"src/libs/program_options/src/config_file.cpp",
-			"src/libs/program_options/src/convert.cpp",
-			"src/libs/program_options/src/options_description.cpp",
-			"src/libs/program_options/src/parsers.cpp",
-			"src/libs/program_options/src/positional_options.cpp",
-			"src/libs/program_options/src/split.cpp",
-			"src/libs/program_options/src/utf8_codecvt_facet.cpp",
-			"src/libs/program_options/src/value_semantic.cpp",
-			"src/libs/program_options/src/variables_map.cpp",
-			"src/libs/program_options/src/winmain.cpp"]
+		sources = [
+				"src/libs/date_time/src/gregorian/date_generators.cpp",
+				"src/libs/date_time/src/gregorian/greg_month.cpp",
+				"src/libs/date_time/src/gregorian/greg_weekday.cpp",
+				"src/libs/date_time/src/gregorian/gregorian_types.cpp",
+				"src/libs/date_time/src/posix_time/posix_time_types.cpp",
+				"src/libs/system/src/error_code.cpp",
+				"src/libs/thread/src/tss_null.cpp",
+				"src/libs/signals/src/connection.cpp",
+				"src/libs/signals/src/named_slot_map.cpp",
+				"src/libs/signals/src/signal_base.cpp",
+				"src/libs/signals/src/slot.cpp",
+				"src/libs/signals/src/trackable.cpp",
+				"src/libs/filesystem/src/operations.cpp",
+				"src/libs/filesystem/src/path.cpp",
+				"src/libs/filesystem/src/portability.cpp",
+				"src/libs/filesystem/src/utf8_codecvt_facet.cpp",
+				"src/libs/regex/src/c_regex_traits.cpp",
+				"src/libs/regex/src/cpp_regex_traits.cpp",
+				"src/libs/regex/src/cregex.cpp",
+				"src/libs/regex/src/fileiter.cpp",
+				"src/libs/regex/src/icu.cpp",
+				"src/libs/regex/src/instances.cpp",
+				"src/libs/regex/src/posix_api.cpp",
+				"src/libs/regex/src/regex.cpp",
+				"src/libs/regex/src/regex_debug.cpp",
+				"src/libs/regex/src/regex_raw_buffer.cpp",
+				"src/libs/regex/src/regex_traits_defaults.cpp",
+				"src/libs/regex/src/static_mutex.cpp",
+				"src/libs/regex/src/w32_regex_traits.cpp",
+				"src/libs/regex/src/wc_regex_traits.cpp",
+				"src/libs/regex/src/wide_posix_api.cpp",
+				"src/libs/regex/src/winstances.cpp",
+				"src/libs/regex/src/usinstances.cpp",
+				"src/libs/program_options/src/cmdline.cpp",
+				"src/libs/program_options/src/config_file.cpp",
+				"src/libs/program_options/src/convert.cpp",
+				"src/libs/program_options/src/options_description.cpp",
+				"src/libs/program_options/src/parsers.cpp",
+				"src/libs/program_options/src/positional_options.cpp",
+				"src/libs/program_options/src/split.cpp",
+				"src/libs/program_options/src/utf8_codecvt_facet.cpp",
+				"src/libs/program_options/src/value_semantic.cpp",
+				"src/libs/program_options/src/variables_map.cpp",
+				"src/libs/program_options/src/winmain.cpp"]
 
-	if env["PLATFORM"] != "win32" :
-		sources += [
-				"src/libs/thread/src/pthread/once.cpp",
-				"src/libs/thread/src/pthread/thread.cpp"]
-	else :
-		sources += [
-				"win32_stubs.cpp",
-				"src/libs/thread/src/win32/thread.cpp",
-				"src/libs/thread/src/win32/tss_dll.cpp",
-				"src/libs/thread/src/win32/tss_pe.cpp"]
+		if env["PLATFORM"] != "win32" :
+			sources += [
+					"src/libs/thread/src/pthread/once.cpp",
+					"src/libs/thread/src/pthread/thread.cpp"]
+		else :
+			sources += [
+					"win32_stubs.cpp",
+					"src/libs/thread/src/win32/thread.cpp",
+					"src/libs/thread/src/win32/tss_dll.cpp",
+					"src/libs/thread/src/win32/tss_pe.cpp"]
 
-	myenv.StaticLibrary("Boost", sources, CPPFLAGS = "-I" + Dir("src").abspath, CPPDEFINES = cppdefines)
+		myenv.StaticLibrary("Boost", sources, CPPFLAGS = "-I" + Dir("src").abspath, CPPDEFINES = cppdefines)
 
-	if ARGUMENTS.get("BOOST_BUILD_BCP") or env.GetOption("clean") :
-		bcp_env = myenv.Clone()
-		bcp_env.MergeFlags(bcp_env["BOOST_FLAGS"])
-		bcp_env.Append(CPPPATH = ["src/tools/bcp"])
-		bcp_env.Program("bcp", [
-				"src/tools/bcp/add_path.cpp",
-				"src/tools/bcp/add_dependent_lib.cpp",
-				"src/tools/bcp/bcp_imp.cpp",
-				"src/tools/bcp/copy_path.cpp",
-				"src/tools/bcp/file_types.cpp",
-				"src/tools/bcp/fileview.cpp",
-				"src/tools/bcp/licence_info.cpp",
-				"src/tools/bcp/output_licence_info.cpp",
-				"src/tools/bcp/path_operations.cpp",
-				"src/tools/bcp/scan_cvs_path.cpp",
-				"src/tools/bcp/scan_licence.cpp",
-				"bcp.cpp",
-			])
+		if ARGUMENTS.get("BOOST_BUILD_BCP") or env.GetOption("clean") :
+			bcp_env = myenv.Clone()
+			bcp_env.MergeFlags(bcp_env["BOOST_FLAGS"])
+			bcp_env.Append(CPPPATH = ["src/tools/bcp"])
+			bcp_env.Program("bcp", [
+					"src/tools/bcp/add_path.cpp",
+					"src/tools/bcp/add_dependent_lib.cpp",
+					"src/tools/bcp/bcp_imp.cpp",
+					"src/tools/bcp/copy_path.cpp",
+					"src/tools/bcp/file_types.cpp",
+					"src/tools/bcp/fileview.cpp",
+					"src/tools/bcp/licence_info.cpp",
+					"src/tools/bcp/output_licence_info.cpp",
+					"src/tools/bcp/path_operations.cpp",
+					"src/tools/bcp/scan_cvs_path.cpp",
+					"src/tools/bcp/scan_licence.cpp",
+					"bcp.cpp",
+				])
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index 6e98e87..9e79c4c 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -269,19 +269,20 @@ else :
 	env["LIBIDN_BUNDLED"] = 1
 
 # Boost
-# NOTE: We can't use the system boost, because of 'signals' (which we
-# redefine as signals2 for avoiding Qt clashes)
-#boostLibs = ["boost_signals", "boost_thread", "boost_program_options", "boost_filesystem"]
-#if conf.CheckCHeader("boost/foreach.hpp") and conf.CheckCHeader("boost/signals.hpp") and conf.CheckCHeader("boost/thread.hpp") and conf.CheckCHeader("boost/program_options.hpp") and Conf.CheckCHeader("boost/filesystem.hpp") :
-#	allLibsPresent = True
-#	for lib in boostLibs :
-#		if not env.CheckLib(lib) :
-#			allLibsPresent = False
-#			break
-#	if allLibsPresent :
-#		env["BOOST_FLAGS"] = { "LIBS": [boostLibs] }
-#	else :
-#		env["BOOST_BUNDLED"] = True
+boostLibs = [("signals", None), ("thread", None), ("regex", None), ("program_options", None), ("filesystem", None), ("system", "system/system_error.hpp"), ("date_time", "date_time/date.hpp")]
+allLibsPresent = True
+for (lib, header) in boostLibs :
+	if header :
+		header = "boost/" + header
+	else :
+		header = "boost/" + lib + ".hpp"
+	if not conf.CheckCXXHeader(header) or not conf.CheckLib("boost_" + lib) :
+		allLibsPresent = False
+		break
+if allLibsPresent :
+	env["BOOST_FLAGS"] = { "LIBS": ["boost_" + lib for lib, header in boostLibs] }
+else :
+	env["BOOST_BUNDLED"] = True
 
 # Avahi
 if env["PLATFORM"] != "darwin" :
diff --git a/Swift/Packaging/Debian/debian/control b/Swift/Packaging/Debian/debian/control
index bb63afe..43cb655 100644
--- a/Swift/Packaging/Debian/debian/control
+++ b/Swift/Packaging/Debian/debian/control
@@ -2,7 +2,7 @@ Source: swift
 Section: x11
 Priority: optional
 Maintainer: Remko Tronçon <dev@el-tramo.be>
-Build-Depends: debhelper (>= 7), scons (>= 1.2.0), libssl-dev (>= 0.9.8k), libqt4-dev (>= 4.5.3), libexpat1-dev (>= 2.0.1), lintian (>= 2.3.4), libxss-dev (>= 1.2.0), libboost-dev (>= 1.40.0), libboost-filesystem-dev (>= 1.40.0), libboost-program-options-dev (>= 1.40.0), libboost-regex-dev (>= 1.40.0), libboost-signals-dev (>= 1.40.0), libboost-system-dev (>= 1.40.0), libboost-thread-dev (>= 1.40.0), libidn11-dev (>= 1.15)
+Build-Depends: debhelper (>= 7), scons (>= 1.2.0), libssl-dev (>= 0.9.8k), libqt4-dev (>= 4.5.3), libexpat1-dev (>= 2.0.1), lintian (>= 2.3.4), libxss-dev (>= 1.2.0), libboost-dev (>= 1.40.0), libboost-filesystem-dev (>= 1.40.0), libboost-program-options-dev (>= 1.40.0), libboost-regex-dev (>= 1.40.0), libboost-signals-dev (>= 1.40.0), libboost-system-dev (>= 1.40.0), libboost-thread-dev (>= 1.40.0), libboost-date-time-dev (>= 1.40.0), libidn11-dev (>= 1.15)
 Standards-Version: 3.8.4
 Homepage: http://swift.im
 
-- 
cgit v0.10.2-6-g49f6