summaryrefslogtreecommitdiff
path: root/mkconfig.rb
diff options
context:
space:
mode:
Diffstat (limited to 'mkconfig.rb')
-rw-r--r--mkconfig.rb38
1 files changed, 15 insertions, 23 deletions
diff --git a/mkconfig.rb b/mkconfig.rb
index 175a4c3b15..57c4384983 100644
--- a/mkconfig.rb
+++ b/mkconfig.rb
@@ -6,7 +6,7 @@ rbconfig_rb = ARGV[0] || 'rbconfig.rb'
srcdir = $srcdir if $srcdir
File.makedirs(File.dirname(rbconfig_rb), true)
-version = VERSION
+version = RUBY_VERSION
config = open(rbconfig_rb, "w")
$stdout.reopen(config)
@@ -14,8 +14,8 @@ fast = {'prefix'=>TRUE, 'ruby_install_name'=>TRUE, 'INSTALL'=>TRUE, 'EXEEXT'=>TR
print %[
module Config
- VERSION == "#{version}" or
- raise "ruby lib version (#{version}) doesn't match executable version (\#{VERSION})"
+ RUBY_VERSION == "#{version}" or
+ raise "ruby lib version (#{version}) doesn't match executable version (\#{RUBY_VERSION})"
# 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.
@@ -28,11 +28,11 @@ has_srcdir = false
has_version = false
File.foreach "config.status" do |$_|
next if /^#/
- if /^s%@program_transform_name@%s,(.*)%g$/
+ if /^s[%,]@program_transform_name@[%,]s,(.*)[%,]/
next if $install_name
ptn = $1.sub(/\$\$/, '$').split(/,/) #'
v_fast << " CONFIG[\"ruby_install_name\"] = \"" + "ruby".sub(ptn[0],ptn[1]) + "\"\n"
- elsif /^s%@(\w+)@%(.*)%g/
+ elsif /^s[%,]@(\w+)@[%,](.*)[%,]/
name = $1
val = $2 || ""
next if name =~ /^(INSTALL|DEFS|configure_input|srcdir|top_srcdir)$/
@@ -40,7 +40,7 @@ File.foreach "config.status" do |$_|
next if $so_name and name =~ /^RUBY_SO_NAME$/
v = " CONFIG[\"" + name + "\"] = " +
val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?(\w+)\}?/) {
- "\#{CONFIG[\\\"#{$1}\\\"]}"
+ "$(#{$1})"
} + "\n"
if fast[name]
v_fast << v
@@ -48,20 +48,7 @@ File.foreach "config.status" do |$_|
v_others << v
end
has_version = true if name == "MAJOR"
- if /DEFS/
- val.split(/\s*-D/).each do |i|
- if i =~ /(.*)=(\\")?([^\\]*)(\\")?/
- key, val = $1, $3
- if val == '1'
- val = "TRUE"
- else
- val.sub! /^\s*(.*)\s*$/, '"\1"'
- end
- print " CONFIG[\"#{key}\"] = #{val}\n"
- end
- end
- end
- elsif /^ac_given_srcdir=(.*)/
+ elsif /^(?:ac_given_)?srcdir=(.*)/
v_fast << " CONFIG[\"srcdir\"] = \"" + File.expand_path($1) + "\"\n"
has_srcdir = true
elsif /^ac_given_INSTALL=(.*)/
@@ -71,11 +58,11 @@ File.foreach "config.status" do |$_|
end
if not has_srcdir
- v_fast << " CONFIG[\"srcdir\"] = \"" + File.expand_path(srcdir) + "\"\n"
+ v_fast << " CONFIG[\"srcdir\"] = \"" + File.expand_path(srcdir || '.') + "\"\n"
end
if not has_version
- VERSION.scan(/(\d+)\.(\d+)\.(\d+)/) {
+ RUBY_VERSION.scan(/(\d+)\.(\d+)\.(\d+)/) {
print " CONFIG[\"MAJOR\"] = \"" + $1 + "\"\n"
print " CONFIG[\"MINOR\"] = \"" + $2 + "\"\n"
print " CONFIG[\"TEENY\"] = \"" + $3 + "\"\n"
@@ -102,6 +89,11 @@ end
print v_fast, v_others
print <<EOS
+ CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
+ CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
+ CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
+ CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
+ CONFIG["sitearchdir"] = "$(sitelibdir)/$(arch)"
CONFIG["compile_dir"] = "#{Dir.pwd}"
MAKEFILE_CONFIG = {}
CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
@@ -109,7 +101,7 @@ print <<EOS
val.gsub!(/\\$\\(([^()]+)\\)/) do |var|
key = $1
if CONFIG.key? key
- "\#{Config::expand(CONFIG[\\\"\#{key}\\\"])}"
+ Config::expand(CONFIG[key])
else
var
end