なかだです。

At Sat, 18 Jan 2003 08:12:14 +0000,
katsu wrote:
>     rough/ext/zlib:
>       ChangeLog extconf.rb zlib.c
>   Log:
>     * zlib.c: followed the latest Ruby.
>     * extconf.rb: ditto.

これ見て思ったんですが

* クロスコンパイルの場合respond_to?は正しくないかも知れない。最
  初あまり考えずに使ってしまったんですが、後から考えると失敗で
  した。

* (パターンをStringで指定すると)egrep_cppはegrepのない環境では
  常に失敗する。

* ライブラリ名は固定ではない。

ということで、extconf.rbでのfeatureの検出方法についてのパッチで
す。

最近のcygwin+mingwだと、1.4.6はコンパイルできないみたいですが、
動作確認状況はこんなところ。

	1.4.6	1.6.8	1.8.0
linux	OK	OK	OK
cygwin	OK	OK	OK
mingw	-	OK	OK
mswin	NG	OK	OK
bccwin	-	-	OK

mswin32版の1.4.6ではやっぱりhave_ruby_funcがちゃんと動きません
が、これはconfig.statusでmkmfのことを考慮してないのとruby本体が
LIBPATHに対応してないせいなので、extconf.rbで処理するのは無理が
あります。まぁどうせ、使ってる人はもういないでしょう。

しかし、Allocation frameworkとかNORETURN()とか、検出が面倒なも
のはrbconfig.rbとかfeature.hみたいので分かるようにしておいたほ
うがいいかも。


Index: ext/zlib/extconf.rb =================================================================== RCS file: /cvs/ruby/src/rough/ext/zlib/extconf.rb,v retrieving revision 1.2 diff -u -2 -p -r1.2 extconf.rb --- ext/zlib/extconf.rb 18 Jan 2003 08:12:14 -0000 1.2 +++ ext/zlib/extconf.rb 19 Jan 2003 16:36:02 -0000 @@ -16,10 +16,6 @@ def have_ruby_func(s) oldlibs = $libs oldlibpath = $LIBPATH - lib = 'ruby' - lib = 'libruby' if /mswin32/ =~ RUBY_PLATFORM - $libs = append_library($libs, lib) - archdir = CONFIG['archdir'] - archdir ||= "$(libdir)/ruby/$(ruby_version)/$(arch)" # for ruby-1.4 - $LIBPATH = [ archdir, CONFIG['compile_dir'] ] + $LIBPATH + $libs += " " + CONFIG['LIBRUBYARG'] + $LIBPATH = [$archdir] + $LIBPATH begin have_func s, 'ruby.h' @@ -32,4 +28,9 @@ def have_ruby_func(s) end +unless respond_to?(:try_compile) + class << self + alias try_compile try_link + end +end dir_config "zlib" @@ -40,12 +41,5 @@ if have_library('z', 'deflateReset') and defines = [] - msg_check "checking for block_given?" # for ruby-1.4 - if Kernel.respond_to? :block_given? then - print "yes\n" - defines << "HAVE_BLOCK_GIVEN_P" - else - print "no\n" - end - + have_ruby_func "rb_block_given_p" # for ruby-1.4 have_ruby_func 'rb_str_buf_new' # for ruby-1.6 have_ruby_func 'rb_io_print' # for ruby-1.6 @@ -57,9 +51,9 @@ if have_library('z', 'deflateReset') and msg_check "checking for new NORETURN" # for ruby-1.6 - if egrep_cpp("^NORETURN", "#include \"config.h\"\nNORETURN(exit);\n") then - print "no\n" - else + if try_compile("#include \"config.h\"\nmain(){NORETURN(void exit());}\n") then print "yes\n" defines << "HAVE_NEW_NORETURN" + else + print "no\n" end Index: ext/zlib/zlib.c =================================================================== RCS file: /cvs/ruby/src/rough/ext/zlib/zlib.c,v retrieving revision 1.8 diff -u -2 -p -r1.8 zlib.c --- ext/zlib/zlib.c 18 Jan 2003 08:44:49 -0000 1.8 +++ ext/zlib/zlib.c 18 Jan 2003 10:40:06 -0000 @@ -11,5 +11,5 @@ #include <time.h> -#ifndef HAVE_BLOCK_GIVEN_P /* for Ruby-1.4 */ +#ifndef HAVE_RB_BLOCK_GIVEN_P /* for Ruby-1.4 */ #define rb_block_given_p() rb_iterator_p() #endif
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