summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2015-12-28 15:30:21 -0500
committerJonathan Reams <jbreams@mongodb.com>2016-02-22 11:44:37 -0500
commite5f5b4ef8e6b6cf6f36af8d90ad08869d7274f30 (patch)
treeb713211a0403124254925984dbc004d7122aee5b
parent516450d7a25ae23e6dee38bf46cf64a31492d9b0 (diff)
downloadmongo-e5f5b4ef8e6b6cf6f36af8d90ad08869d7274f30.tar.gz
SERVER-22042 Use CheckLib to verify SSL library availabiliy
-rw-r--r--SConstruct114
1 files changed, 67 insertions, 47 deletions
diff --git a/SConstruct b/SConstruct
index 0d9de5a8d50..e8d1b083b64 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1155,18 +1155,6 @@ if "uname" in dir(os):
if hacks is not None:
hacks.insert( env , { "linux64" : linux64 } )
-if has_option( "ssl" ):
- env.Append( CPPDEFINES=["MONGO_SSL"] )
- env.Append( MONGO_CRYPTO=["openssl"] )
- if 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 = (get_option('wiredtiger') == 'on')
try:
@@ -2163,6 +2151,73 @@ def doConfigure(myenv):
conf = Configure(myenv)
libdeps.setup_conftests(conf)
+ if has_option( "ssl" ):
+ sslLibName = "ssl"
+ cryptoLibName = "crypto"
+ if 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")
+
+ conf.env.Append(
+ MONGO_CRYPTO=["openssl"],
+ CPPDEFINES=["MONGO_SSL"]
+ )
+
+ if conf.CheckDeclaration(
+ "FIPS_mode_set",
+ includes="""
+ #include <openssl/crypto.h>
+ #include <openssl/evp.h>
+ """):
+
+ conf.env.Append(CPPDEFINES=["MONGO_HAVE_FIPS_MODE_SET"])
+
+ else:
+ conf.env.Append( MONGO_CRYPTO=["tom"] )
+
if use_system_version_of_library("pcre"):
conf.FindSysLibDep("pcre", ["pcre"])
conf.FindSysLibDep("pcrecpp", ["pcrecpp"])
@@ -2283,41 +2338,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():
- print "SSL is enabled, but is unavailable"
- Exit(1)
-
- if conf.CheckDeclaration(
- "FIPS_mode_set",
- includes="""
- #include <openssl/crypto.h>
- #include <openssl/evp.h>
- """):
- conf.env.Append(CPPDEFINES=['MONGO_HAVE_FIPS_MODE_SET'])
-
return conf.Finish()
env = doConfigure( env )