永井@知能.九工大です.

From: Hidetoshi NAGAI <nagai / ai.kyutech.ac.jp>
Subject: [ruby-dev:25561] Re: merge tcltklib and tk
Date: Thu, 27 Jan 2005 12:22:21 +0900
Message-ID: <20050127.122209.41646111.nagai / ai.kyutech.ac.jp>
> > > これができるのなら,tkutil をサブディレクトリに落としてやれば
> > > 解決するということになります.
> > > どんな風に書けばいいんでしょう.
> > ディレクトリ構造に依存関係を肩代りさせるのであれば、extconf.rb
> > を分離してtkutilをext/tcltklib/tkutilに移動させることになります。
> 
> 単純に階層関係にするだけで,親ディレクトリで失敗したら
> 子も作られないのでしょうか?
> 
> # すみません.本当に分かってません.
> # ext/tk/tcltklib.c , ext/tk/tkutil/tkutil.c という配置を
> # 考えています.

よくわからないなりにやってみました.

・tk/tkutil.c を tk/tkutil/tkutil.c に移動
・tk/depend から tk/tkutil/depend 分を分離
・tk/extconf.rb から tkutil 関係の記述を削除.
・tk/extconf.rb から tk/tkutil/extconf.rb を生成するように記述.
・tk/extconf.rb を直接実行した場合に限り,生成した tkutil の 
  extconf.rb 実行した上で,tkutil の make に関する記述 
  (tk/make-tkutil がその内容) を tk/Makefile に追加するように 
  tk/extconf.rb に記述.

となっています.
tkutil.c の移動以外の差分を添付します.
このパッチを当てた上で,tk/tkutil.c を tk/tkutil/tkutil.c に
移動してください.


