From: Motoyuki Kasahara Date: 1998-10-19T10:55:58+09:00 Subject: [ruby-list:10175] VPATH SRA の笠原です。 Ruby-1.1c6 のソースコードの Makefile.in を見ると、$(srcdir) や VPATH といった単語が入っているので、ソースコードとは別のディレクトリでコンパ イルすることも考慮しているような気配なのですが、実際にやってみると幾つ かのファイルが見つけらないために、途中でコンパイルエラーを起こしてしま います。 そこで、別のディレクトリでもコンパイルできるようにするためのパッチを作っ てみましたので、添付します。採用して頂けると嬉しいです。 それから蛇足ですが、gperf は AC_PATH_PROG (or AC_PATH_PROGS) でチェッ クした方が良いと思います。 --- ./ext/extmk.rb.in.ORG Thu Oct 1 11:55:28 1998 +++ ./ext/extmk.rb.in Mon Oct 19 10:41:07 1998 @@ -1,7 +1,7 @@ #! /usr/local/bin/ruby $".push 'mkmf.rb' #" -load '../lib/find.rb' +load '@top_srcdir@/lib/find.rb' if ARGV[0] == 'static' $force_static = TRUE @@ -20,8 +20,16 @@ $lib_cache = {} $func_cache = {} $hdr_cache = {} -$topdir = "@top_srcdir@" -if $topdir !~ "^/" +$top_srcdir = "@top_srcdir@" +if $top_srcdir !~ "^/" + # get absolute path + save = Dir.pwd + Dir.chdir $top_srcdir + $top_srcdir = Dir.pwd + Dir.chdir save +end +$topdir = ".." +if $topdir !~ "^/" # get absolute path save = Dir.pwd Dir.chdir $topdir @@ -63,8 +71,8 @@ else CFLAGS = "@CFLAGS@" end -LINK = "@CC@ -o conftest -I#{$topdir} -I@includedir@ " + CFLAGS + " %s @LDFLAGS@ %s conftest.c @LIBS@ %s" -CPP = "@CPP@ @CPPFLAGS@ -I#{$topdir} -I@includedir@ " + CFLAGS + " %s conftest.c" +LINK = "@CC@ -o conftest -I#{$topdir} -I#{$top_srcdir} -I@includedir@ " + CFLAGS + " %s @LDFLAGS@ %s conftest.c @LIBS@ %s" +CPP = "@CPP@ @CPPFLAGS@ -I#{$topdir} -I#{$top_srcdir} -I@includedir@ " + CFLAGS + " %s conftest.c" if /win32|djgpp|mingw32|m68k-human/i =~ PLATFORM $null = open("nul", "w") @@ -255,7 +263,7 @@ $DLDFLAGS = $DLDFLAGS + " -L" + $topdir end - $srcdir = $topdir + "/ext/" + target + $srcdir = $top_srcdir + "/ext/" + target mfile = open("Makefile", "w") mfile.printf "\ SHELL = /bin/sh @@ -270,7 +278,7 @@ CC = @CC@ prefix = @prefix@ -CFLAGS = %s -I#{$topdir} -I@includedir@ %s #$CFLAGS %s +CFLAGS = %s -I#{$topdir} -I#{$top_srcdir} -I@includedir@ %s #$CFLAGS %s DLDFLAGS = #$DLDFLAGS #$LDFLAGS LDSHARED = @LDSHARED@ ", if $static then "" else "@CCDLFLAGS@" end, CFLAGS, $defs.join(" ") @@ -294,7 +302,7 @@ mfile.printf "OBJS = " if !$objs then $objs = [] - for f in Dir["#{$topdir}/ext/#{target}/*.{c,cc}"] + for f in Dir["#{$top_srcdir}/ext/#{target}/*.{c,cc}"] f = File.basename(f) f.sub!(/\.(c|cc)$/, ".o") $objs.push f @@ -409,13 +417,13 @@ Dir.chdir target if $static_ext.size > 0 || !File.exist?("./Makefile") || - older("./Makefile", "#{$topdir}/ext/@setup@") || + older("./Makefile", "#{$top_srcdir}/ext/@setup@") || older("./Makefile", "../extmk.rb") || - older("./Makefile", "#{$topdir}/ext/#{target}/extconf.rb") + older("./Makefile", "#{$top_srcdir}/ext/#{target}/extconf.rb") then $defs = [] - if File.exist?("#{$topdir}/ext/#{target}/extconf.rb") - load "#{$topdir}/ext/#{target}/extconf.rb" + if File.exist?("#{$top_srcdir}/ext/#{target}/extconf.rb") + load "#{$top_srcdir}/ext/#{target}/extconf.rb" else create_makefile(target); end @@ -445,7 +453,7 @@ # get static-link modules $static_ext = {} -for setup in ["@setup@", "#{$topdir}/ext/@setup@"] +for setup in ["@setup@", "#{$top_srcdir}/ext/@setup@"] if File.file? setup f = open(setup) while f.gets() @@ -463,7 +471,7 @@ end end -for d in Dir["#{$topdir}/ext/*"] +for d in Dir["#{$top_srcdir}/ext/*"] File.directory?(d) || next File.file?(d + "/MANIFEST") || next @@ -511,7 +519,7 @@ end end - if older("extinit.c", "#{$topdir}/ext/@setup@") + if older("extinit.c", "#{$top_srcdir}/ext/@setup@") f = open("extinit.c", "w") f.printf "void Init_ext() {\n" f.printf $extinit @@ -526,7 +534,7 @@ Dir.chdir ".." - if older("ruby@binsuffix@", "#{$topdir}/ext/@setup@") or older("ruby@binsuffix@", "miniruby@binsuffix@") + if older("ruby@binsuffix@", "#{$top_srcdir}/ext/@setup@") or older("ruby@binsuffix@", "miniruby@binsuffix@") `rm -f ruby@binsuffix@` end --- ./Makefile.in.ORG Mon Aug 3 18:12:07 1998 +++ ./Makefile.in Mon Oct 19 10:35:57 1998 @@ -11,7 +11,7 @@ @SET_MAKE@ prefix = @prefix@ -CFLAGS = @CFLAGS@ -I@srcdir@ -I@includedir@ +CFLAGS = @CFLAGS@ -I. -I@srcdir@ -I@includedir@ LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@ EXTLIBS = LIBS = @LIBS@ $(EXTLIBS) @@ -117,7 +117,7 @@ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< lex.c: keywords - gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ keywords > lex.c + gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ @srcdir@/keywords > lex.c parse.c: parse.y $(YACC) $< --- ./instruby.rb.ORG Thu Sep 24 11:18:09 1998 +++ ./instruby.rb Mon Oct 19 10:35:57 1998 @@ -13,10 +13,11 @@ prefix = CONFIG["prefix"] end ruby_install_name = CONFIG["ruby_install_name"] -bindir = prefix + "/bin" -libdir = prefix + "/lib/" + ruby_install_name +bindir = CONFIG["bindir"] +libdir = CONFIG["libdir"] + "/" + ruby_install_name archdir = libdir+"/"+CONFIG["arch"] -mandir = prefix + "/man/man1" +mandir = CONFIG["mandir"] + "/man1" +wdir = Dir.getwd File.makedirs bindir, TRUE File.install "ruby#{binsuffix}", @@ -24,10 +25,10 @@ for dll in Dir['*.dll'] File.install dll, "#{bindir}/#{dll}", 0755, TRUE end -File.makedirs "#{prefix}/lib", TRUE +File.makedirs "#{libdir}", TRUE for lib in ["libruby.so", "libruby.so.LIB"] if File.exist? lib - File.install lib, "#{prefix}/lib", 0644, TRUE + File.install lib, "#{libdir}", 0644, TRUE end end File.makedirs libdir, TRUE @@ -37,13 +38,14 @@ IO.foreach 'MANIFEST' do |$_| $_.chop! if /^lib/ - File.install $_, libdir, 0644, TRUE + File.install $_, "#{libdir}", 0644, TRUE elsif /^[a-z]+\.h$/ - File.install $_, archdir, 0644, TRUE + File.install $_, "#{archdir}", 0644, TRUE end - File.install "config.h", archdir, 0644, TRUE end -File.install "rbconfig.rb", archdir, 0644, TRUE File.makedirs mandir, TRUE -File.install "ruby.1", mandir, 0644, TRUE +File.install "ruby.1", "#{mandir}", 0644, TRUE +Dir.chdir wdir +File.install "config.h", "#{archdir}", 0644, TRUE +File.install "rbconfig.rb", "#{archdir}", 0644, TRUE # vi:set sw=2: ______________________________________________________________________ 笠原 基之(かさはら もとゆき)