2000-09-01 07:31:05 +04:00
|
|
|
#!./miniruby
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2000-09-01 07:31:05 +04:00
|
|
|
load "./rbconfig.rb"
|
1998-01-16 15:19:09 +03:00
|
|
|
include Config
|
|
|
|
|
2000-12-18 12:46:21 +03:00
|
|
|
File.umask(0)
|
2002-10-22 08:19:26 +04:00
|
|
|
|
|
|
|
while arg = ARGV.shift
|
|
|
|
case arg
|
|
|
|
when /^--/ # ignore
|
|
|
|
when /^-/
|
|
|
|
$dryrun = /n/ =~ arg
|
|
|
|
when /=/ # ignore
|
|
|
|
else
|
|
|
|
destdir ||= arg
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
destdir ||= ''
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2002-11-18 20:26:03 +03:00
|
|
|
$:.unshift File.join(CONFIG["srcdir"], "lib")
|
2002-10-22 08:19:26 +04:00
|
|
|
require 'ftools'
|
2002-10-23 21:40:36 +04:00
|
|
|
require 'shellwords'
|
1998-01-16 15:19:09 +03:00
|
|
|
|
2002-10-22 08:19:26 +04:00
|
|
|
class Installer < File; end
|
|
|
|
class << Installer
|
|
|
|
if $dryrun
|
|
|
|
def makedirs(*dirs)
|
|
|
|
String === dirs.last or dirs.pop
|
|
|
|
for dir in dirs
|
|
|
|
File.directory?(dir) or print "mkdir -p #{dir}\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def install(file, dir, mode = nil, verbose = false)
|
|
|
|
to = catname(file, dir)
|
|
|
|
unless FileTest.exist? to and cmp file, to
|
|
|
|
print "install#{' -m %#o'%mode if mode} #{file} #{dir}\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def makelink(orig, link, verbose = false)
|
|
|
|
unless File.symlink?(link) and File.readlink(link) == orig
|
|
|
|
print "ln -sf #{orig} #{link}\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
require "ftools"
|
|
|
|
def makelink(orig, link, verbose = false)
|
|
|
|
if exist? link
|
|
|
|
delete link
|
|
|
|
end
|
|
|
|
symlink orig, link
|
|
|
|
print "link #{orig} -> #{link}\n"
|
|
|
|
end
|
|
|
|
end
|
1998-01-16 15:19:09 +03:00
|
|
|
end
|
2000-02-17 10:11:22 +03:00
|
|
|
|
2002-10-22 08:19:26 +04:00
|
|
|
exeext = CONFIG["EXEEXT"]
|
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
ruby_install_name = CONFIG["ruby_install_name"]
|
2002-10-22 08:19:26 +04:00
|
|
|
rubyw_install_name = CONFIG["rubyw_install_name"]
|
2000-02-17 10:11:22 +03:00
|
|
|
|
2002-10-22 08:19:26 +04:00
|
|
|
version = CONFIG["ruby_version"]
|
1999-08-13 09:45:20 +04:00
|
|
|
bindir = destdir+CONFIG["bindir"]
|
|
|
|
libdir = destdir+CONFIG["libdir"]
|
2002-10-22 08:19:26 +04:00
|
|
|
rubylibdir = destdir+CONFIG["rubylibdir"]
|
|
|
|
archlibdir = destdir+CONFIG["archdir"]
|
|
|
|
sitelibdir = destdir+CONFIG["sitelibdir"]
|
|
|
|
sitearchlibdir = destdir+CONFIG["sitearchdir"]
|
2002-11-18 20:26:03 +03:00
|
|
|
mandir = File.join(destdir+CONFIG["mandir"], "man1")
|
2002-10-23 21:40:36 +04:00
|
|
|
configure_args = Shellwords.shellwords(CONFIG["configure_args"])
|
2002-11-04 14:06:03 +03:00
|
|
|
enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
|
2002-10-22 08:19:26 +04:00
|
|
|
dll = CONFIG["LIBRUBY_SO"]
|
|
|
|
lib = CONFIG["LIBRUBY"]
|
|
|
|
arc = CONFIG["LIBRUBY_A"]
|
|
|
|
|
|
|
|
Installer.makedirs bindir, libdir, rubylibdir, archlibdir, sitelibdir, sitearchlibdir, mandir, true
|
|
|
|
|
2002-11-18 20:26:03 +03:00
|
|
|
Installer.install ruby_install_name+exeext, File.join(bindir, ruby_install_name+exeext), 0755, true
|
2002-10-22 08:19:26 +04:00
|
|
|
if rubyw_install_name and !rubyw_install_name.empty?
|
|
|
|
Installer.install rubyw_install_name+exeext, bindir, 0755, true
|
1999-01-20 07:59:39 +03:00
|
|
|
end
|
2002-10-23 21:40:36 +04:00
|
|
|
Installer.install dll, bindir, 0755, true if enable_shared and dll != lib
|
2002-10-22 08:19:26 +04:00
|
|
|
Installer.install lib, libdir, 0555, true unless lib == arc
|
2002-11-14 16:51:19 +03:00
|
|
|
Installer.install arc, libdir, 0644, true
|
2002-10-22 08:19:26 +04:00
|
|
|
Installer.install "config.h", archlibdir, 0644, true
|
|
|
|
Installer.install "rbconfig.rb", archlibdir, 0644, true
|
|
|
|
if CONFIG["ARCHFILE"]
|
|
|
|
for file in CONFIG["ARCHFILE"].split
|
|
|
|
Installer.install file, archlibdir, 0644, true
|
1999-01-20 07:59:39 +03:00
|
|
|
end
|
|
|
|
end
|
2002-10-22 08:19:26 +04:00
|
|
|
|
|
|
|
if dll == lib and dll != arc
|
1999-08-13 09:45:20 +04:00
|
|
|
for link in CONFIG["LIBRUBY_ALIASES"].split
|
2002-10-22 08:19:26 +04:00
|
|
|
Installer.makelink(dll, File.join(libdir, link), true)
|
1999-08-13 09:45:20 +04:00
|
|
|
end
|
|
|
|
end
|
2002-09-08 13:08:15 +04:00
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
Dir.chdir CONFIG["srcdir"]
|
1999-08-13 09:45:20 +04:00
|
|
|
|
2002-11-18 20:26:03 +03:00
|
|
|
for src in Dir["bin/*"]
|
|
|
|
next unless File.file?(src)
|
2002-11-18 19:57:36 +03:00
|
|
|
|
2002-11-18 20:26:03 +03:00
|
|
|
name = ruby_install_name.sub(/ruby/, File.basename(src))
|
|
|
|
dest = File.join(bindir, name)
|
2002-11-18 19:57:36 +03:00
|
|
|
|
2002-11-18 20:26:03 +03:00
|
|
|
Installer.install src, dest, 0755, true
|
|
|
|
|
|
|
|
open(dest, "r+") { |f|
|
|
|
|
shebang = f.gets
|
|
|
|
body = f.readlines
|
|
|
|
|
|
|
|
f.rewind
|
|
|
|
|
2002-11-18 20:40:09 +03:00
|
|
|
f.print shebang.sub(/ruby/, ruby_install_name), *body
|
2002-11-18 20:26:03 +03:00
|
|
|
f.truncate(f.pos)
|
2002-11-18 23:09:46 +03:00
|
|
|
} unless $dryrun
|
2002-11-18 19:57:36 +03:00
|
|
|
end
|
2000-07-14 08:34:43 +04:00
|
|
|
|
2002-10-23 21:40:36 +04:00
|
|
|
Dir.glob("lib/**/*{.rb,help-message}") do |f|
|
2002-10-22 08:19:26 +04:00
|
|
|
dir = File.dirname(f).sub!(/\Alib/, rubylibdir) || rubylibdir
|
|
|
|
Installer.makedirs dir, true unless File.directory? dir
|
|
|
|
Installer.install f, dir, 0644, true
|
1999-01-20 07:59:39 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
for f in Dir["*.h"]
|
2002-10-22 08:19:26 +04:00
|
|
|
Installer.install f, archlibdir, 0644, true
|
1999-08-13 09:45:20 +04:00
|
|
|
end
|
2002-06-11 05:27:48 +04:00
|
|
|
if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
|
2002-11-18 20:26:03 +03:00
|
|
|
Installer.makedirs File.join(archlibdir, "win32"), true
|
|
|
|
Installer.install "win32/win32.h", File.join(archlibdir, "win32"), 0644, true
|
1998-01-16 15:19:09 +03:00
|
|
|
end
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2002-10-22 08:19:26 +04:00
|
|
|
Installer.makedirs mandir, true
|
2002-11-18 20:26:03 +03:00
|
|
|
Installer.install "ruby.1", File.join(mandir, ruby_install_name+".1"), 0644, true
|
2002-10-22 08:19:26 +04:00
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
# vi:set sw=2:
|