2000-08-03 05:50:41 -04:00
|
|
|
#!./miniruby -s
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
|
|
require File.dirname($0)+"/lib/ftools"
|
|
|
|
|
|
|
|
rbconfig_rb = ARGV[0] || 'rbconfig.rb'
|
2000-08-03 05:50:41 -04:00
|
|
|
srcdir = $srcdir if $srcdir
|
1998-01-16 07:19:09 -05:00
|
|
|
File.makedirs(File.dirname(rbconfig_rb), true)
|
|
|
|
|
2001-05-31 00:40:37 -04:00
|
|
|
version = RUBY_VERSION
|
1998-01-16 07:19:09 -05:00
|
|
|
config = open(rbconfig_rb, "w")
|
|
|
|
$stdout.reopen(config)
|
|
|
|
|
2000-08-03 05:50:41 -04:00
|
|
|
fast = {'prefix'=>TRUE, 'ruby_install_name'=>TRUE, 'INSTALL'=>TRUE, 'EXEEXT'=>TRUE}
|
1998-01-16 07:19:09 -05:00
|
|
|
print %[
|
|
|
|
module Config
|
|
|
|
|
2001-05-31 00:40:37 -04:00
|
|
|
RUBY_VERSION == "#{version}" or
|
|
|
|
raise "ruby lib version (#{version}) doesn't match executable version (\#{RUBY_VERSION})"
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
|
|
# This file was created by configrb when ruby was built. Any changes
|
|
|
|
# made to this file will be lost the next time ruby is built.
|
|
|
|
]
|
|
|
|
|
2000-06-18 23:37:55 -04:00
|
|
|
print " DESTDIR = '' if not defined? DESTDIR\n CONFIG = {}\n"
|
1998-01-16 07:19:09 -05:00
|
|
|
v_fast = []
|
|
|
|
v_others = []
|
2000-08-03 05:50:41 -04:00
|
|
|
has_srcdir = false
|
1999-08-13 01:45:20 -04:00
|
|
|
has_version = false
|
2000-12-28 00:00:47 -05:00
|
|
|
File.foreach "config.status" do |line|
|
|
|
|
next if /^#/ =~ line
|
2001-01-22 02:37:14 -05:00
|
|
|
if /^s[%,]@program_transform_name@[%,]s,(.*)[%,]/ =~ line
|
2000-08-03 05:50:41 -04:00
|
|
|
next if $install_name
|
1999-01-19 23:59:39 -05:00
|
|
|
ptn = $1.sub(/\$\$/, '$').split(/,/) #'
|
1998-01-16 07:19:09 -05:00
|
|
|
v_fast << " CONFIG[\"ruby_install_name\"] = \"" + "ruby".sub(ptn[0],ptn[1]) + "\"\n"
|
2001-01-22 02:37:14 -05:00
|
|
|
elsif /^s[%,]@(\w+)@[%,](.*)[%,]/ =~ line
|
1998-01-16 07:19:09 -05:00
|
|
|
name = $1
|
|
|
|
val = $2 || ""
|
2000-12-28 00:00:47 -05:00
|
|
|
next if /^(INSTALL|DEFS|configure_input|srcdir|top_srcdir)$/ =~ name
|
|
|
|
next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name
|
|
|
|
next if $so_name and /^RUBY_SO_NAME$/ =~ name
|
1998-01-16 07:19:09 -05:00
|
|
|
v = " CONFIG[\"" + name + "\"] = " +
|
2000-09-27 03:22:17 -04:00
|
|
|
val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?(\w+)\}?/) {
|
2001-05-07 05:26:29 -04:00
|
|
|
"$(#{$1})"
|
1998-01-16 07:19:09 -05:00
|
|
|
} + "\n"
|
|
|
|
if fast[name]
|
|
|
|
v_fast << v
|
|
|
|
else
|
|
|
|
v_others << v
|
|
|
|
end
|
1999-08-13 01:45:20 -04:00
|
|
|
has_version = true if name == "MAJOR"
|
2001-05-24 21:33:03 -04:00
|
|
|
elsif /^(?:ac_given_)?srcdir=(.*)/ =~ line
|
1999-08-13 01:45:20 -04:00
|
|
|
v_fast << " CONFIG[\"srcdir\"] = \"" + File.expand_path($1) + "\"\n"
|
2000-08-03 05:50:41 -04:00
|
|
|
has_srcdir = true
|
2000-12-28 00:00:47 -05:00
|
|
|
elsif /^ac_given_INSTALL=(.*)/ =~ line
|
1998-01-16 07:19:09 -05:00
|
|
|
v_fast << " CONFIG[\"INSTALL\"] = " + $1 + "\n"
|
|
|
|
end
|
|
|
|
# break if /^CEOF/
|
|
|
|
end
|
|
|
|
|
2000-08-03 05:50:41 -04:00
|
|
|
if not has_srcdir
|
2001-05-24 03:13:56 -04:00
|
|
|
v_fast << " CONFIG[\"srcdir\"] = \"" + File.expand_path(srcdir || '.') + "\"\n"
|
2000-08-03 05:50:41 -04:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
if not has_version
|
2001-05-31 00:40:37 -04:00
|
|
|
RUBY_VERSION.scan(/(\d+)\.(\d+)\.(\d+)/) {
|
1999-08-13 01:45:20 -04:00
|
|
|
print " CONFIG[\"MAJOR\"] = \"" + $1 + "\"\n"
|
|
|
|
print " CONFIG[\"MINOR\"] = \"" + $2 + "\"\n"
|
|
|
|
print " CONFIG[\"TEENY\"] = \"" + $3 + "\"\n"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2000-06-18 23:37:55 -04:00
|
|
|
v_fast.collect! do |x|
|
|
|
|
if /"prefix"/ === x
|
2000-08-03 05:50:41 -04:00
|
|
|
prefix = Regexp.quote('/lib/ruby/' + RUBY_VERSION.sub(/\.\d+$/, '') + '/' + RUBY_PLATFORM)
|
|
|
|
puts " TOPDIR = File.dirname(__FILE__).sub!(%r'#{prefix}\\Z', '')"
|
|
|
|
x.sub(/= (.*)/, '= (TOPDIR || DESTDIR + \1)')
|
2000-06-18 23:37:55 -04:00
|
|
|
else
|
|
|
|
x
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2000-08-03 05:50:41 -04:00
|
|
|
if $install_name
|
|
|
|
v_fast << " CONFIG[\"ruby_install_name\"] = \"" + $install_name + "\"\n"
|
|
|
|
v_fast << " CONFIG[\"RUBY_INSTALL_NAME\"] = \"" + $install_name + "\"\n"
|
|
|
|
end
|
|
|
|
if $so_name
|
|
|
|
v_fast << " CONFIG[\"RUBY_SO_NAME\"] = \"" + $so_name + "\"\n"
|
|
|
|
end
|
|
|
|
|
1998-01-16 07:19:09 -05:00
|
|
|
print v_fast, v_others
|
1999-08-13 01:45:20 -04:00
|
|
|
print <<EOS
|
2001-05-07 05:26:29 -04:00
|
|
|
CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
|
|
|
|
CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
|
|
|
|
CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
|
|
|
|
CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
|
|
|
|
CONFIG["sitearchdir"] = "$(sitelibdir)/$(arch)"
|
1999-08-13 01:45:20 -04:00
|
|
|
CONFIG["compile_dir"] = "#{Dir.pwd}"
|
2000-07-31 05:43:14 -04:00
|
|
|
MAKEFILE_CONFIG = {}
|
|
|
|
CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
|
|
|
|
def Config::expand(val)
|
|
|
|
val.gsub!(/\\$\\(([^()]+)\\)/) do |var|
|
|
|
|
key = $1
|
|
|
|
if CONFIG.key? key
|
2001-05-07 05:26:29 -04:00
|
|
|
Config::expand(CONFIG[key])
|
2000-07-31 05:43:14 -04:00
|
|
|
else
|
|
|
|
var
|
|
|
|
end
|
|
|
|
end
|
|
|
|
val
|
|
|
|
end
|
|
|
|
CONFIG.each_value do |val|
|
|
|
|
Config::expand(val)
|
|
|
|
end
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
EOS
|
1998-01-16 07:19:09 -05:00
|
|
|
config.close
|
1999-08-13 01:45:20 -04:00
|
|
|
|
1998-01-16 07:19:09 -05:00
|
|
|
# vi:set sw=2:
|