0
+# Copyright (c) 2000-2005 Minero Aoki
0
+# This program is free software.
0
+# You can distribute/modify this program under the terms of
0
+# the GNU LGPL, Lesser General Public License version 2.1.
0
+unless Enumerable.method_defined?(:map) # Ruby 1.4.6
0
+unless File.respond_to?(:read) # Ruby 1.6
0
+unless Errno.const_defined?(:ENOTEMPTY) # Windows?
0
+ # We do not raise this exception, implementation is not needed.
0
+def File.binread(fname)
0
+ open(fname, 'rb') {|f|
0
+# for corrupted Windows' stat(2)
0
+ File.directory?((path[-1,1] == '/') ? path : path + '/')
0
+ def initialize(rbconfig)
0
+ attr_accessor :install_prefix
0
+ attr_accessor :config_opt
0
+ lookup(key).resolve(self)
0
+ @items.map {|i| i.name }
0
+ @table[name] or setup_rb_error "no such config item: #{name}"
0
+ @table[item.name] = item
0
+ @items.delete_if {|i| i.name == name }
0
+ @table.delete_if {|name, i| i.name == name }
0
+ def load_script(path, inst = nil)
0
+ MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path
0
+ File.foreach(savefile()) do |line|
0
+ k, v = *line.split(/=/, 2)
0
+ setup_rb_error $!.message + "\n#{File.basename($0)} config first"
0
+ @items.each {|i| i.value }
0
+ File.open(savefile(), 'w') {|f|
0
+ f.printf "%s=%s\n", i.name, i.value if i.value? and i.value
0
+ def load_standard_entries
0
+ standard_entries(@rbconfig).each do |ent|
0
+ def standard_entries(rbconfig)
0
+ rubypath = File.join(c['bindir'], c['ruby_install_name'] + c['EXEEXT'])
0
+ major = c['MAJOR'].to_i
0
+ minor = c['MINOR'].to_i
0
+ teeny = c['TEENY'].to_i
0
+ version = "#{major}.#{minor}"
0
+ newpath_p = ((major >= 2) or
0
+ ((minor == 4) and (teeny >= 4)))))
0
+ libruby = "#{c['prefix']}/lib/ruby"
0
+ librubyver = c['rubylibdir']
0
+ librubyverarch = c['archdir']
0
+ siteruby = c['sitedir']
0
+ siterubyver = c['sitelibdir']
0
+ siterubyverarch = c['sitearchdir']
0
+ libruby = "#{c['prefix']}/lib/ruby"
0
+ librubyver = "#{c['prefix']}/lib/ruby/#{version}"
0
+ librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
0
+ siteruby = c['sitedir']
0
+ siterubyver = "$siteruby/#{version}"
0
+ siterubyverarch = "$siterubyver/#{c['arch']}"
0
+ libruby = "#{c['prefix']}/lib/ruby"
0
+ librubyver = "#{c['prefix']}/lib/ruby/#{version}"
0
+ librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
0
+ siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby"
0
+ siterubyver = siteruby
0
+ siterubyverarch = "$siterubyver/#{c['arch']}"
0
+ parameterize = lambda {|path|
0
+ path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')
0
+ if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
0
+ makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
0
+ ExecItem.new('installdirs', 'std/site/home',
0
+ 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\
0
+ table['rbdir'] = '$librubyver'
0
+ table['sodir'] = '$librubyverarch'
0
+ table['rbdir'] = '$siterubyver'
0
+ table['sodir'] = '$siterubyverarch'
0
+ setup_rb_error '$HOME was not set' unless ENV['HOME']
0
+ table['prefix'] = ENV['HOME']
0
+ table['rbdir'] = '$libdir/ruby'
0
+ table['sodir'] = '$libdir/ruby'
0
+ PathItem.new('prefix', 'path', c['prefix'],
0
+ 'path prefix of target environment'),
0
+ PathItem.new('bindir', 'path', parameterize.call(c['bindir']),
0
+ 'the directory for commands'),
0
+ PathItem.new('libdir', 'path', parameterize.call(c['libdir']),
0
+ 'the directory for libraries'),
0
+ PathItem.new('datadir', 'path', parameterize.call(c['datadir']),
0
+ 'the directory for shared data'),
0
+ PathItem.new('mandir', 'path', parameterize.call(c['mandir']),
0
+ 'the directory for man pages'),
0
+ PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']),
0
+ 'the directory for system configuration files'),
0
+ PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']),
0
+ 'the directory for local state data'),
0
+ PathItem.new('libruby', 'path', libruby,
0
+ 'the directory for ruby libraries'),
0
+ PathItem.new('librubyver', 'path', librubyver,
0
+ 'the directory for standard ruby libraries'),
0
+ PathItem.new('librubyverarch', 'path', librubyverarch,
0
+ 'the directory for standard ruby extensions'),
0
+ PathItem.new('siteruby', 'path', siteruby,
0
+ 'the directory for version-independent aux ruby libraries'),
0
+ PathItem.new('siterubyver', 'path', siterubyver,
0
+ 'the directory for aux ruby libraries'),
0
+ PathItem.new('siterubyverarch', 'path', siterubyverarch,
0
+ 'the directory for aux ruby binaries'),
0
+ PathItem.new('rbdir', 'path', '$siterubyver',
0
+ 'the directory for ruby scripts'),
0
+ PathItem.new('sodir', 'path', '$siterubyverarch',
0
+ 'the directory for ruby extentions'),
0
+ PathItem.new('rubypath', 'path', rubypath,
0
+ 'the path to set to #! line'),
0
+ ProgramItem.new('rubyprog', 'name', rubypath,
0
+ 'the ruby program using for installation'),
0
+ ProgramItem.new('makeprog', 'name', makeprog,
0
+ 'the make program to compile ruby extentions'),
0
+ SelectItem.new('shebang', 'all/ruby/never', 'ruby',
0
+ 'shebang line (#!) editing mode'),
0
+ BoolItem.new('without-ext', 'yes/no', 'no',
0
+ 'does not compile/install ruby extentions')
0
+ private :standard_entries
0
+ def load_multipackage_entries
0
+ multipackage_entries().each do |ent|
0
+ def multipackage_entries
0
+ PackageSelectionItem.new('with', 'name,name...', '', 'ALL',
0
+ 'package names that you want to install'),
0
+ PackageSelectionItem.new('without', 'name,name...', '', 'NONE',
0
+ 'package names that you do not want to install')
0
+ private :multipackage_entries
0
+ 'std-ruby' => 'librubyver',
0
+ 'stdruby' => 'librubyver',
0
+ 'rubylibdir' => 'librubyver',
0
+ 'archdir' => 'librubyverarch',
0
+ 'site-ruby-common' => 'siteruby', # For backward compatibility
0
+ 'site-ruby' => 'siterubyver', # For backward compatibility
0
+ 'bin-dir' => 'bindir',
0
+ 'bin-dir' => 'bindir',
0
+ 'data-dir' => 'datadir',
0
+ 'ruby-path' => 'rubypath',
0
+ 'ruby-prog' => 'rubyprog',
0
+ 'make-prog' => 'makeprog',
0
+ ALIASES.each do |ali, name|
0
+ @table[ali] = @table[name]
0
+ @options_re = /\A--(#{@table.keys.join('|')})(?:=(.*))?\z/
0
+ m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}"