summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct110
1 files changed, 64 insertions, 46 deletions
diff --git a/SConstruct b/SConstruct
index 7ee8fe74985..5082a4b3b65 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1423,18 +1423,6 @@ if env.TargetOSIs('posix'):
env.Append( LINKFLAGS=["-fstack-protector"] )
env.Append( SHLINKFLAGS=["-fstack-protector"] )
-if has_option( "ssl" ):
- env.SetConfigHeaderDefine("MONGO_CONFIG_SSL")
- env.Append( MONGO_CRYPTO=["openssl"] )
- if env.TargetOSIs('windows'):
- env.Append( LIBS=["libeay32"] )
- env.Append( LIBS=["ssleay32"] )
- else:
- env.Append( LIBS=["ssl"] )
- env.Append( LIBS=["crypto"] )
-else:
- env.Append( MONGO_CRYPTO=["tom"] )
-
wiredtiger = False
if get_option('wiredtiger') == 'on':
# Wiredtiger only supports 64-bit architecture, and will fail to compile on 32-bit
@@ -2213,6 +2201,70 @@ def doConfigure(myenv):
})
libdeps.setup_conftests(conf)
+ if has_option( "ssl" ):
+ sslLibName = "ssl"
+ cryptoLibName = "crypto"
+ if conf.env.TargetOSIs('windows'):
+ sslLibName = "ssleay32"
+ cryptoLibName = "libeay32"
+
+ if not conf.CheckLibWithHeader(
+ sslLibName,
+ ["openssl/ssl.h"],
+ "C",
+ "SSL_version(NULL);",
+ autoadd=True):
+ conf.env.ConfError("Couldn't find OpenSSL ssl.h header and library")
+
+ if not conf.CheckLibWithHeader(
+ cryptoLibName,
+ ["openssl/crypto.h"],
+ "C",
+ "SSLeay_version(0);",
+ autoadd=True):
+ conf.env.ConfError("Couldn't find OpenSSL crypto.h header and library")
+
+ def CheckLinkSSL(context):
+ test_body = """
+ #include <openssl/err.h>
+ #include <openssl/ssl.h>
+ #include <stdlib.h>
+
+ int main() {
+ SSL_library_init();
+ SSL_load_error_strings();
+ ERR_load_crypto_strings();
+
+ OpenSSL_add_all_algorithms();
+ ERR_free_strings();
+
+ return EXIT_SUCCESS;
+ }
+ """
+ context.Message("Checking that linking to OpenSSL works...")
+ ret = context.TryLink(textwrap.dedent(test_body), ".c")
+ context.Result(ret)
+ return ret
+
+ conf.AddTest("CheckLinkSSL", CheckLinkSSL)
+
+ if not conf.CheckLinkSSL():
+ conf.env.ConfError("SSL is enabled, but is unavailable")
+
+ env.SetConfigHeaderDefine("MONGO_CONFIG_SSL")
+ env.Append( MONGO_CRYPTO=["openssl"] )
+
+ if conf.CheckDeclaration(
+ "FIPS_mode_set",
+ includes="""
+ #include <openssl/crypto.h>
+ #include <openssl/evp.h>
+ """):
+ conf.env.SetConfigHeaderDefine('MONGO_CONFIG_HAVE_FIPS_MODE_SET')
+
+ else:
+ env.Append( MONGO_CRYPTO=["tom"] )
+
if use_system_version_of_library("pcre"):
conf.FindSysLibDep("pcre", ["pcre"])
conf.FindSysLibDep("pcrecpp", ["pcrecpp"])
@@ -2370,40 +2422,6 @@ def doConfigure(myenv):
# ask each module to configure itself and the build environment.
moduleconfig.configure_modules(mongo_modules, conf)
- def CheckLinkSSL(context):
- test_body = """
- #include <openssl/err.h>
- #include <openssl/ssl.h>
- #include <stdlib.h>
-
- int main() {
- SSL_library_init();
- SSL_load_error_strings();
- ERR_load_crypto_strings();
-
- OpenSSL_add_all_algorithms();
- ERR_free_strings();
- return EXIT_SUCCESS;
- }
- """
- context.Message("Checking if OpenSSL is available...")
- ret = context.TryLink(textwrap.dedent(test_body), ".c")
- context.Result(ret)
- return ret
- conf.AddTest("CheckLinkSSL", CheckLinkSSL)
-
- if has_option("ssl"):
- if not conf.CheckLinkSSL():
- conf.env.ConfError("SSL is enabled, but is unavailable")
-
- if conf.CheckDeclaration(
- "FIPS_mode_set",
- includes="""
- #include <openssl/crypto.h>
- #include <openssl/evp.h>
- """):
- conf.env.SetConfigHeaderDefine('MONGO_CONFIG_HAVE_FIPS_MODE_SET')
-
return conf.Finish()
env = doConfigure( env )