Skip to content

Commit 26e258c

Browse files
committed
* ext/digest/*/extconf.rb: use pkg_config to use same library with
openssl. [ruby-core:44755][Bug ruby#6379] * ext/openssl/deprecation.rb: extract check for broken Apple OpenSSL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 0f1181a commit 26e258c

File tree

7 files changed

+38
-22
lines changed

7 files changed

+38
-22
lines changed

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Tue May 1 06:03:34 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* ext/digest/*/extconf.rb: use pkg_config to use same library with
4+
openssl. [ruby-core:44755][Bug #6379]
5+
6+
* ext/openssl/deprecation.rb: extract check for broken Apple OpenSSL.
7+
18
Tue May 1 05:02:30 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
29

310
* configure.in (optflags): disable unsafe optimizations.

ext/digest/md5/extconf.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
$objs = [ "md5init.#{$OBJEXT}" ]
1010

1111
dir_config("openssl")
12+
pkg_config("openssl")
13+
require_relative '../../openssl/deprecation'
1214

1315
if !with_config("bundled-md5") &&
14-
have_library("crypto") && have_header("openssl/md5.h")
16+
have_library("crypto") && OpenSSL.check_func("MD5_Transform", "openssl/md5.h")
1517
$objs << "md5ossl.#{$OBJEXT}"
1618

1719
else
@@ -22,7 +24,4 @@
2224

2325
$preload = %w[digest]
2426

25-
if try_compile("", flag = " -Wno-deprecated-declarations")
26-
$warnflags << flag
27-
end
2827
create_makefile("digest/md5")

ext/digest/rmd160/extconf.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
$objs = [ "rmd160init.#{$OBJEXT}" ]
1010

1111
dir_config("openssl")
12+
pkg_config("openssl")
13+
require_relative '../../openssl/deprecation'
1214

1315
if !with_config("bundled-rmd160") &&
14-
have_library("crypto") && have_header("openssl/ripemd.h")
16+
have_library("crypto") && OpenSSL.check_func("RMD160_Transform", "openssl/ripemd.h")
1517
$objs << "rmd160ossl.#{$OBJEXT}"
1618
else
1719
$objs << "rmd160.#{$OBJEXT}"
@@ -21,7 +23,4 @@
2123

2224
$preload = %w[digest]
2325

24-
if try_compile("", flag = " -Wno-deprecated-declarations")
25-
$warnflags << flag
26-
end
2726
create_makefile("digest/rmd160")

ext/digest/sha1/extconf.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
$objs = [ "sha1init.#{$OBJEXT}" ]
1010

1111
dir_config("openssl")
12+
pkg_config("openssl")
13+
require_relative '../../openssl/deprecation'
1214

1315
if !with_config("bundled-sha1") &&
14-
have_library("crypto") && have_header("openssl/sha.h")
16+
have_library("crypto") && OpenSSL.check_func("SHA1_Transform", "openssl/sha.h")
1517
$objs << "sha1ossl.#{$OBJEXT}"
1618
else
1719
$objs << "sha1.#{$OBJEXT}"
@@ -21,7 +23,4 @@
2123

2224
$preload = %w[digest]
2325

24-
if try_compile("", flag = " -Wno-deprecated-declarations")
25-
$warnflags << flag
26-
end
2726
create_makefile("digest/sha1")

ext/digest/sha2/extconf.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
$objs = [ "sha2init.#{$OBJEXT}" ]
1010

1111
dir_config("openssl")
12+
pkg_config("openssl")
13+
require_relative '../../openssl/deprecation'
1214

1315
if !with_config("bundled-sha2") &&
1416
have_library("crypto") &&
15-
%w[SHA256 SHA512].all? {|d| have_func("#{d}_Transform", "openssl/sha.h")} &&
17+
%w[SHA256 SHA512].all? {|d| OpenSSL.check_func("#{d}_Transform", "openssl/sha.h")} &&
1618
%w[SHA256 SHA512].all? {|d| have_type("#{d}_CTX", "openssl/sha.h")}
1719
$objs << "sha2ossl.#{$OBJEXT}"
1820
$defs << "-DSHA2_USE_OPENSSL"
@@ -26,8 +28,5 @@
2628
$preload = %w[digest]
2729

2830
if have_type("uint64_t", "defs.h", $defs.join(' '))
29-
if try_compile("", flag = " -Wno-deprecated-declarations")
30-
$warnflags << flag
31-
end
3231
create_makefile("digest/sha2")
3332
end

ext/openssl/deprecation.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module OpenSSL
2+
def self.check_func(func, header)
3+
unless flag = (@deprecated_warning_flag ||= nil)
4+
if try_compile("", flag = "-Werror=deprecated-declarations")
5+
if with_config("broken-apple-openssl")
6+
flag = "-Wno-deprecated-declarations"
7+
end
8+
$warnflags << " #{flag}"
9+
else
10+
flag = ""
11+
end
12+
@deprecated_warning_flag = flag
13+
end
14+
have_func(func, header, flag)
15+
end
16+
end

ext/openssl/extconf.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
=end
1616

1717
require "mkmf"
18+
require_relative 'deprecation'
1819

1920
dir_config("openssl")
2021
dir_config("kerberos")
@@ -57,12 +58,8 @@
5758
message "OpenSSL 0.9.6 or later required.\n"
5859
exit 1
5960
end
60-
if try_compile("", flag = "-Werror=deprecated-declarations")
61-
unless have_func("SSL_library_init()", "openssl/ssl.h", flag)
62-
with_config("broken-apple-openssl") or
63-
abort "Ignore OpenSSL broken by Apple"
64-
$warnflags << " -Wno-deprecated-declarations"
65-
end
61+
unless OpenSSL.check_func("SSL_library_init()", "openssl/ssl.h")
62+
abort "Ignore OpenSSL broken by Apple"
6663
end
6764

6865
message "=== Checking for OpenSSL features... ===\n"

0 commit comments

Comments
 (0)