diff -urN --exclude=CVS tk.orig/depend tk/depend --- tk.orig/depend 2005-01-25 23:44:59.000000000 +0900 +++ tk/depend 2005-01-27 17:02:31.000000000 +0900 @@ -1,3 +1,2 @@ tcltklib.o: tcltklib.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h stubs.o: stubs.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h -tkutil.o: tkutil.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h diff -urN --exclude=CVS tk.orig/extconf.rb tk/extconf.rb --- tk.orig/extconf.rb 2005-01-27 18:09:35.000000000 +0900 +++ tk/extconf.rb 2005-01-27 17:59:25.000000000 +0900 @@ -265,6 +265,9 @@ $LDFLAGS += ' -framework Tk -framework Tcl' end + + FileUtils.rm_f('tkutil/extconf.rb') + if stubs or pthread_check # create Makefile @@ -276,78 +279,41 @@ $INSTALLFILES = [] end - cleanings_bup = CLEANINGS.dup - - if $objs - objs_bup = $objs.dup - else - objs_bup = nil - $objs = [] - end - # for SUPPORT_STATUS $INSTALLFILES << ["lib/tkextlib/SUPPORT_STATUS", "$(RUBYLIBDIR)", "lib"] - # for tcltklib.so - $objs << "stubs.o" << "tcltklib.o" - - # for tkutil.so - mk_tkutil = "\n\n" - mk_tkutil << "OBJS2 = tkutil.#{$OBJEXT}\n" - mk_tkutil << "TARGET2 = tkutil\n" - mk_tkutil << "DLLIB2 = $(TARGET2).#{CONFIG['DLEXT']}\n" - mk_tkutil << "STATIC_LIB2 = $(TARGET2).#{$LIBEXT}\n" - mk_tkutil << "\n" - mk_tkutil << 'CLEANLIBS2 = "$(TARGET2).{lib,exp,il?,tds,map}" $(DLLIB2)' - mk_tkutil << "\n\n" - mk_tkutil << "all: $(DLLIB2)\n" - mk_tkutil << "static: $(STATIC_LIB2)\n" - mk_tkutil << "\n" - - mk_tkutil << CLEANINGS.sub(/\$\(CLEANLIBS\)/, "$(CLEANLIBS) $(CLEANLIBS2)") - mk_tkutil << "\n\n" - - DLDFLAGS2 = "#$LDFLAGS #$DLDFLAGS #$ARCH_FLAG".gsub(/\$\(DEFFILE\)/, '$(DEFFILE2)') - mk_tkutil << "DLDFLAGS2 = #{DLDFLAGS2}\n" - mk_tkutil << "DEFFILE2 = $(TARGET2)-$(arch).def\n" if EXPORT_PREFIX - mk_tkutil << "\n" - - mk_tkutil << "$(DLLIB2): #{EXPORT_PREFIX ? '$(DEFFILE2) ':''}$(OBJS2)\n\t" - mk_tkutil << "@-$(RM) $@\n\t" - mk_tkutil << "@-$(RM) $(TARGET2).lib\n\t" if $mswin - - LINK_SO2 = LINK_SO.gsub(/\$\(DLLIB\)/, '$(DLLIB2)').gsub(/\$\(OBJS\)/, '$(OBJS2)').gsub(/\$\(DLDFLAGS\)/, '$(DLDFLAGS2)').gsub(/\$\(DEFFILE\)/, '$(DEFFILE2)') - mk_tkutil << LINK_SO2 - - mk_tkutil << "\n\n" - unless $static.nil? - mk_tkutil << "$(STATIC_LIB2): $(OBJS2)\n\t" - mk_tkutil << "$(AR) #{config_string('ARFLAGS') || 'cru '}$@ $(OBJS2)" - if ranlib = config_string('RANLIB') - mk_tkutil << "\n\t@-#{ranlib} $(DLLIB2) 2> /dev/null || true" - end - end - mk_tkutil << "\n\n" - - if EXPORT_PREFIX - mk_tkutil << "$(DEFFILE2):\n" - mk_tkutil << %Q!\t$(RUBY) -e "puts 'EXPORTS', '#{EXPORT_PREFIX}Init_$(TARGET2)'" > $@\n! - mk_tkutil << "\n\n" - end - mk_tkutil << "\n" - - mk_tkutil << "install: $(RUBYARCHDIR)/$(DLLIB2)\n" - mk_tkutil << "$(RUBYARCHDIR)/$(DLLIB2): $(DLLIB2) $(RUBYARCHDIR)\n" - mk_tkutil << "\t@$(INSTALL_PROG) $(DLLIB2) $(RUBYARCHDIR)\n" - - CLEANINGS.replace(mk_tkutil) - # create create_makefile("tcltklib") # reset $INSTALLFILES = installfiles_bup - CLEANINGS.replace(cleanings_bup) - $objs = objs_bup + + # create tkutil/extconf.rb + File::open('tkutil/extconf.rb', 'w'){|f| + f.print "# This file is created by extconf.rb on the parent directory\n" + f.print "require 'mkmf'\n" + f.print "create_makefile('tkutil')\n" + } + + if !$extout && !$extmk + puts "enter 'tkutil' directory" + system("cd tkutil; #{$ruby} extconf.rb") + + File::open('Makefile', 'a'){|mfile| + File::open('make-tkutil', 'r'){|dfile| + mfile.print "\n###\n" + while line = dfile.gets() + mfile.print line + end + } + } + end + + else + # not clreate Makefile + File::open('tkutil/extconf.rb', 'w'){|f| + f.print "# This file is created by extconf.rb on the parent directory\n" + f.print "require 'mkmf'\n" + } end end diff -urN --exclude=CVS tk.orig/make-tkutil tk/make-tkutil --- tk.orig/make-tkutil 1970-01-01 09:00:00.000000000 +0900 +++ tk/make-tkutil 2005-01-27 17:56:07.000000000 +0900 @@ -0,0 +1,43 @@ +all: all-tkutil +all-tkutil: + @(cd tkutil; $(MAKE) all) + +static: static-tkutil +static-tkutil: + @(cd tkutil; $(MAKE) static) + +clean: clean-tkutil +clean-tkutil: + @(cd tkutil; $(MAKE) clean) + +distclean: distclean-tkutil +distclean-tkutil: + @(cd tkutil; $(MAKE) distclean) + +realclean: realclean-tkutil +realclean-tkutil: + @(cd tkutil; $(MAKE) realclean) + +install: install-tkutil +install-tkutil: + @(cd tkutil; $(MAKE) install) + +install-so: install-tkutil-so +install-tkutil-so: + @(cd tkutil; $(MAKE) install-so) + +install-rb: install-tkutil-rb +install-tkutil-rb: + @(cd tkutil; $(MAKE) install-rb) + +site-install: site-install-tkutil +site-install-tkutil: + @(cd tkutil; $(MAKE) site-install) + +site-install-so: site-install-tkutil-so +site-install-tkutil-so: + @(cd tkutil; $(MAKE) site-install-so) + +site-install-rb: site-install-tkutil-rb +site-install-tkutil-rb: + @(cd tkutil; $(MAKE) site-install-rb) diff -urN --exclude=CVS tk.orig/tkutil/depend tk/tkutil/depend --- tk.orig/tkutil/depend 1970-01-01 09:00:00.000000000 +0900 +++ tk/tkutil/depend 2005-01-27 16:20:06.000000000 +0900 @@ -0,0 +1 @@ +tkutil.o: tkutil.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h diff -urN --exclude=CVS tk.orig/tkutil/extconf.rb tk/tkutil/extconf.rb --- tk.orig/tkutil/extconf.rb 1970-01-01 09:00:00.000000000 +0900 +++ tk/tkutil/extconf.rb 2005-01-27 18:08:03.000000000 +0900 @@ -0,0 +1,3 @@ +# This file is created by extconf.rb on the parent directory +require 'mkmf' +create_makefile('tkutil')
-- 永井 秀利 (九工大 知能情報) nagai / ai.kyutech.ac.jp