1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

digest: common configurations

* ext/digest/digest_conf.rb (digest_conf): extract common
  configurations.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-02-11 02:08:50 +00:00
parent e5c516c89a
commit b632ca436c
9 changed files with 36 additions and 44 deletions

View file

@ -1,3 +1,8 @@
Wed Feb 11 11:08:48 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/digest/digest_conf.rb (digest_conf): extract common
configurations.
Wed Feb 11 11:01:33 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/json/generator/generator.c (generate_json): get rid of

20
ext/digest/digest_conf.rb Normal file
View file

@ -0,0 +1,20 @@
def digest_conf(name, hdr = name, funcs = nil)
unless with_config("bundled-#{name}")
dir_config("openssl")
pkg_config("openssl")
require File.expand_path('../../openssl/deprecation', __FILE__)
if have_library("crypto")
funcs ||= name.upcase
funcs = Array(funcs)
hdr = "openssl/#{hdr}.h"
if funcs.all? {|func| OpenSSL.check_func("#{func}_Transform", hdr)} &&
funcs.all? {|func| have_type("#{func}_CTX", hdr)}
$defs << "-D#{name.upcase}_USE_OPENSSL"
$objs << "#{name}ossl.#{$OBJEXT}"
return :ossl
end
end
end
$objs << "#{name}.#{$OBJEXT}"
return
end

View file

@ -3,22 +3,14 @@
# $Id$
require "mkmf"
require File.expand_path("../../digest_conf", __FILE__)
$defs << "-DHAVE_CONFIG_H"
$INCFLAGS << " -I$(srcdir)/.."
$objs = [ "md5init.#{$OBJEXT}" ]
if !with_config("bundled-md5") &&
(dir_config("openssl")
pkg_config("openssl")
require File.expand_path('../../../openssl/deprecation', __FILE__)
have_library("crypto")) &&
OpenSSL.check_func("MD5_Transform", "openssl/md5.h")
$objs << "md5ossl.#{$OBJEXT}"
else
$objs << "md5.#{$OBJEXT}"
end
digest_conf("md5")
have_header("sys/cdefs.h")

View file

@ -2,7 +2,7 @@
/* $Id$ */
#include "digest.h"
#if defined(HAVE_OPENSSL_MD5_H)
#if defined(MD5_USE__OPENSSL)
#include "md5ossl.h"
#else
#include "md5.h"

View file

@ -3,22 +3,14 @@
# $Id$
require "mkmf"
require File.expand_path("../../digest_conf", __FILE__)
$defs << "-DNDEBUG" << "-DHAVE_CONFIG_H"
$INCFLAGS << " -I$(srcdir)/.."
$objs = [ "rmd160init.#{$OBJEXT}" ]
if !with_config("bundled-rmd160") &&
(dir_config("openssl")
pkg_config("openssl")
require File.expand_path('../../../openssl/deprecation', __FILE__)
have_library("crypto")) &&
OpenSSL.check_func("RIPEMD160_Transform", "openssl/ripemd.h")
$objs << "rmd160ossl.#{$OBJEXT}"
else
$objs << "rmd160.#{$OBJEXT}"
end
digest_conf("rmd160", "ripemd", "RIPEMD160")
have_header("sys/cdefs.h")

View file

@ -2,7 +2,7 @@
/* $Id$ */
#include "digest.h"
#if defined(HAVE_OPENSSL_RIPEMD_H)
#if defined(RMD160_USE_OPENSSL)
#include "rmd160ossl.h"
#else
#include "rmd160.h"

View file

@ -3,22 +3,14 @@
# $Id$
require "mkmf"
require File.expand_path("../../digest_conf", __FILE__)
$defs << "-DHAVE_CONFIG_H"
$INCFLAGS << " -I$(srcdir)/.."
$objs = [ "sha1init.#{$OBJEXT}" ]
if !with_config("bundled-sha1") &&
(dir_config("openssl")
pkg_config("openssl")
require File.expand_path('../../../openssl/deprecation', __FILE__)
have_library("crypto")) &&
OpenSSL.check_func("SHA1_Transform", "openssl/sha.h")
$objs << "sha1ossl.#{$OBJEXT}"
else
$objs << "sha1.#{$OBJEXT}"
end
digest_conf("sha1", "sha")
have_header("sys/cdefs.h")

View file

@ -2,7 +2,7 @@
/* $Id$ */
#include "digest.h"
#if defined(HAVE_OPENSSL_SHA_H)
#if defined(SHA1_USE_OPENSSL)
#include "sha1ossl.h"
#else
#include "sha1.h"

View file

@ -3,24 +3,15 @@
# $Id$
require "mkmf"
require File.expand_path("../../digest_conf", __FILE__)
$defs << "-DHAVE_CONFIG_H"
$INCFLAGS << " -I$(srcdir)/.."
$objs = [ "sha2init.#{$OBJEXT}" ]
if !with_config("bundled-sha2") &&
(dir_config("openssl")
pkg_config("openssl")
require File.expand_path('../../../openssl/deprecation', __FILE__)
have_library("crypto")) &&
%w[SHA256 SHA512].all? {|d| OpenSSL.check_func("#{d}_Transform", "openssl/sha.h")} &&
%w[SHA256 SHA512].all? {|d| have_type("#{d}_CTX", "openssl/sha.h")}
$objs << "sha2ossl.#{$OBJEXT}"
$defs << "-DSHA2_USE_OPENSSL"
else
unless digest_conf("sha2", "sha", %w[SHA256 SHA512])
have_type("u_int8_t")
$objs << "sha2.#{$OBJEXT}"
end
have_header("sys/cdefs.h")