2016-07-02 17:01:04 -04:00
|
|
|
# Used by Makefile and configure for building Ruby.
|
|
|
|
# See common.mk and Makefile.in for details.
|
|
|
|
|
2014-07-06 01:20:10 -04:00
|
|
|
class File
|
|
|
|
sep = ("\\" if RUBY_PLATFORM =~ /mswin|bccwin|mingw/)
|
|
|
|
if sep != ALT_SEPARATOR
|
|
|
|
remove_const :ALT_SEPARATOR
|
|
|
|
ALT_SEPARATOR = sep
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-04 11:27:02 -04:00
|
|
|
static = !!(defined?($static) && $static)
|
2014-07-06 01:20:10 -04:00
|
|
|
$:.unshift(builddir)
|
|
|
|
posthook = proc do
|
2015-09-04 06:06:49 -04:00
|
|
|
config = RbConfig::CONFIG
|
2014-07-06 01:20:10 -04:00
|
|
|
mkconfig = RbConfig::MAKEFILE_CONFIG
|
|
|
|
extout = File.expand_path(mkconfig["EXTOUT"], builddir)
|
2015-09-04 06:06:49 -04:00
|
|
|
[
|
|
|
|
["top_srcdir", $top_srcdir],
|
|
|
|
["topdir", $topdir],
|
|
|
|
].each do |var, val|
|
|
|
|
next unless val
|
|
|
|
mkconfig[var] = config[var] = val
|
|
|
|
t = /\A#{Regexp.quote(val)}(?=\/)/
|
|
|
|
$hdrdir.sub!(t) {"$(#{var})"}
|
|
|
|
mkconfig.keys.grep(/dir\z/) do |k|
|
|
|
|
mkconfig[k] = "$(#{var})#$'" if t =~ mkconfig[k]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if $extmk
|
|
|
|
$ruby = "$(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'"
|
|
|
|
else
|
|
|
|
$ruby = baseruby
|
|
|
|
end
|
|
|
|
$static = static
|
2014-07-06 01:20:10 -04:00
|
|
|
untrace_var(:$ruby, posthook)
|
|
|
|
end
|
|
|
|
prehook = proc do |extmk|
|
2015-09-04 06:06:49 -04:00
|
|
|
pat = %r[(?:\A(?:\w:|//[^/]+)|\G)/[^/]*]
|
|
|
|
dir = builddir.scan(pat)
|
|
|
|
pwd = Dir.pwd.scan(pat)
|
|
|
|
if dir[0] == pwd[0]
|
|
|
|
while dir[0] and dir[0] == pwd[0]
|
|
|
|
dir.shift
|
|
|
|
pwd.shift
|
|
|
|
end
|
2015-11-03 20:32:54 -05:00
|
|
|
builddir = File.join((pwd.empty? ? ["."] : [".."]*pwd.size) + dir)
|
2015-09-04 22:00:34 -04:00
|
|
|
builddir = "." if builddir.empty?
|
2014-07-06 01:20:10 -04:00
|
|
|
end
|
2015-09-05 08:29:29 -04:00
|
|
|
join = proc {|*args| File.join(*args).sub!(/\A(?:\.\/)*/, '')}
|
2015-09-04 06:06:49 -04:00
|
|
|
$topdir ||= builddir
|
2015-12-05 03:48:28 -05:00
|
|
|
$top_srcdir ||= (File.identical?(top_srcdir, dir = join[$topdir, srcdir]) ?
|
|
|
|
dir : top_srcdir)
|
2015-09-04 06:06:49 -04:00
|
|
|
$extout = '$(topdir)/.ext'
|
|
|
|
$extout_prefix = '$(extout)$(target_prefix)/'
|
|
|
|
config = RbConfig::CONFIG
|
|
|
|
mkconfig = RbConfig::MAKEFILE_CONFIG
|
|
|
|
mkconfig["builddir"] = config["builddir"] = builddir
|
2016-05-25 02:05:47 -04:00
|
|
|
mkconfig["buildlibdir"] = config["buildlibdir"] = builddir
|
2017-12-26 20:26:22 -05:00
|
|
|
mkconfig["libdir"] = config["libdir"] = builddir
|
2015-09-04 06:06:49 -04:00
|
|
|
mkconfig["top_srcdir"] = $top_srcdir if $top_srcdir
|
2016-04-06 21:33:04 -04:00
|
|
|
mkconfig["extout"] ||= $extout
|
2015-09-04 06:06:49 -04:00
|
|
|
config["top_srcdir"] = File.expand_path($top_srcdir ||= top_srcdir)
|
2015-09-05 08:29:29 -04:00
|
|
|
config["rubyhdrdir"] = join[$top_srcdir, "include"]
|
|
|
|
config["rubyarchhdrdir"] = join[builddir, config["EXTOUT"], "include", config["arch"]]
|
2016-04-06 21:33:04 -04:00
|
|
|
config["extout"] ||= join[$topdir, ".ext"]
|
2016-05-25 02:05:47 -04:00
|
|
|
mkconfig["libdirname"] = "buildlibdir"
|
2015-09-04 06:06:49 -04:00
|
|
|
trace_var(:$ruby, posthook)
|
2014-07-06 01:20:10 -04:00
|
|
|
untrace_var(:$extmk, prehook)
|
|
|
|
end
|
|
|
|
trace_var(:$extmk, prehook)
|