From cf8cd080e4e64bec5461093011940a64bd6c3ab6 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 21 Feb 2004 05:33:24 +0000 Subject: [PATCH] * ext/extmk.rb: prefer relative path. [ruby-talk:93037] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ ext/extmk.rb | 36 +++++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a5fd208a8..c0a8344bff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Feb 21 14:33:20 2004 Nobuyoshi Nakada + + * ext/extmk.rb: prefer relative path. [ruby-talk:93037] + Sat Feb 21 11:12:08 2004 Nobuyoshi Nakada * missing/os2.c, missing/x68.c: typo fix. pointed out by greentea. diff --git a/ext/extmk.rb b/ext/extmk.rb index 15dc1b3dc1..c20cd5a93a 100644 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -27,7 +27,7 @@ $:.replace [srcdir, srcdir+"/lib", "."] require 'mkmf' require 'getopts' -$topdir = File.expand_path(".") +$topdir = "." $top_srcdir = srcdir $hdrdir = $top_srcdir @@ -52,7 +52,17 @@ def extmake(target) init_mkmf FileUtils.mkpath target unless File.directory?(target) - Dir.chdir(target) do + begin + dir = Dir.pwd + FileUtils.mkpath target unless File.directory?(target) + Dir.chdir target + top_srcdir = $top_srcdir + topdir = $topdir + prefix = "../" * (target.count("/")+1) + if File.expand_path(top_srcdir) != File.expand_path(top_srcdir, dir) + $hdrdir = $top_srcdir = prefix + top_srcdir + end + $topdir = prefix + $topdir $target = target $mdir = target $srcdir = File.join($top_srcdir, "ext", $mdir) @@ -112,6 +122,10 @@ def extmake(target) $extlibs = merge_libs($extlibs, $libs.split, $LOCAL_LIBS.split) $extpath |= $LIBPATH end + ensure + $hdrdir = $top_srcdir = top_srcdir + $topdir = topdir + Dir.chdir dir end begin Dir.rmdir target @@ -182,11 +196,7 @@ def parse_args() $mflags.defined?("DESTDIR") or $mflags << "DESTDIR=#{$destdir}" end if $extout - $absextout = File.expand_path(Config::expand($extout.dup), $topdir) $extout = '$(topdir)/'+$extout - unless Config::expand($extout.dup) == $absextout - $extout = $absextout - end $extout_prefix = $extout ? "$(extout)$(target_prefix)/" : "" $mflags << "extout=#$extout" << "extout_prefix=#$extout_prefix" end @@ -277,28 +287,36 @@ exts |= Dir.glob("#{ext_prefix}/*/**/MANIFEST").collect {|d| } unless $extension if $extout + Config.expand(extout = $extout+"/.") if $install Config.expand(dest = "#{$destdir}#{$rubylibdir}") - FileUtils.cp_r($absextout+"/.", dest, :verbose => true, :noop => $dryrun) + FileUtils.cp_r(extout, dest, :verbose => true, :noop => $dryrun) exit end unless $ignore - FileUtils.mkpath($absextout) + FileUtils.mkpath(extout) end end +dir = Dir.pwd FileUtils::makedirs('ext') Dir::chdir('ext') +if File.expand_path(srcdir) != File.expand_path(srcdir, dir) + $hdrdir = $top_srcdir = "../" + srcdir +end +$topdir = ".." exts.each do |d| extmake(d) or abort end +$hdrdir = $top_srcdir = srcdir +$topdir = "." if $ignore Dir.chdir ".." if $clean Dir.rmdir('ext') rescue nil - FileUtils.rm_rf($absextout) if $extout + FileUtils.rm_rf(extout) if $extout end exit end