[前][次][番号順一覧][スレッド一覧]

ruby-changes:21657

From: nobu <ko1@a...>
Date: Fri, 11 Nov 2011 17:21:29 +0900 (JST)
Subject: [ruby-changes:21657] nobu:r33706 (trunk): * lib/mkmf.rb (have_library, find_library, have_func): allow

nobu	2011-11-11 17:21:17 +0900 (Fri, 11 Nov 2011)

  New Revision: 33706

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33706

  Log:
    * lib/mkmf.rb (have_library, find_library, have_func): allow
      arguments of function to be checked.

  Modified files:
    trunk/ChangeLog
    trunk/lib/mkmf.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33705)
+++ ChangeLog	(revision 33706)
@@ -1,3 +1,8 @@
+Fri Nov 11 17:21:15 2011  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/mkmf.rb (have_library, find_library, have_func): allow
+	  arguments of function to be checked.
+
 Fri Nov 11 17:09:45 2011  Nobuyoshi Nakada  <nobu@r...>
 
 	* vm_dump.c (HAVE_BACKTRACE): fallback to 0.
Index: lib/mkmf.rb
===================================================================
--- lib/mkmf.rb	(revision 33705)
+++ lib/mkmf.rb	(revision 33706)
@@ -186,6 +186,14 @@
   def tr_cpp
     strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P")
   end
+
+  def funcall_style
+    /\)\z/ =~ self ? dup : "#{self}()"
+  end
+
+  def sans_arguments
+    self[/\A[^()]+/]
+  end
 end
 class Array
   # Wraps all strings in escaped quotes if they contain whitespace.
@@ -615,8 +623,10 @@
   case func
   when /^&/
     decltype = proc {|x|"const volatile void *#{x}"}
+  when /\)$/
+    call = func
   else
-    call = true
+    call = "#{func}()"
     decltype = proc {|x| "void ((*#{x})())"}
   end
   if opt and !opt.empty?
@@ -629,7 +639,7 @@
   else
     opt = libs
   end
-  try_link(<<"SRC", opt, &b) or
+  decltype && try_link(<<"SRC", opt, &b) or
 #{headers}
 /*top*/
 #{MAIN_DOES_NOTHING}
@@ -639,7 +649,7 @@
 #{headers}
 /*top*/
 #{MAIN_DOES_NOTHING}
-int t() { #{func}(); return 0; }
+int t() { #{call}; return 0; }
 SRC
 end
 
@@ -850,7 +860,7 @@
 def have_library(lib, func = nil, headers = nil, opt = "", &b)
   func = "main" if !func or func.empty?
   lib = with_config(lib+'lib', lib)
-  checking_for checking_message("#{func}()", LIBARG%lib, opt) do
+  checking_for checking_message(func.funcall_style, LIBARG%lib, opt) do
     if COMMON_LIBS.include?(lib)
       true
     else
@@ -876,7 +886,7 @@
   func = "main" if !func or func.empty?
   lib = with_config(lib+'lib', lib)
   paths = paths.collect {|path| path.split(File::PATH_SEPARATOR)}.flatten
-  checking_for "#{func}() in #{LIBARG%lib}" do
+  checking_for(func.funcall_style, LIBARG%lib) do
     libpath = $LIBPATH
     libs = append_library($libs, lib)
     begin
@@ -903,9 +913,9 @@
 # preprocessor macro would be passed to the compiler.
 #
 def have_func(func, headers = nil, opt = "", &b)
-  checking_for checking_message("#{func}()", headers, opt) do
+  checking_for checking_message(func.funcall_style, headers, opt) do
     if try_func(func, $libs, headers, opt, &b)
-      $defs.push(format("-DHAVE_%s", func.tr_cpp))
+      $defs << "-DHAVE_#{func.sans_arguments.tr_cpp}"
       true
     else
       false

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]