ext/configsub.rb


DEFINITIONS

This source file includes following functions.


   1  #!./miniruby -ps
   2  
   3  BEGIN {
   4    CONFIG = {}
   5  
   6    RUBY_VERSION.scan(/(\d+)\.(\d+)\.(\d+)/) do
   7      # overridden if config.status has version
   8      CONFIG['MAJOR'] = $1
   9      CONFIG['MINOR'] = $2
  10      CONFIG['TEENY'] = $3
  11    end
  12  
  13    File.foreach($config || "config.status") do |line|
  14      next if /^#/ =~ line
  15      if /^s[%,]@(\w+)@[%,](.*)[%,][g;]/ =~ line
  16        name = $1
  17        val = $2 || ""
  18        next if /^(INSTALL|DEFS|configure_input|srcdir)$/ =~ name
  19        val.gsub!(/\$\{([^{}]+)\}/) { "$(#{$1})" }
  20        CONFIG[name] = val
  21      end
  22    end
  23  
  24    CONFIG['top_srcdir'] = File.expand_path($srcdir || ".")
  25    CONFIG['RUBY_INSTALL_NAME'] = $install_name if $install_name
  26    CONFIG['RUBY_SO_NAME'] = $so_name if $so_name
  27    $defout = open($output, 'w') if $output
  28  }
  29  
  30  gsub!(/@(\w+)@/) {CONFIG[$1] || $&}
  31  
  32  # vi:set sw=2: