From 311fdfdfeaceb581c51602f5aeeff40c12567a78 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 18 Mar 2004 09:50:14 +0000 Subject: * mkconfig.rb: no longer embed srcdir and compile_dir into rbconfig.rb. * ext/extmk.rb, lib/mkmf.rb: obtain top_srcdir and topdir from library paths. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/extmk.rb | 30 ++++++++++++++++-------------- lib/mkmf.rb | 16 ++++++++-------- mkconfig.rb | 9 +-------- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0340cb72de..79863e30e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Mar 18 18:50:06 2004 Nobuyoshi Nakada + + * mkconfig.rb: no longer embed srcdir and compile_dir into + rbconfig.rb. + + * ext/extmk.rb, lib/mkmf.rb: obtain top_srcdir and topdir from library + paths. + Thu Mar 18 17:46:35 2004 Masatoshi SEKI * lib/drb/drb.rb: do not undef :to_a. diff --git a/ext/extmk.rb b/ext/extmk.rb index 3e530e7316..427313bd58 100644 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -20,22 +20,29 @@ $extlist = [] $:.replace ["."] require 'rbconfig' -srcdir = Config::CONFIG["srcdir"] +srcdir = File.dirname(File.dirname(__FILE__)) $:.replace [srcdir, srcdir+"/lib", "."] -require 'mkmf' -require 'optparse/shellwords' - $topdir = "." $top_srcdir = srcdir -$hdrdir = $top_srcdir + +require 'mkmf' +require 'optparse/shellwords' def sysquote(x) @quote ||= /human|os2|macos/ =~ (CROSS_COMPILING || RUBY_PLATFORM) @quote ? x.quote : x end +def relative_from(path, base) + if File.expand_path(path) == File.expand_path(path, base) + path + else + File.join(base, path) + end +end + def extmake(target) print "#{$message} #{target}\n" $stdout.flush @@ -59,9 +66,7 @@ def extmake(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 + $hdrdir = $top_srcdir = relative_from(top_srcdir, prefix) $topdir = prefix + $topdir $target = target $mdir = target @@ -239,7 +244,7 @@ elsif $nmake else $ruby = '$(topdir)/miniruby' + EXEEXT end -$ruby << " -I$(topdir) -I$(hdrdir)/lib" +$ruby << " -I'$(topdir)' -I'$(hdrdir)/lib'" $config_h = '$(topdir)/config.h' MTIMES = [__FILE__, 'rbconfig.rb', srcdir+'/lib/mkmf.rb'].collect {|f| File.mtime(f)} @@ -289,7 +294,7 @@ exts |= Dir.glob("#{ext_prefix}/*/**/MANIFEST").collect {|d| } unless $extension if $extout - Config.expand(extout = $extout+"/.") + Config.expand(extout = $extout+"/.", Config::CONFIG.merge("topdir"=>$topdir)) if $install Config.expand(dest = "#{$destdir}#{$rubylibdir}") FileUtils.cp_r(extout, dest, :verbose => true, :noop => $dryrun) @@ -304,10 +309,7 @@ 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 = ".." +$hdrdir = $top_srcdir = relative_from(srcdir, $topdir = "..") exts.each do |d| extmake(d) or abort end diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 39da5dfeb4..7561edaad9 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -38,7 +38,6 @@ unless defined? $configure_args end end -$srcdir = CONFIG["srcdir"] $libdir = CONFIG["libdir"] $rubylibdir = CONFIG["rubylibdir"] $archdir = CONFIG["archdir"] @@ -77,12 +76,13 @@ def map_dir(dir, map = nil) map.inject(dir) {|dir, (orig, new)| dir.gsub(orig, new)} end -if not $extmk and File.exist?(Config::CONFIG["archdir"] + "/ruby.h") +libdir = File.dirname(__FILE__) +if libdir == Config::CONFIG["rubylibdir"] and + File.exist?(Config::CONFIG["archdir"] + "/ruby.h") $topdir = $hdrdir = $archdir -elsif File.exist?($srcdir + "/ruby.h") and - File.exist?((compile_dir = Config::CONFIG['compile_dir']) + "/config.h") - $hdrdir = $srcdir - $topdir = compile_dir +elsif File.exist?(($top_srcdir ||= File.dirname(libdir)) + "/ruby.h") and + File.exist?(($topdir ||= Config::CONFIG["topdir"]) + "/config.h") + $hdrdir = $top_srcdir else abort "can't find header files for ruby." end @@ -728,7 +728,7 @@ end def configuration(srcdir) mk = [] vpath = %w[$(srcdir) $(topdir) $(hdrdir)] - if $mingw && CONFIG['build_os'] == 'cygwin' + if !CROSS_COMPILING && CONFIG['build_os'] == 'cygwin' && CONFIG['target_os'] != 'cygwin' vpath.each {|p| p.sub!(/.*/, '$(shell cygpath -u \&)')} end mk << %{ @@ -739,7 +739,7 @@ SHELL = /bin/sh srcdir = #{srcdir} topdir = #{$topdir} hdrdir = #{$hdrdir} -VPATH = #{vpath.join(File::PATH_SEPARATOR)} +VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])} } drive = File::PATH_SEPARATOR == ';' ? /\A\w:/ : /\A/ if destdir = CONFIG["prefix"].scan(drive)[0] and !destdir.empty? diff --git a/mkconfig.rb b/mkconfig.rb index ef54287db5..08f8dc166e 100644 --- a/mkconfig.rb +++ b/mkconfig.rb @@ -1,7 +1,6 @@ #!./miniruby -s # avoid warnings with -d. -$srcdir ||= nil $install_name ||= nil $so_name ||= nil @@ -9,7 +8,6 @@ require File.dirname($0)+"/lib/fileutils" mkconfig = File.basename($0) rbconfig_rb = ARGV[0] || 'rbconfig.rb' -srcdir = $srcdir || '.' unless File.directory?(dir = File.dirname(rbconfig_rb)) FileUtils.makedirs(dir, :verbose => true) end @@ -54,17 +52,12 @@ File.foreach "config.status" do |line| v_others << v end has_version = true if name == "MAJOR" - elsif /^(?:ac_given_)?srcdir=(.*)/ =~ line - srcdir = $1.strip elsif /^ac_given_INSTALL=(.*)/ =~ line v_fast << " CONFIG[\"INSTALL\"] = " + $1 + "\n" end # break if /^CEOF/ end -srcdir = File.expand_path(srcdir) -v_fast.unshift(" CONFIG[\"srcdir\"] = \"" + srcdir + "\"\n") - v_fast.collect! do |x| if /"prefix"/ === x x.sub(/= (.*)/, '= (TOPDIR || DESTDIR + \1)') @@ -113,7 +106,7 @@ print <