diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 04b5f26a5e..c9eae06b23 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -770,6 +770,10 @@ def try_constant(const, headers = nil, opt = "", &b) # [+headers+] a String or an Array of strings which contains names of header # files. def try_func(func, libs, headers = nil, opt = "", &b) + _try_func(:try_link, func, libs, headers, opt, &b) + end + + private def _try_func(try_method, func, libs, headers = nil, opt = "", &b) headers = cpp_include(headers) case func when /^&/ @@ -792,14 +796,14 @@ def try_func(func, libs, headers = nil, opt = "", &b) else opt = libs end - decltype && try_link(<<"SRC", opt, &b) or + decltype && send(try_method, <<"SRC", opt, &b) or #{headers} /*top*/ extern int t(void); #{MAIN_DOES_NOTHING 't'} int t(void) { #{decltype["volatile p"]}; p = (#{decltype[]})#{func}; return !p; } SRC - call && try_link(<<"SRC", opt, &b) + try_method == :try_link && call && try_link(<<"SRC", opt, &b) #{headers} /*top*/ extern int t(void); @@ -1089,7 +1093,12 @@ def find_library(lib, func, *paths, &b) # def have_func(func, headers = nil, opt = "", &b) checking_for checking_message(func.funcall_style, headers, opt) do - if try_func(func, $libs, headers, opt, &b) + try_method = if RbConfig::CONFIG["LIBRUBYARG"].include?('-lruby') + :try_link + else + :try_compile + end + if _try_func(try_method, func, $libs, headers, opt, &b) $defs << "-DHAVE_#{func.sans_arguments.tr_cpp}" true else diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb index 6db60724e9..297fd690fa 100755 --- a/tool/mkconfig.rb +++ b/tool/mkconfig.rb @@ -30,6 +30,7 @@ install_name = nil so_name = nil platform = nil +disable_install_static_library = nil File.foreach "config.status" do |line| next if /^#/ =~ line name = nil @@ -110,6 +111,9 @@ eq = win32 && vars[name] ? '<< "\n"' : '=' vars[name] = val if name == "configure_args" + if val.include?('--disable-install-static-library') + disable_install_static_library = true + end val.gsub!(/--with-out-ext/, "--without-ext") end val = val.gsub(/\$(?:\$|\{?(\w+)\}?)/) {$1 ? "$(#{$1})" : $&}.dump @@ -126,6 +130,10 @@ end when /^includedir$/ val = '"$(SDKROOT)"'+val if /darwin/ =~ arch + when /^LIBRUBYARG_STATIC$/ + if disable_install_static_library + val.sub!('-l$(RUBY_SO_NAME)-static ', '') + end end v = " CONFIG[\"#{name}\"] #{eq} #{val}\n" if fast[name]