From: gotoken@... (GOTO Kentaro) Date: 2000-02-09T07:42:59+09:00 Subject: [ruby-dev:9160] Re: lib/subdirectory ごとけんです ruby-list から持って来ました。 In message "[ruby-list:20535] Re: lib/subdirectory" on 00/02/07, GOTO Kentaro writes: >>え? いえ、全然そんなこと考えてませんでした。そのままインス >>トールする時に指定されたディレクトリに(なければ作って)コピー >>しようと思ってました。ディレクトリを作る意味ってなんでしょう。 >>もしかして、下で述べてたテストを念頭に置いてます? > >そうです。人のモノをいれるとき make install する前 >に試してみたいですし。 ってことで、ちょっと書いてみました。 work というのを掘ってその下にarcdir以下のインストール構成を 作ります。 あと $TESTRB が定義してあったら make test で ruby $(TESTRB) するようにしてみました。 コメント下さいまし。 -- gotoken --- 1.4/mkmf.rb.orig Fri Sep 24 08:39:01 1999 +++ 1.4/mkmf.rb Wed Feb 9 03:23:05 2000 @@ -313,6 +313,12 @@ $LDFLAGS += ldir if ldir end +def subdirectories(root, subdir) + dirs, res = subdir.split('/'), [] + dirs.size.times{|i| res.push(root+'/'+dirs[0..i].join('/'))} + res +end + def create_makefile(target) print "creating Makefile\n" system "rm -f conftest*" @@ -331,6 +337,10 @@ $DLDFLAGS = $DLDFLAGS + " -L" + CONFIG["prefix"] + "/lib" end + subdir, target = $1, $2 if target =~ %r%(.*)/(.*$)% # end + subdir = subdir || "." + blddir = "work" + defflag = '' if RUBY_PLATFORM =~ /cygwin/ if File.exist? target + ".def" @@ -379,6 +389,12 @@ OBJS = #{$objs} TARGET = #{target} +SUBDIR = #{subdir} +SUBDIRS = #{subdirectories("$(archdir)", subdir).join(" ")} +BLDDIR = #{blddir} +BLDDIRS = #{blddir} #{subdirectories(blddir, subdir).join(" ")} +TESTRB = #{$TESTRB} + DLLIB = $(TARGET).#{CONFIG["DLEXT"]} RUBY = #{CONFIG["ruby_install_name"]} @@ -388,6 +404,7 @@ all: $(DLLIB) clean:; @rm -f *.#{$OBJEXT} *.so *.sl *.a $(DLLIB) + @rm -fr $(BLDDIR) @rm -f $(TARGET).lib $(TARGET).exp @rm -f Makefile extconf.h conftest.* @rm -f core ruby$(EXEEXT) *~ @@ -397,16 +414,27 @@ install: $(archdir)/$(DLLIB) $(archdir)/$(DLLIB): $(DLLIB) - @$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(libdir) $(archdir) + @$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(libdir) $(archdir) $(SUBDIRS) @$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)' $(DLLIB) $(archdir)/$(DLLIB) + EOMF + + install_rb(mfile) + mfile.print(<