ext/dl/install.rb


DEFINITIONS

This source file includes following functions.


   1  require 'mkmf'
   2  require 'ftools'
   3  
   4  SO_LIBS = ["dl.so"]
   5  
   6  $ruby_version = CONFIG['MAJOR'] + "." + CONFIG['MINOR']
   7  $prefix = CONFIG['prefix']
   8  $libdir = File.join($prefix,'lib')
   9  $rubylibdir = File.join($libdir, 'ruby', $ruby_version)
  10  $arch = CONFIG['arch']
  11  $archdir = File.join($rubylibdir, $arch)
  12  
  13  def find(dir, match = /./)
  14    Dir.chdir(dir)
  15    files = []
  16    Dir.new(".").each{|file|
  17      if( file != "." && file != ".." )
  18        case File.ftype(file)
  19        when "file"
  20          if( file =~ match )
  21            files.push(File.join(dir,file))
  22          end
  23        when "directory"
  24          files += find(file, match).collect{|f| File.join(dir,f)}
  25        end
  26      end
  27    }
  28    Dir.chdir("..")
  29    return files
  30  end
  31  
  32  def install()
  33    rb_files = find(File.join(".","lib"), /.rb$/)
  34  
  35    SO_LIBS.each{|f|
  36      File.makedirs($rubylibdir, "#{$archdir}")
  37      File.install(f, File.join($archdir,f), 0555, true)
  38    }
  39  
  40    rb_files.each{|f|
  41      origfile = f
  42      instfile = File.join($rubylibdir, origfile.sub("./lib/",""))
  43      instdir  = File.dirname(instfile)
  44      File.makedirs(instdir)
  45      File.install(origfile, instfile, 0644, true)
  46    }
  47  end
  48  
  49  install()