diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2017-06-14 13:02:13 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2017-06-14 13:02:13 +0900 |
commit | 2be699e74a7e95b3ea16b041870ed01fd334805d (patch) | |
tree | cdbaec4935aaf155b83408b110112656fc4879a4 /ext/openssl | |
parent | 805882145bde3286d8fcfa1e6254be1522979ee7 (diff) | |
parent | ad5564f879b8ddea1cfddc5db3f7888d33d5ee1b (diff) | |
download | ruby-openssl-2be699e74a7e95b3ea16b041870ed01fd334805d.tar.gz |
Merge changes from Ruby trunk r56953..r58742
Commits that went to master are excluded.
* ruby-trunk r56953..r58742: (3 commits)
(r58742) Search SSL libraries by testing various filename patterns
(r57592) openssl: fix broken openssl check
(r57591) openssl: fix broken openssl check
Sync-with-trunk: r58742
Diffstat (limited to 'ext/openssl')
-rw-r--r-- | ext/openssl/deprecation.rb | 2 | ||||
-rw-r--r-- | ext/openssl/extconf.rb | 52 |
2 files changed, 47 insertions, 7 deletions
diff --git a/ext/openssl/deprecation.rb b/ext/openssl/deprecation.rb index 7dfc87c1..0c3ab628 100644 --- a/ext/openssl/deprecation.rb +++ b/ext/openssl/deprecation.rb @@ -3,7 +3,7 @@ module OpenSSL def self.deprecated_warning_flag unless flag = (@deprecated_warning_flag ||= nil) if try_compile("", flag = "-Werror=deprecated-declarations") - if with_config("broken-apple-openssl") + if /darwin/ =~ RUBY_PLATFORM and with_config("broken-apple-openssl") flag = "-Wno-deprecated-declarations" end $warnflags << " #{flag}" diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb index 60bd518e..250aabe4 100644 --- a/ext/openssl/extconf.rb +++ b/ext/openssl/extconf.rb @@ -36,17 +36,57 @@ have_library("socket", "socket") Logging::message "=== Checking for required stuff... ===\n" result = pkg_config("openssl") && have_header("openssl/ssl.h") -unless result + +def find_openssl_library if $mswin || $mingw # required for static OpenSSL libraries have_library("gdi32") # OpenSSL <= 1.0.2 (for RAND_screen()) have_library("crypt32") end - result = have_header("openssl/ssl.h") - result &&= %w[crypto libeay32].any? {|lib| have_library(lib, "CRYPTO_malloc")} - result &&= %w[ssl ssleay32].any? {|lib| have_library(lib, "SSL_new")} - unless result + return false unless have_header("openssl/ssl.h") + + libpath = $LIBPATH.dup + libpath |= ENV["LIB"].split(File::PATH_SEPARATOR).map{|d| d.tr(File::ALT_SEPARATOR, File::SEPARATOR)} if $mswin + + result = false + %w[crypto eay32].each do |base| + libs = [base] + if $mswin || $mingw + libs << "lib" + libs.first + if base == "crypto" + libs << libs.first + "-[0-9][0-9]" + libs << "lib" + libs.last + end + libs = Dir.glob(libs.map{|l| libpath.map{|d| File.join(d, l + ".*")}}.flatten).map{|path| File.basename(path, ".*")}.uniq + end + libs.each do |lib| + result = have_library(lib, "CRYPTO_malloc") + break if result + end + break if result + end + return false unless result + + %w[ssl ssleay32].each do |base| + libs = [base] + if $mswin || $mingw + libs << "lib" + libs.first + if base == "ssl" + libs << libs.first + "-[0-9][0-9]" + libs << "lib" + libs.last + end + libs = Dir.glob(libs.map{|l| libpath.map{|d| File.join(d, l + ".*")}}.flatten).map{|path| File.basename(path, ".*")}.uniq + end + libs.each do |lib| + return true if have_library(lib, "SSL_new") + end + end + return false +end + +unless result + unless find_openssl_library Logging::message "=== Checking for required stuff failed. ===\n" Logging::message "Makefile wasn't created. Fix the errors above.\n" exit 1 @@ -60,7 +100,7 @@ unless result raise "OpenSSL 0.9.8 or later required." end -unless OpenSSL.check_func("SSL_library_init()", "openssl/ssl.h") +if /darwin/ =~ RUBY_PLATFORM and !OpenSSL.check_func("SSL_library_init()", "openssl/ssl.h") raise "Ignore OpenSSL broken by Apple.\nPlease use another openssl. (e.g. using `configure --with-openssl-dir=/path/to/openssl')" end |