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

* lib/mkmf.rb (have_library, have_func, have_var, have_header):

add compiler option parameter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-11-10 06:02:40 +00:00
parent a5fc87bd5b
commit cfe220d8f3
2 changed files with 28 additions and 16 deletions

View file

@ -1,3 +1,8 @@
Thu Nov 10 15:02:37 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (have_library, have_func, have_var, have_header):
add compiler option parameter.
Thu Nov 10 07:45:16 2011 Eric Hodel <drbrain@segment7.net> Thu Nov 10 07:45:16 2011 Eric Hodel <drbrain@segment7.net>
* ext/openssl/lib/openssl/ssl.rb (class OpenSSL::SSL::SSLContext): * ext/openssl/lib/openssl/ssl.rb (class OpenSSL::SSL::SSLContext):

View file

@ -610,7 +610,7 @@ end
# [+libs+] a String which contains library names. # [+libs+] a String which contains library names.
# [+headers+] a String or an Array of strings which contains # [+headers+] a String or an Array of strings which contains
# names of header files. # names of header files.
def try_func(func, libs, headers = nil, &b) def try_func(func, libs, headers = nil, opt = "", &b)
headers = cpp_include(headers) headers = cpp_include(headers)
case func case func
when /^&/ when /^&/
@ -619,13 +619,20 @@ def try_func(func, libs, headers = nil, &b)
call = true call = true
decltype = proc {|x| "void ((*#{x})())"} decltype = proc {|x| "void ((*#{x})())"}
end end
try_link(<<"SRC", libs, &b) or if opt and !opt.empty?
[[:to_str], [:join, " "], [:to_s]].each do |meth, *args|
if opt.respond_to?(meth)
break opt = opt.send(meth, *args)
end
end
end
try_link(<<"SRC", "#{opt} #{libs}", &b) or
#{headers} #{headers}
/*top*/ /*top*/
#{MAIN_DOES_NOTHING} #{MAIN_DOES_NOTHING}
int t() { #{decltype["volatile p"]}; p = (#{decltype[]})#{func}; return 0; } int t() { #{decltype["volatile p"]}; p = (#{decltype[]})#{func}; return 0; }
SRC SRC
call && try_link(<<"SRC", libs, &b) call && try_link(<<"SRC", "#{opt} #{libs}", &b)
#{headers} #{headers}
/*top*/ /*top*/
#{MAIN_DOES_NOTHING} #{MAIN_DOES_NOTHING}
@ -634,9 +641,9 @@ SRC
end end
# You should use +have_var+ rather than +try_var+. # You should use +have_var+ rather than +try_var+.
def try_var(var, headers = nil, &b) def try_var(var, headers = nil, opt = "", &b)
headers = cpp_include(headers) headers = cpp_include(headers)
try_compile(<<"SRC", &b) try_compile(<<"SRC", opt, &b)
#{headers} #{headers}
/*top*/ /*top*/
#{MAIN_DOES_NOTHING} #{MAIN_DOES_NOTHING}
@ -837,15 +844,15 @@ end
# The real name of the library to be linked can be altered by # The real name of the library to be linked can be altered by
# '--with-FOOlib' configuration option. # '--with-FOOlib' configuration option.
# #
def have_library(lib, func = nil, headers = nil, &b) def have_library(lib, func = nil, headers = nil, opt = "", &b)
func = "main" if !func or func.empty? func = "main" if !func or func.empty?
lib = with_config(lib+'lib', lib) lib = with_config(lib+'lib', lib)
checking_for checking_message("#{func}()", LIBARG%lib) do checking_for checking_message("#{func}()", LIBARG%lib, opt) do
if COMMON_LIBS.include?(lib) if COMMON_LIBS.include?(lib)
true true
else else
libs = append_library($libs, lib) libs = append_library($libs, lib)
if try_func(func, libs, headers, &b) if try_func(func, libs, headers, opt, &b)
$libs = libs $libs = libs
true true
else else
@ -892,9 +899,9 @@ end
# For example, if have_func('foo') returned true, then the HAVE_FOO # For example, if have_func('foo') returned true, then the HAVE_FOO
# preprocessor macro would be passed to the compiler. # preprocessor macro would be passed to the compiler.
# #
def have_func(func, headers = nil, &b) def have_func(func, headers = nil, opt = "", &b)
checking_for checking_message("#{func}()", headers) do checking_for checking_message("#{func}()", headers, opt) do
if try_func(func, $libs, headers, &b) if try_func(func, $libs, headers, opt, &b)
$defs.push(format("-DHAVE_%s", func.tr_cpp)) $defs.push(format("-DHAVE_%s", func.tr_cpp))
true true
else else
@ -911,9 +918,9 @@ end
# For example, if have_var('foo') returned true, then the HAVE_FOO # For example, if have_var('foo') returned true, then the HAVE_FOO
# preprocessor macro would be passed to the compiler. # preprocessor macro would be passed to the compiler.
# #
def have_var(var, headers = nil, &b) def have_var(var, headers = nil, opt = "", &b)
checking_for checking_message(var, headers) do checking_for checking_message(var, headers, opt) do
if try_var(var, headers, &b) if try_var(var, headers, opt, &b)
$defs.push(format("-DHAVE_%s", var.tr_cpp)) $defs.push(format("-DHAVE_%s", var.tr_cpp))
true true
else else
@ -929,9 +936,9 @@ end
# For example, if have_header('foo.h') returned true, then the HAVE_FOO_H # For example, if have_header('foo.h') returned true, then the HAVE_FOO_H
# preprocessor macro would be passed to the compiler. # preprocessor macro would be passed to the compiler.
# #
def have_header(header, preheaders = nil, &b) def have_header(header, preheaders = nil, opt = "", &b)
checking_for header do checking_for header do
if try_header(cpp_include(preheaders)+cpp_include(header), &b) if try_header(cpp_include(preheaders)+cpp_include(header), opt, &b)
$defs.push(format("-DHAVE_%s", header.tr_cpp)) $defs.push(format("-DHAVE_%s", header.tr_cpp))
true true
else else