1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
--- bin/install.rb.orig Mon Mar 24 07:10:57 2003
+++ bin/install.rb Thu Oct 13 12:05:17 2005
@@ -1,21 +1,39 @@
require 'rbconfig'
require 'find'
require 'ftools'
+require 'getoptlong'
+
+def usage( exit_code = 1 )
+ printf "Usage: #{ARGV[0]} [--path <PATH>]\n"
+ exit( exit_code )
+end
Dir.chdir ".." if Dir.pwd =~ /bin.?$/
+opts = GetoptLong.new( ["--prefix", "-p", GetoptLong::REQUIRED_ARGUMENT ] )
+$my_prefix = nil
+opts.each { |opt, arg|
+ case opt
+ when "--prefix"
+ $my_prefix = arg
+ else
+ usage()
+ end
+}
+
+def prefixize( str )
+ $my_prefix ?
+ str.gsub( Regexp::compile( "^#{Regexp::escape($prefix)}" ), $my_prefix ) :
+ str
+end
+
include Config
-$srcdir = CONFIG["srcdir"]
+$prefix = CONFIG["prefix"]
$version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
-$libdir = File.join(CONFIG["libdir"], "ruby", $version)
-$archdir = File.join($libdir, CONFIG["arch"])
-$site_libdir = $:.find {|x| x =~ /site_ruby$/}
-if !$site_libdir
- $site_libdir = File.join($libdir, "site_ruby")
-elsif $site_libdir !~ Regexp.quote($version)
- $site_libdir = File.join($site_libdir, $version)
-end
+$libdir = prefixize( CONFIG["rubylibdir"] )
+$archdir = prefixize( CONFIG["archdir"] )
+$site_libdir = prefixize( CONFIG["sitelibdir"] )
def install_rb(srcdir = nil)
libdir = "lib"
@@ -39,4 +57,4 @@
end
end
-install_rb
\ No newline at end of file
+install_rb
|