From: Kenta Murata Date: 2010-02-18T12:14:50+09:00 Subject: [ruby-dev:40442] Re: [Feature #2746] ビルドする拡張ライブラリを configure 時に指定するための --with-exts オプション -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 むらたです。 On 2010/02/16, at 15:48, Akinori MUSHA wrote: > At Tue, 16 Feb 2010 12:05:49 +0900, > Kenta Murata wrote: >>> こんにちは、なかむら(う)です。 >>> >>> In message "[ruby-dev:40418] [Feature #2746] ビルドする拡張ライブラリを configure 時に指定するための --with-exts オプション" >>> on Feb.15,2010 13:36:10, wrote: >>>> 現在 make に対して EXTS 変数を指定することでビルドする拡張ライブラリを限定できます。 >>>> この方法では make の度に拡張ライブラリのリストを指定しなければならず、 >>>> 例えば dbm, gdbm, sdbm, tk 以外をビルドしたい場合は >>>> 除外するライブラリ以外を列挙する必要があり不便です。 >>>> >>>> この状況を改善するために、configure.in に --with-exts オプションを追加する以下のパッチを提案します。 >>> >>> 既に--with-ext(または--with-extensions)というものがあるのです >>> が。 >>> ext/extmk.rbあたりを参照してください。 >> >> extmk.rb に対して --with-ext または --without-ext を EXTS 変数経由で渡せるなら >> configure.in で AC_SUBST(EXTS) するだけで良く、--with-exts を導入するまでもないですね。 >> しかも extmk.rb の機能を直接使えば拡張ライブラリ名にワイルドカードが使えるんですね。 >> >> 以下のパッチで configure EXTS=--without-ext=*dbm,tk,win32api ができるようになります。 >> これで問題ないようでしたら、アカウント登録され次第マージしてコミットします。 > >  --with-ext=... は今もそのまま configure の引数に書けば渡るはず。 > 問題は --without-ext=... が configure の文法上エラーになってしまう > ので渡せないことでしょうか。 > >  よって、たとえば --with-out-ext に改名すれば解決しそうです。 > > Index: extmk.rb > =================================================================== > --- extmk.rb (revision 26649) > +++ extmk.rb (working copy) > @@ -396,7 +396,7 @@ end unless $extstatic > > ext_prefix = "#{$top_srcdir}/ext" > exts = $static_ext.sort_by {|t, i| i}.collect {|t, i| t} > -withes, withouts = %w[--with --without].collect {|w| > +withes, withouts = %w[--with --with-out].collect {|w| > if not (w = %w[-extensions -ext].collect {|o|arg_config(w+o)}).any? > nil > elsif (w = w.grep(String)).empty? > > > あるいは、互換性が重要ならこうするか。 > > Index: extmk.rb > =================================================================== > --- extmk.rb (revision 26649) > +++ extmk.rb (working copy) > @@ -396,7 +396,7 @@ end unless $extstatic > > ext_prefix = "#{$top_srcdir}/ext" > exts = $static_ext.sort_by {|t, i| i}.collect {|t, i| t} > -withes, withouts = %w[--with --without].collect {|w| > +withes, *withouts = %w[--with --without --with-out].collect {|w| > if not (w = %w[-extensions -ext].collect {|o|arg_config(w+o)}).any? > nil > elsif (w = w.grep(String)).empty? > @@ -405,6 +405,7 @@ withes, withouts = %w[--with --without]. > proc {|c1| w.collect {|o| o.split(/,/)}.flatten.any?(&c1)} > end > } > +withouts = withouts.compact.first > if withes > withouts ||= proc {true} > else without を with-out に分離する方法は思いつきませんでした。 以下のように --with-ext と --with-out-ext を定義して mkconfig.rb で with-out を without へ変換すると、 configure で警告も出ず、extmk.rb を変更する必要もなくなります。 diff --git a/configure.in b/configure.in index 513898d..4542bda 100644 - --- a/configure.in +++ b/configure.in @@ -1918,6 +1918,12 @@ AS_CASE(["$target_os"], [nextstep* | openstep* | rhapsody* | darwin*], [ STRIP='strip -A -n']) +AC_ARG_WITH(ext, + AC_HELP_STRING([--with-ext=EXTS], + [pass to --with-ext option of extmk.rb])) +AC_ARG_WITH(out-ext, + AC_HELP_STRING([--with-out-ext=EXTS], + [pass to --without-ext option of extmk.rb])) EXTSTATIC= AC_SUBST(EXTSTATIC)dnl AC_ARG_WITH(static-linked-ext, diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb index df3c35f..ac24821 100755 - --- a/tool/mkconfig.rb +++ b/tool/mkconfig.rb @@ -111,7 +111,10 @@ File.foreach "config.status" do |line| end end end - - val.gsub!(/ +(?!-)/, "=") if name == "configure_args" && /mswin32/ =~ RUBY_PLATFORM + if name == "configure_args" + val.gsub!(/ +(?!-)/, "=") if /mswin32/ =~ RUBY_PLATFORM + val.gsub!(/--with-out-ext/, "--without-ext") + end val = val.gsub(/\$(?:\$|\{?(\w+)\}?)/) {$1 ? "$(#{$1})" : $&}.dump if /^prefix$/ =~ name val = "(TOPDIR || DESTDIR + #{val})" - -- Kenta Murata OpenPGP FP = FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC 本を書きました!! 『Ruby 逆引きレシピ』 http://www.amazon.co.jp/dp/4798119881/mrkn-22 E-mail: mrkn@mrkn.jp twitter: http://twitter.com/mrkn/ blog: http://d.hatena.ne.jp/mrkn/ -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) iF4EAREIAAYFAkt8sKAACgkQ8hOWb+nrC8yM2AD9Gl1dZF9aTzL6twwC2lspYGSg AVouWvosi9dCa6oz1M8A/1JG3ul3LdlbC5zPQqmc9QBAGjcnx+ePfI1EHTzjRZjS =teb9 -----END PGP SIGNATURE-----