summaryrefslogtreecommitdiff
path: root/ext/configsub.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/configsub.rb')
-rw-r--r--ext/configsub.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/ext/configsub.rb b/ext/configsub.rb
new file mode 100644
index 0000000000..315cdaf868
--- /dev/null
+++ b/ext/configsub.rb
@@ -0,0 +1,32 @@
+#!./miniruby -ps
+
+BEGIN {
+ CONFIG = {}
+
+ VERSION.scan(/(\d+)\.(\d+)\.(\d+)/) do
+ # overridden if config.status has version
+ CONFIG['MAJOR'] = $1
+ CONFIG['MINOR'] = $2
+ CONFIG['TEENY'] = $3
+ end
+
+ File.foreach($config || "config.status") do |$_|
+ next if /^#/
+ if /^s%@(\w+)@%(.*)%g/
+ name = $1
+ val = $2 || ""
+ next if /^(INSTALL|DEFS|configure_input|srcdir)$/ =~ name
+ val.gsub!(/\$\{([^{}]+)\}/) { "$(#{$1})" }
+ CONFIG[name] = val
+ end
+ end
+
+ CONFIG['top_srcdir'] = File.expand_path($srcdir || ".")
+ CONFIG['RUBY_INSTALL_NAME'] = $install_name if $install_name
+ CONFIG['RUBY_SO_NAME'] = $so_name if $so_name
+ $defout = open($output, 'w') if $output
+}
+
+gsub!(/@(\w+)@/) {CONFIG[$1] || $&}
+
+# vi:set sw=2: