instruby.rb


DEFINITIONS

This source file includes following functions.


   1  #!./miniruby
   2  
   3  load "./rbconfig.rb"
   4  include Config
   5  
   6  File.umask(0)
   7  destdir = ARGV[0] || ''
   8  
   9  $:.unshift CONFIG["srcdir"]+"/lib"
  10  require "ftools"
  11  require "find"
  12  
  13  exeext = CONFIG["EXEEXT"]
  14  if ENV["prefix"]
  15    prefix = ENV["prefix"]
  16  else
  17    prefix = CONFIG["prefix"]
  18  end
  19  
  20  ruby_install_name = CONFIG["ruby_install_name"]
  21  version = "/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
  22  arch = "/"+CONFIG["arch"]
  23  sitearch = "/"+CONFIG["sitearch"]
  24  
  25  bindir = destdir+CONFIG["bindir"]
  26  libdir = destdir+CONFIG["libdir"]
  27  rubylibdir = destdir+CONFIG["prefix"]+"/lib/ruby"+version
  28  archlibdir = rubylibdir+arch
  29  sitelibdir = destdir+CONFIG["sitedir"]+version
  30  sitearchlibdir = sitelibdir+sitearch
  31  mandir = destdir+CONFIG["mandir"] + "/man1"
  32  wdir = Dir.getwd
  33  
  34  File.makedirs bindir, true
  35  File.install ruby_install_name+exeext,
  36    "#{bindir}/#{ruby_install_name}#{exeext}", 0755, true
  37  rubyw = ruby_install_name.sub(/ruby/, '\&w')+exeext
  38  if File.exist? rubyw
  39    File.install rubyw, "#{bindir}/#{rubyw}", 0755, true
  40  end
  41  for dll in Dir['*.dll']
  42    File.install dll, "#{bindir}/#{dll}", 0755, true
  43  end
  44  File.makedirs libdir, true
  45  if CONFIG["LIBRUBY"] != CONFIG["LIBRUBY_A"]
  46    for lib in [CONFIG["LIBRUBY"]]
  47      if File.exist? lib
  48        File.install lib, libdir, 0555, true
  49      end
  50    end
  51  end
  52  Dir.chdir libdir
  53  if File.exist? CONFIG["LIBRUBY_SO"]
  54    for link in CONFIG["LIBRUBY_ALIASES"].split
  55      if File.exist? link
  56         File.delete link
  57      end
  58      File.symlink CONFIG["LIBRUBY_SO"], link
  59      print "link #{CONFIG['LIBRUBY_SO']} -> #{link}\n"
  60    end
  61  end
  62  Dir.chdir wdir
  63  File.makedirs rubylibdir, true
  64  File.makedirs archlibdir, true
  65  File.makedirs sitelibdir, true
  66  File.makedirs sitearchlibdir, true
  67  
  68  if RUBY_PLATFORM =~ /-aix/
  69    File.install "ruby.imp", archlibdir, 0644, true
  70  end
  71  
  72  system "#{CONFIG['MINIRUBY']} #{CONFIG['srcdir']}/ext/extmk.rb install #{destdir}"
  73  
  74  Dir.chdir CONFIG["srcdir"]
  75  
  76  File.install "sample/irb.rb", "#{bindir}/irb", 0755, true
  77  
  78  Find.find("lib") do |f|
  79    next unless /\.rb$/ =~ f || /help-message$/ =~ f
  80    dir = rubylibdir+"/"+File.dirname(f[4..-1])
  81    File.makedirs dir, true unless File.directory? dir
  82    File.install f, dir, 0644, true
  83  end
  84  
  85  for f in Dir["*.h"]
  86    File.install f, archlibdir, 0644, true
  87  end
  88  if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
  89    File.makedirs archlibdir + "/win32", true
  90    File.install "win32/win32.h", archlibdir + "/win32", 0644, true
  91  end
  92  File.install wdir+'/'+CONFIG['LIBRUBY_A'], archlibdir, 0644, true
  93  
  94  File.makedirs mandir, true
  95  File.install "ruby.1", mandir+"/"+ruby_install_name+".1", 0644, true
  96  Dir.chdir wdir
  97  File.install "config.h", archlibdir, 0644, true
  98  File.install "rbconfig.rb", archlibdir, 0644, true
  99  # vi:set sw=2: