MinGW: OpenSSL support
authorBert Belder <bertbelder@gmail.com>
Wed, 16 Feb 2011 04:09:02 +0000 (05:09 +0100)
committerRyan Dahl <ry@tinyclouds.org>
Wed, 16 Feb 2011 04:15:46 +0000 (20:15 -0800)
wscript

diff --git a/wscript b/wscript
index 53d1e50..a13b91b 100644 (file)
--- a/wscript
+++ b/wscript
@@ -4,7 +4,7 @@ import Options
 import sys, os, shutil, glob
 import Utils
 from Utils import cmd_output
-from os.path import join, dirname, abspath
+from os.path import join, dirname, abspath, normpath
 from logging import fatal
 
 cwd = os.getcwd()
@@ -101,6 +101,20 @@ def set_options(opt):
                 , dest='shared_v8_libname'
                 )
 
+  opt.add_option( '--openssl-includes'
+                , action='store'
+                , default=False
+                , help='A directory to search for the OpenSSL includes'
+                , dest='openssl_includes'
+                )
+
+  opt.add_option( '--openssl-libpath'
+                , action='store'
+                , default=False
+                , help="A directory to search for the OpenSSL libraries"
+                , dest='openssl_libpath'
+                )
+
   opt.add_option( '--oprofile'
                 , action='store_true'
                 , default=False
@@ -247,17 +261,44 @@ def configure(conf):
       Options.options.use_openssl = conf.env["USE_OPENSSL"] = True
       conf.env.append_value("CPPFLAGS", "-DHAVE_OPENSSL=1")
     else:
-      libssl = conf.check_cc(lib=['ssl', 'crypto'],
+      if o.openssl_libpath: 
+        openssl_libpath = [o.openssl_libpath]
+      elif not sys.platform.startswith('win32'):
+        openssl_libpath = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/usr/sfw/lib']
+      else:
+        openssl_libpath = [normpath(join(cwd, '../openssl'))]
+
+      if o.openssl_includes: 
+        openssl_includes = [o.openssl_includes]
+      elif not sys.platform.startswith('win32'):
+        openssl_includes = [];
+      else:
+        openssl_includes = [normpath(join(cwd, '../openssl/include'))];
+
+      openssl_lib_names = ['ssl', 'crypto']
+      if sys.platform.startswith('win32'):
+        openssl_lib_names += ['ws2_32', 'gdi32']
+
+      libssl = conf.check_cc(lib=openssl_lib_names,
                              header_name='openssl/ssl.h',
                              function_name='SSL_library_init',
-                             libpath=['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/usr/sfw/lib'],
+                             includes=openssl_includes,
+                             libpath=openssl_libpath,
                              uselib_store='OPENSSL')
+
       libcrypto = conf.check_cc(lib='crypto',
                                 header_name='openssl/crypto.h',
+                                includes=openssl_includes,
+                                libpath=openssl_libpath,
                                 uselib_store='OPENSSL')
+
       if libcrypto and libssl:
         conf.env["USE_OPENSSL"] = Options.options.use_openssl = True
         conf.env.append_value("CPPFLAGS", "-DHAVE_OPENSSL=1")
+      elif sys.platform.startswith('win32'):
+        conf.fatal("Could not autodetect OpenSSL support. " +
+                   "Use the --openssl-libpath and --openssl-includes options to set the search path. " +
+                   "Use configure --without-ssl to disable this message.")
       else:
         conf.fatal("Could not autodetect OpenSSL support. " +
                    "Make sure OpenSSL development packages are installed. " +