update OpenSSL detection / testing
@@ -29,17 +29,34 @@ else
puts 'using an unknown (old?) compiler... who knows if this will work out... we hope.'
end
-
# Test for OpenSSL version equal to 1.0.0 or greater.
-unless ENV['NO_SSL']
+unless ENV['NO_SSL'] || ENV['NO_TLS'] || ENV["DISABLE_SSL"]
+ OPENSSL_TEST_CODE = <<EOS
+\#include <openssl/bio.h>
+\#include <openssl/err.h>
+\#include <openssl/ssl.h>
+\#if OPENSSL_VERSION_NUMBER < 0x10100000L
+\#error "OpenSSL version too small"
+\#endif
+int main(void) {
+ SSL_library_init();
+ SSL_CTX *ctx = SSL_CTX_new(TLS_method());
+ SSL *ssl = SSL_new(ctx);
+ BIO *bio = BIO_new_socket(3, 0);
+ BIO_up_ref(bio);
+ SSL_set0_rbio(ssl, bio);
+ SSL_set0_wbio(ssl, bio);
+}
+EOS
+
+ dir_config("openssl")
begin
require 'openssl'
rescue LoadError
else
if have_library('crypto') && have_library('ssl')
- puts "Detected OpenSSL library, testing for version."
- if try_compile("\#include <openssl/ssl.h>\r\#if OPENSSL_VERSION_NUMBER < 0x10100000L\r\#error \"OpenSSL version too small\"\r\#endif\rint main(void) { SSL_library_init(); }")
- # if ((OpenSSL::OPENSSL_VERSION_NUMBER >> 24) > 16) || (((OpenSSL::OPENSSL_VERSION_NUMBER >> 24) == 16) && (((OpenSSL::OPENSSL_VERSION_NUMBER >> 16) & 255) >= 16))
+ puts "Detected OpenSSL library, testing for version and required functions."
+ if try_compile(OPENSSL_TEST_CODE)
$defs << "-DHAVE_OPENSSL"
puts "Confirmed OpenSSL to be version 1.1.0 or above (#{OpenSSL::OPENSSL_LIBRARY_VERSION})...\n* Compiling with HAVE_OPENSSL."
else
@@ -54,6 +71,4 @@ RbConfig::MAKEFILE_CONFIG['CFLAGS'] = $CFLAGS = "-std=c11 -DFIO_PRINT_STATE=0 #{
RbConfig::MAKEFILE_CONFIG['CC'] = $CC = ENV['CC'] if ENV['CC']
RbConfig::MAKEFILE_CONFIG['CPP'] = $CPP = ENV['CPP'] if ENV['CPP']
-# abort "Missing OpenSSL." unless have_library("ssl")
-
create_makefile 'iodine/iodine'
