diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-03 02:05:57 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-03 02:05:57 +0000 |
commit | 341ae6ac3ed239acf5322192c4c70c8fbac88bcd (patch) | |
tree | 9ef04f87541467f60f94422bd14ddc69f8a77fa7 /ext | |
parent | f3a1a4a4ba1d36dcfa79bc7be8a4fd56ff5ab40d (diff) | |
download | ruby-341ae6ac3ed239acf5322192c4c70c8fbac88bcd.tar.gz |
* ext/extmk.rb (extmake): save all CONFIG values.
* ext/extmk.rb (extmake): remove mkmf.log at clean, and extconf.h at
distclean, respectively.
* ext/extmk.rb: remove rdoc at clean, and installed list file at
distclean, respectively.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/extmk.rb | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/ext/extmk.rb b/ext/extmk.rb index 1c34fa0aa1..a237efdeab 100644 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -113,8 +113,6 @@ def extmake(target) top_srcdir = $top_srcdir topdir = $topdir hdrdir = $hdrdir - mk_srcdir = CONFIG["srcdir"] - mk_topdir = CONFIG["topdir"] prefix = "../" * (target.count("/")+1) $top_srcdir = relative_from(top_srcdir, prefix) $hdrdir = relative_from(hdrdir, prefix) @@ -129,12 +127,30 @@ def extmake(target) makefile = "./Makefile" ok = File.exist?(makefile) unless $ignore - RbConfig::CONFIG["hdrdir"] = $hdrdir - RbConfig::CONFIG["srcdir"] = $srcdir - RbConfig::CONFIG["topdir"] = $topdir - CONFIG["hdrdir"] = ($hdrdir == top_srcdir) ? top_srcdir : "$(top_srcdir)/include" - CONFIG["srcdir"] = "$(top_srcdir)/ext/#{$mdir}" - CONFIG["topdir"] = $topdir + rbconfig0 = RbConfig::CONFIG + mkconfig0 = CONFIG + rbconfig = { + "hdrdir" => $hdrdir, + "srcdir" => $srcdir, + "topdir" => $topdir, + } + mkconfig = { + "hdrdir" => ($hdrdir == top_srcdir) ? top_srcdir : "$(top_srcdir)/include", + "srcdir" => "$(top_srcdir)/ext/#{$mdir}", + "topdir" => $topdir, + } + rbconfig0.each_pair {|key, val| rbconfig[key] ||= val.dup} + mkconfig0.each_pair {|key, val| mkconfig[key] ||= val.dup} + RbConfig.module_eval { + remove_const(:CONFIG) + const_set(:CONFIG, rbconfig) + remove_const(:MAKEFILE_CONFIG) + const_set(:MAKEFILE_CONFIG, mkconfig) + } + Object.class_eval { + remove_const(:CONFIG) + const_set(:CONFIG, mkconfig) + } begin $extconf_h = nil ok &&= extract_makefile(makefile) @@ -183,8 +199,11 @@ def extmake(target) $ignore or $continue or return false end $compiled[target] = true - if $clean and $clean != true - File.unlink(makefile) rescue nil + if $clean + FileUtils.rm_f("mkmf.log") + if $clean != true + FileUtils.rm_f([makefile, $extconf_h || "extconf.h"]) + end end if $static $extflags ||= "" @@ -197,11 +216,18 @@ def extmake(target) $extpath |= $LIBPATH end ensure - RbConfig::CONFIG["srcdir"] = $top_srcdir - RbConfig::CONFIG["topdir"] = topdir - CONFIG["srcdir"] = mk_srcdir - CONFIG["topdir"] = mk_topdir - CONFIG.delete("hdrdir") + unless $ignore + RbConfig.module_eval { + remove_const(:CONFIG) + const_set(:CONFIG, rbconfig0) + remove_const(:MAKEFILE_CONFIG) + const_set(:MAKEFILE_CONFIG, mkconfig0) + } + Object.class_eval { + remove_const(:CONFIG) + const_set(:CONFIG, mkconfig0) + } + end $top_srcdir = top_srcdir $topdir = topdir $hdrdir = hdrdir @@ -428,10 +454,11 @@ if $ignore if $clean Dir.rmdir('ext') rescue nil if $extout - FileUtils.rm_rf([extout+"/common", extout+"/include/ruby"]) + FileUtils.rm_rf([extout+"/common", extout+"/include/ruby", extout+"/rdoc"]) FileUtils.rm_rf(extout+"/"+CONFIG["arch"]) if $clean != true FileUtils.rm_rf(extout+"/include/"+CONFIG["arch"]) + FileUtils.rm_f($mflags.defined?("INSTALLED_LIST")||ENV["INSTALLED_LIST"]||".installed.list") Dir.rmdir(extout+"/include") rescue nil Dir.rmdir(extout) rescue nil end |