|
36 | 36 |
|
37 | 37 | Logging::message "=== Checking for required stuff... ===\n" |
38 | 38 | result = pkg_config("openssl") && have_header("openssl/ssl.h") |
39 | | -unless result |
| 39 | + |
| 40 | +def find_openssl_library |
40 | 41 | if $mswin || $mingw |
41 | 42 | # required for static OpenSSL libraries |
42 | 43 | have_library("gdi32") # OpenSSL <= 1.0.2 (for RAND_screen()) |
43 | 44 | have_library("crypt32") |
44 | 45 | end |
45 | 46 |
|
46 | | - result = %w[crypto libeay32].any? {|lib| have_library(lib, "CRYPTO_malloc")} |
47 | | - result &&= %w[ssl ssleay32].any? {|lib| have_library(lib, "SSL_new")} |
48 | | - unless result |
| 47 | + return false unless have_header("openssl/ssl.h") |
| 48 | + |
| 49 | + ret = have_library("crypto", "CRYPTO_malloc") && |
| 50 | + have_library("ssl", "SSL_new") |
| 51 | + return ret if ret |
| 52 | + |
| 53 | + if $mswin |
| 54 | + # OpenSSL >= 1.1.0: libcrypto.lib and libssl.lib. |
| 55 | + if have_library("libcrypto", "CRYPTO_malloc") && |
| 56 | + have_library("libssl", "SSL_new") |
| 57 | + return true |
| 58 | + end |
| 59 | + |
| 60 | + # OpenSSL <= 1.0.2: libeay32.lib and ssleay32.lib. |
| 61 | + if have_library("libeay32", "CRYPTO_malloc") && |
| 62 | + have_library("ssleay32", "SSL_new") |
| 63 | + return true |
| 64 | + end |
| 65 | + |
| 66 | + # LibreSSL: libcrypto-##.lib and libssl-##.lib, where ## is the ABI version |
| 67 | + # number. We have to find the version number out by scanning libpath. |
| 68 | + libpath = $LIBPATH.dup |
| 69 | + libpath |= ENV["LIB"].split(File::PATH_SEPARATOR) |
| 70 | + libpath.map! { |d| d.tr(File::ALT_SEPARATOR, File::SEPARATOR) } |
| 71 | + |
| 72 | + ret = [ |
| 73 | + ["crypto", "CRYPTO_malloc"], |
| 74 | + ["ssl", "SSL_new"] |
| 75 | + ].all? do |base, func| |
| 76 | + result = false |
| 77 | + libs = ["lib#{base}-[0-9][0-9]", "lib#{base}-[0-9][0-9][0-9]"] |
| 78 | + libs = Dir.glob(libs.map{|l| libpath.map{|d| File.join(d, l + ".*")}}.flatten).map{|path| File.basename(path, ".*")}.uniq |
| 79 | + libs.each do |lib| |
| 80 | + result = have_library(lib, func) |
| 81 | + break if result |
| 82 | + end |
| 83 | + result |
| 84 | + end |
| 85 | + return ret if ret |
| 86 | + end |
| 87 | + return false |
| 88 | +end |
| 89 | + |
| 90 | +unless result |
| 91 | + unless find_openssl_library |
| 92 | + Logging::message "=== Checking for required stuff failed. ===\n" |
| 93 | + Logging::message "Makefile wasn't created. Fix the errors above.\n" |
49 | 94 | raise "OpenSSL library could not be found. You might want to use " \ |
50 | 95 | "--with-openssl-dir=<dir> option to specify the prefix where OpenSSL " \ |
51 | 96 | "is installed." |
52 | 97 | end |
53 | | - unless have_header("openssl/ssl.h") |
54 | | - raise "OpenSSL library itself was found, but the necessary header files " \ |
55 | | - "are missing. Installing \"development package\" of OpenSSL on your " \ |
56 | | - "system might help." |
57 | | - end |
58 | 98 | end |
59 | 99 |
|
60 | 100 | unless checking_for("OpenSSL version is 1.0.1 or later") { |
|
0 commit comments