1998-01-16 07:19:09 -05:00
|
|
|
#!./miniruby
|
|
|
|
|
|
|
|
require File.dirname($0)+"/lib/ftools"
|
|
|
|
|
|
|
|
rbconfig_rb = ARGV[0] || 'rbconfig.rb'
|
|
|
|
File.makedirs(File.dirname(rbconfig_rb), true)
|
|
|
|
|
|
|
|
version = VERSION
|
|
|
|
config = open(rbconfig_rb, "w")
|
|
|
|
$stdout.reopen(config)
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
fast = {'prefix'=>TRUE, 'INSTALL'=>TRUE, 'EXEEXT'=>TRUE}
|
1998-01-16 07:19:09 -05:00
|
|
|
print %[
|
|
|
|
module Config
|
|
|
|
|
|
|
|
VERSION == "#{version}" or
|
|
|
|
raise "ruby lib version (#{version}) doesn't match executable version (\#{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.
|
|
|
|
]
|
|
|
|
|
|
|
|
print " CONFIG = {}\n"
|
|
|
|
v_fast = []
|
|
|
|
v_others = []
|
1999-08-13 01:45:20 -04:00
|
|
|
has_version = false
|
1998-01-16 07:19:09 -05:00
|
|
|
File.foreach "config.status" do |$_|
|
|
|
|
next if /^#/
|
|
|
|
if /^s%@program_transform_name@%s,(.*)%g$/
|
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"
|
|
|
|
elsif /^s%@(\w+)@%(.*)%g/
|
|
|
|
name = $1
|
|
|
|
val = $2 || ""
|
|
|
|
next if name =~ /^(INSTALL|DEFS|configure_input|srcdir|top_srcdir)$/
|
|
|
|
v = " CONFIG[\"" + name + "\"] = " +
|
1999-08-13 01:45:20 -04:00
|
|
|
val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?([^(){}]+)\}?/) {
|
1998-01-16 07:19:09 -05:00
|
|
|
"\#{CONFIG[\\\"#{$1}\\\"]}"
|
|
|
|
} + "\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"
|
1998-01-16 07:19:09 -05:00
|
|
|
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=(.*)/
|
1999-08-13 01:45:20 -04:00
|
|
|
v_fast << " CONFIG[\"srcdir\"] = \"" + File.expand_path($1) + "\"\n"
|
1998-01-16 07:19:09 -05:00
|
|
|
elsif /^ac_given_INSTALL=(.*)/
|
|
|
|
v_fast << " CONFIG[\"INSTALL\"] = " + $1 + "\n"
|
|
|
|
end
|
|
|
|
# break if /^CEOF/
|
|
|
|
end
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
if not has_version
|
|
|
|
VERSION.scan(/(\d+)\.(\d+)\.(\d+)/) {
|
|
|
|
print " CONFIG[\"MAJOR\"] = \"" + $1 + "\"\n"
|
|
|
|
print " CONFIG[\"MINOR\"] = \"" + $2 + "\"\n"
|
|
|
|
print " CONFIG[\"TEENY\"] = \"" + $3 + "\"\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
|
|
|
|
CONFIG["compile_dir"] = "#{Dir.pwd}"
|
1999-12-02 01:58:52 -05:00
|
|
|
MAKEFILE_CONFIG = {}
|
|
|
|
CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
|
|
|
|
def Config::expand(val)
|
1999-08-13 01:45:20 -04:00
|
|
|
val.gsub!(/\\$\\(([^()]+)\\)/) do |var|
|
|
|
|
key = $1
|
|
|
|
if CONFIG.key? key
|
1999-12-02 01:58:52 -05:00
|
|
|
"\#{Config::expand(CONFIG[\\\"\#{key}\\\"])}"
|
1999-08-13 01:45:20 -04:00
|
|
|
else
|
|
|
|
var
|
|
|
|
end
|
|
|
|
end
|
1999-12-02 01:58:52 -05:00
|
|
|
val
|
|
|
|
end
|
|
|
|
CONFIG.each_value do |val|
|
|
|
|
Config::expand(val)
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
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:
|