From 701843a2ee1ef8d40097a8d3682c725348807a76 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Mon, 10 Aug 2009 23:45:30 +0200
Subject: Add --with-openssl scons flag.


diff --git a/SConstruct b/SConstruct
index 6e52bc5..c5f8506 100644
--- a/SConstruct
+++ b/SConstruct
@@ -98,6 +98,12 @@ if env["PLATFORM"] == "win32" :
 
 
 ################################################################################
+# Configuration options
+################################################################################
+
+AddOption("--with-openssl", dest="openssl_prefix", type="string", nargs=1, action="store", metavar="DIR", help="OpenSSL installation prefix")
+
+################################################################################
 # Platform configuration
 ################################################################################
 
@@ -106,14 +112,6 @@ conf = Configure(conf_env)
 if conf.CheckCHeader("pthread.h") :
 	env["HAVE_PTHREAD"] = 1
 
-if conf.CheckCHeader("openssl/ssl.h") :
-	env["HAVE_OPENSSL"] = 1
-	env["OPENSSL_FLAGS"] = {
-			"LIBS": ["ssl", "crypto"]
-		}
-else :
-	env["OPENSSL_FLAGS"] = ""
-
 if conf.CheckLib("z") :
 	env.Append(LIBS = "z")
 	env["ZLIB_FLAGS"] = ""
@@ -143,6 +141,29 @@ if not env.get("HAVE_EXPAT", 0) :
 	env["HAVE_EXPAT"] = 1
 	bundledExpat = True
 
+# OpenSSL
+openssl_env = conf_env.Clone()
+openssl_prefix = GetOption("openssl_prefix")
+if openssl_prefix :
+	openssl_flags = { "CPPPATH": [os.path.join(openssl_prefix, "include")] }
+	if env["PLATFORM"] == "win32" : 
+		openssl_flags["LIBPATH"] = [os.path.join(openssl_prefix, "lib", "VC")]
+	else :
+		openssl_flags["LIBPATH"] = [os.path.join(openssl_prefix, "lib")]
+	openssl_env.MergeFlags(openssl_flags)
+
+openssl_conf = Configure(openssl_env)
+if openssl_conf.CheckCHeader("openssl/ssl.h") :
+	env["HAVE_OPENSSL"] = 1
+	env["OPENSSL_FLAGS"] = openssl_flags
+	if env["PLATFORM"] == "win32" : 
+		env["OPENSSL_FLAGS"]["LIBS"] = ["libeay32MT", "ssleay32MT"]
+	else:
+		env["OPENSSL_FLAGS"]["LIBS"] = ["ssl", "crypto"]
+else :
+	env["OPENSSL_FLAGS"] = ""
+openssl_conf.Finish()
+
 
 ################################################################################
 # Project files
diff --git a/Swiften/SConscript b/Swiften/SConscript
index eac3084..60f2fbc 100644
--- a/Swiften/SConscript
+++ b/Swiften/SConscript
@@ -11,6 +11,7 @@ myenv.MergeFlags(env["LIBIDN_FLAGS"])
 myenv.MergeFlags(env["SQLITE_FLAGS"])
 myenv.MergeFlags(env["EXPAT_FLAGS"])
 myenv.MergeFlags(env["ZLIB_FLAGS"])
+myenv.MergeFlags(env["OPENSSL_FLAGS"])
 
 sources = [
 		"Application/Application.cpp",
-- 
cgit v0.10.2-6-g49f6