2000-08-31 23:31:05 -04:00
|
|
|
#!./miniruby
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2000-08-31 23:31:05 -04:00
|
|
|
load "./rbconfig.rb"
|
* mkconfig.rb: generate RbConfig instead of Config.
* instruby.rb, rubytest.rb, runruby.rb, bcc32/Makefile.sub,
ext/extmk.rb, ext/dl/extconf.rb, ext/iconv/charset_alias.rb,
lib/mkmf.rb, lib/rdoc/ri/ri_paths.rb,
lib/webrick/httpservlet/cgihandler.rb,
test/dbm/test_dbm.rb, test/gdbm/test_gdbm.rb,
test/ruby/envutil.rb, test/soap/calc/test_calc_cgi.rb,
test/soap/header/test_authheader_cgi.rb, test/soap/ssl/test_ssl.rb,
win32/mkexports.rb, win32/resource.rb: Use RbConfig instead of
Config.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-02-20 03:34:53 -05:00
|
|
|
include RbConfig
|
2008-10-24 10:05:49 -04:00
|
|
|
$".unshift File.expand_path("./rbconfig.rb")
|
1998-01-16 07:19:09 -05:00
|
|
|
|
2004-03-18 05:49:20 -05:00
|
|
|
srcdir = File.dirname(__FILE__)
|
2005-07-05 10:45:33 -04:00
|
|
|
$:.unshift File.expand_path("lib", srcdir)
|
2002-12-26 13:01:34 -05:00
|
|
|
require 'fileutils'
|
|
|
|
require 'shellwords'
|
2004-02-22 19:09:48 -05:00
|
|
|
require 'optparse'
|
|
|
|
require 'optparse/shellwords'
|
2003-01-20 07:51:50 -05:00
|
|
|
require 'tempfile'
|
2008-10-24 10:05:49 -04:00
|
|
|
require 'rdoc/ri/paths'
|
2002-12-26 13:01:34 -05:00
|
|
|
|
2005-03-03 04:44:33 -05:00
|
|
|
STDOUT.sync = true
|
2003-05-02 02:07:54 -04:00
|
|
|
File.umask(0)
|
2002-10-22 00:19:26 -04:00
|
|
|
|
2008-02-19 23:08:54 -05:00
|
|
|
def parse_args(argv = ARGV)
|
2004-02-22 19:09:48 -05:00
|
|
|
$mantype = 'doc'
|
|
|
|
$destdir = nil
|
2006-09-16 03:06:57 -04:00
|
|
|
$extout = nil
|
2004-02-22 19:09:48 -05:00
|
|
|
$make = 'make'
|
|
|
|
$mflags = []
|
2005-03-03 04:44:33 -05:00
|
|
|
$install = []
|
2006-09-16 03:06:57 -04:00
|
|
|
$installed_list = nil
|
|
|
|
$dryrun = false
|
2006-09-17 04:43:19 -04:00
|
|
|
$rdocdir = nil
|
2008-02-13 10:49:56 -05:00
|
|
|
$data_mode = 0644
|
|
|
|
$prog_mode = 0755
|
2008-02-19 23:08:54 -05:00
|
|
|
$dir_mode = nil
|
|
|
|
$script_mode = nil
|
|
|
|
$cmdtype = ('bat' if File::ALT_SEPARATOR == '\\')
|
|
|
|
mflags = []
|
2004-02-22 19:09:48 -05:00
|
|
|
opt = OptionParser.new
|
|
|
|
opt.on('-n') {$dryrun = true}
|
|
|
|
opt.on('--dest-dir=DIR') {|dir| $destdir = dir}
|
2006-09-16 03:06:57 -04:00
|
|
|
opt.on('--extout=DIR') {|dir| $extout = (dir unless dir.empty?)}
|
2004-02-22 19:09:48 -05:00
|
|
|
opt.on('--make=COMMAND') {|make| $make = make}
|
|
|
|
opt.on('--mantype=MAN') {|man| $mantype = man}
|
2006-09-10 09:59:59 -04:00
|
|
|
opt.on('--make-flags=FLAGS', '--mflags', Shellwords) do |v|
|
2004-02-22 19:09:48 -05:00
|
|
|
if arg = v.first
|
|
|
|
arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
|
|
|
|
end
|
|
|
|
$mflags.concat(v)
|
2003-01-27 14:48:02 -05:00
|
|
|
end
|
2006-09-16 03:06:57 -04:00
|
|
|
opt.on('-i', '--install=TYPE',
|
2008-12-22 08:19:08 -05:00
|
|
|
[:local, :bin, :"bin-arch", :"bin-comm", :lib, :man, :ext, :"ext-arch", :"ext-comm", :rdoc, :capi]) do |ins|
|
2006-09-16 03:06:57 -04:00
|
|
|
$install << ins
|
|
|
|
end
|
2008-02-13 10:49:56 -05:00
|
|
|
opt.on('--data-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
|
|
|
$data_mode = mode
|
|
|
|
end
|
|
|
|
opt.on('--prog-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
|
|
|
$prog_mode = mode
|
|
|
|
end
|
2008-02-19 23:08:54 -05:00
|
|
|
opt.on('--dir-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
|
|
|
$dir_mode = mode
|
|
|
|
end
|
|
|
|
opt.on('--script-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
|
|
|
$script_mode = mode
|
|
|
|
end
|
2006-09-16 03:06:57 -04:00
|
|
|
opt.on('--installed-list [FILENAME]') {|name| $installed_list = name}
|
2006-09-21 09:58:33 -04:00
|
|
|
opt.on('--rdoc-output [DIR]') {|dir| $rdocdir = dir}
|
2008-02-19 23:08:54 -05:00
|
|
|
opt.on('--cmd-type=TYPE', %w[bat cmd plain]) {|cmd| $cmdtype = (cmd unless cmd == 'plain')}
|
|
|
|
|
|
|
|
opt.order!(argv) do |v|
|
|
|
|
case v
|
|
|
|
when /\AINSTALL[-_]([-\w]+)=(.*)/
|
|
|
|
argv.unshift("--#{$1.tr('_', '-')}=#{$2}")
|
|
|
|
when /\A\w[-\w+]*=\z/
|
|
|
|
mflags << v
|
|
|
|
when /\A\w[-\w+]*\z/
|
|
|
|
$install << v.intern
|
|
|
|
else
|
|
|
|
raise OptionParser::InvalidArgument, v
|
|
|
|
end
|
|
|
|
end rescue abort [$!.message, opt].join("\n")
|
2003-01-27 14:48:02 -05:00
|
|
|
|
2003-01-25 13:59:34 -05:00
|
|
|
$make, *rest = Shellwords.shellwords($make)
|
|
|
|
$mflags.unshift(*rest) unless rest.empty?
|
2008-02-19 23:08:54 -05:00
|
|
|
$mflags.unshift(*mflags)
|
2003-01-25 13:59:34 -05:00
|
|
|
|
2003-01-26 03:56:01 -05:00
|
|
|
def $mflags.set?(flag)
|
2008-03-20 20:24:30 -04:00
|
|
|
grep(/\A-(?!-).*#{flag.chr}/i) { return true }
|
2003-01-27 14:48:02 -05:00
|
|
|
false
|
2003-01-26 03:56:01 -05:00
|
|
|
end
|
2006-09-16 03:06:57 -04:00
|
|
|
def $mflags.defined?(var)
|
2008-02-19 23:08:54 -05:00
|
|
|
grep(/\A#{var}=(.*)/) {return block_given? ? yield($1) : $1}
|
2006-09-16 03:06:57 -04:00
|
|
|
false
|
|
|
|
end
|
2003-01-26 03:56:01 -05:00
|
|
|
|
|
|
|
if $mflags.set?(?n)
|
|
|
|
$dryrun = true
|
|
|
|
else
|
|
|
|
$mflags << '-n' if $dryrun
|
|
|
|
end
|
2003-01-25 13:59:34 -05:00
|
|
|
|
2006-09-16 03:06:57 -04:00
|
|
|
$destdir ||= $mflags.defined?("DESTDIR")
|
2006-09-17 04:43:19 -04:00
|
|
|
if $extout ||= $mflags.defined?("EXTOUT")
|
|
|
|
Config.expand($extout)
|
|
|
|
end
|
2003-01-25 13:59:34 -05:00
|
|
|
|
2003-01-26 03:56:01 -05:00
|
|
|
$continue = $mflags.set?(?k)
|
2006-09-16 03:06:57 -04:00
|
|
|
|
|
|
|
if $installed_list ||= $mflags.defined?('INSTALLED_LIST')
|
|
|
|
Config.expand($installed_list, Config::CONFIG)
|
|
|
|
$installed_list = open($installed_list, "ab")
|
|
|
|
$installed_list.sync = true
|
|
|
|
end
|
2006-09-17 04:43:19 -04:00
|
|
|
|
|
|
|
$rdocdir ||= $mflags.defined?('RDOCOUT')
|
2008-02-19 23:08:54 -05:00
|
|
|
|
|
|
|
$dir_mode ||= $prog_mode | 0700
|
|
|
|
$script_mode ||= $prog_mode
|
2003-01-25 13:59:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
parse_args()
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2006-09-21 12:37:05 -04:00
|
|
|
include FileUtils
|
2002-12-26 13:01:34 -05:00
|
|
|
include FileUtils::NoWrite if $dryrun
|
|
|
|
@fileutils_output = STDOUT
|
|
|
|
@fileutils_label = ''
|
2003-07-29 03:08:04 -04:00
|
|
|
|
2006-09-17 04:43:19 -04:00
|
|
|
$install_procs = Hash.new {[]}
|
|
|
|
def install?(*types, &block)
|
|
|
|
$install_procs[:all] <<= block
|
|
|
|
types.each do |type|
|
|
|
|
$install_procs[type] <<= block
|
|
|
|
end
|
2005-03-03 04:44:33 -05:00
|
|
|
end
|
|
|
|
|
2003-07-29 03:08:04 -04:00
|
|
|
def install(src, dest, options = {})
|
2003-07-29 06:24:28 -04:00
|
|
|
options[:preserve] = true
|
2006-09-17 04:43:19 -04:00
|
|
|
super(src, with_destdir(dest), options)
|
2006-09-16 03:06:57 -04:00
|
|
|
if $installed_list
|
|
|
|
dest = File.join(dest, File.basename(src)) if $made_dirs[dest]
|
|
|
|
$installed_list.puts dest
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def ln_sf(src, dest)
|
2006-09-17 04:43:19 -04:00
|
|
|
super(src, with_destdir(dest))
|
2006-09-16 03:06:57 -04:00
|
|
|
$installed_list.puts dest if $installed_list
|
2003-01-25 16:42:42 -05:00
|
|
|
end
|
2003-07-29 03:08:04 -04:00
|
|
|
|
2003-01-25 17:23:17 -05:00
|
|
|
$made_dirs = {}
|
|
|
|
def makedirs(dirs)
|
|
|
|
dirs = fu_list(dirs)
|
2006-09-17 04:43:19 -04:00
|
|
|
dirs.collect! do |dir|
|
|
|
|
realdir = with_destdir(dir)
|
|
|
|
realdir unless $made_dirs.fetch(dir) do
|
2003-01-25 17:23:17 -05:00
|
|
|
$made_dirs[dir] = true
|
2006-09-21 09:58:33 -04:00
|
|
|
$installed_list.puts(File.join(dir, "")) if $installed_list
|
2006-09-17 04:43:19 -04:00
|
|
|
File.directory?(realdir)
|
2003-01-25 17:23:17 -05:00
|
|
|
end
|
2006-09-17 04:43:19 -04:00
|
|
|
end.compact!
|
2008-02-19 23:08:54 -05:00
|
|
|
super(dirs, :mode => $dir_mode) unless dirs.empty?
|
2003-01-25 17:23:17 -05:00
|
|
|
end
|
2000-02-17 02:11:22 -05:00
|
|
|
|
2006-12-04 09:49:47 -05:00
|
|
|
def install_recursive(srcdir, dest, options = {})
|
2008-02-11 22:16:07 -05:00
|
|
|
opts = options.clone
|
|
|
|
noinst = opts.delete(:no_install)
|
|
|
|
glob = opts.delete(:glob) || "*"
|
2006-12-04 09:49:47 -05:00
|
|
|
subpath = srcdir.size..-1
|
2007-06-10 03:34:51 -04:00
|
|
|
Dir.glob("#{srcdir}/**/#{glob}") do |src|
|
2007-06-10 03:05:39 -04:00
|
|
|
case base = File.basename(src)
|
2007-06-10 03:34:51 -04:00
|
|
|
when /\A\#.*\#\z/, /~\z/
|
2007-06-10 03:05:39 -04:00
|
|
|
next
|
|
|
|
end
|
2007-06-09 23:06:15 -04:00
|
|
|
if noinst
|
|
|
|
if Array === noinst
|
|
|
|
next if noinst.any? {|n| File.fnmatch?(n, base)}
|
|
|
|
else
|
|
|
|
next if File.fnmatch?(noinst, base)
|
|
|
|
end
|
|
|
|
end
|
2006-09-17 04:43:19 -04:00
|
|
|
d = dest + src[subpath]
|
|
|
|
if File.directory?(src)
|
|
|
|
makedirs(d)
|
|
|
|
else
|
2007-06-10 04:47:49 -04:00
|
|
|
makedirs(File.dirname(d))
|
2008-02-11 22:16:07 -05:00
|
|
|
install src, d, opts
|
2006-09-17 04:43:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-03-20 20:24:30 -04:00
|
|
|
def open_for_install(path, mode)
|
|
|
|
data = open(realpath = with_destdir(path), "rb") {|f| f.read} rescue nil
|
|
|
|
newdata = yield
|
2006-09-17 04:43:19 -04:00
|
|
|
unless $dryrun
|
2008-03-20 20:24:30 -04:00
|
|
|
unless newdata == data
|
|
|
|
open(realpath, "wb", mode) {|f| f.write newdata}
|
|
|
|
end
|
2008-02-19 23:08:54 -05:00
|
|
|
File.chmod(mode, realpath)
|
2006-09-17 04:43:19 -04:00
|
|
|
end
|
2008-02-19 23:08:54 -05:00
|
|
|
$installed_list.puts path if $installed_list
|
2006-09-17 04:43:19 -04:00
|
|
|
end
|
|
|
|
|
2004-02-22 19:09:48 -05:00
|
|
|
def with_destdir(dir)
|
2005-07-05 10:45:33 -04:00
|
|
|
return dir if !$destdir or $destdir.empty?
|
2004-02-22 19:09:48 -05:00
|
|
|
dir = dir.sub(/\A\w:/, '') if File::PATH_SEPARATOR == ';'
|
|
|
|
$destdir + dir
|
2003-12-28 12:25:31 -05:00
|
|
|
end
|
|
|
|
|
2002-10-22 00:19:26 -04:00
|
|
|
exeext = CONFIG["EXEEXT"]
|
|
|
|
|
1998-01-16 07:19:09 -05:00
|
|
|
ruby_install_name = CONFIG["ruby_install_name"]
|
2002-10-22 00:19:26 -04:00
|
|
|
rubyw_install_name = CONFIG["rubyw_install_name"]
|
2007-12-26 00:39:03 -05:00
|
|
|
goruby_install_name = "go" + ruby_install_name
|
2000-02-17 02:11:22 -05:00
|
|
|
|
2002-10-22 00:19:26 -04:00
|
|
|
version = CONFIG["ruby_version"]
|
2006-09-17 04:43:19 -04:00
|
|
|
bindir = CONFIG["bindir"]
|
|
|
|
libdir = CONFIG["libdir"]
|
2007-06-09 23:06:15 -04:00
|
|
|
archhdrdir = rubyhdrdir = CONFIG["rubyhdrdir"]
|
|
|
|
archhdrdir += "/" + CONFIG["arch"]
|
2006-09-17 04:43:19 -04:00
|
|
|
rubylibdir = CONFIG["rubylibdir"]
|
|
|
|
archlibdir = CONFIG["archdir"]
|
|
|
|
sitelibdir = CONFIG["sitelibdir"]
|
|
|
|
sitearchlibdir = CONFIG["sitearchdir"]
|
2007-11-03 07:35:59 -04:00
|
|
|
vendorlibdir = CONFIG["vendorlibdir"]
|
|
|
|
vendorarchlibdir = CONFIG["vendorarchdir"]
|
2006-09-17 04:43:19 -04:00
|
|
|
mandir = File.join(CONFIG["mandir"], "man")
|
2008-12-22 08:19:08 -05:00
|
|
|
capidir = CONFIG["docdir"]
|
2002-10-23 13:40:36 -04:00
|
|
|
configure_args = Shellwords.shellwords(CONFIG["configure_args"])
|
2002-11-04 06:06:03 -05:00
|
|
|
enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
|
2002-10-22 00:19:26 -04:00
|
|
|
dll = CONFIG["LIBRUBY_SO"]
|
|
|
|
lib = CONFIG["LIBRUBY"]
|
|
|
|
arc = CONFIG["LIBRUBY_A"]
|
|
|
|
|
2008-02-19 23:08:54 -05:00
|
|
|
install?(:local, :arch, :bin, :'bin-arch') do
|
2006-09-21 09:58:33 -04:00
|
|
|
puts "installing binary commands"
|
|
|
|
|
2007-06-10 03:55:49 -04:00
|
|
|
makedirs [bindir, libdir, archlibdir]
|
2003-01-21 03:03:05 -05:00
|
|
|
|
2008-02-13 10:49:56 -05:00
|
|
|
install ruby_install_name+exeext, bindir, :mode => $prog_mode
|
2006-02-23 22:12:27 -05:00
|
|
|
if rubyw_install_name and !rubyw_install_name.empty?
|
2008-02-13 10:49:56 -05:00
|
|
|
install rubyw_install_name+exeext, bindir, :mode => $prog_mode
|
2006-02-23 22:12:27 -05:00
|
|
|
end
|
2007-12-26 00:39:03 -05:00
|
|
|
if File.exist? goruby_install_name+exeext
|
2008-02-13 10:49:56 -05:00
|
|
|
install goruby_install_name+exeext, bindir, :mode => $prog_mode
|
2007-12-26 00:39:03 -05:00
|
|
|
end
|
2006-02-23 22:12:27 -05:00
|
|
|
if enable_shared and dll != lib
|
2008-02-13 10:49:56 -05:00
|
|
|
install dll, bindir, :mode => $prog_mode
|
2006-02-23 22:12:27 -05:00
|
|
|
end
|
2008-02-13 10:49:56 -05:00
|
|
|
install lib, libdir, :mode => $prog_mode unless lib == arc
|
|
|
|
install arc, libdir, :mode => $data_mode
|
|
|
|
install "rbconfig.rb", archlibdir, :mode => $data_mode
|
2006-02-23 22:12:27 -05:00
|
|
|
if CONFIG["ARCHFILE"]
|
|
|
|
for file in CONFIG["ARCHFILE"].split
|
2008-02-13 10:49:56 -05:00
|
|
|
install file, archlibdir, :mode => $data_mode
|
2006-02-23 22:12:27 -05:00
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
2002-10-22 00:19:26 -04:00
|
|
|
|
2006-02-23 22:12:27 -05:00
|
|
|
if dll == lib and dll != arc
|
|
|
|
for link in CONFIG["LIBRUBY_ALIASES"].split
|
|
|
|
ln_sf(dll, File.join(libdir, link))
|
|
|
|
end
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
end
|
2002-09-08 05:08:15 -04:00
|
|
|
|
2006-09-16 03:06:57 -04:00
|
|
|
if $extout
|
2006-09-17 04:43:19 -04:00
|
|
|
extout = "#$extout"
|
2006-09-16 03:06:57 -04:00
|
|
|
install?(:ext, :arch, :'ext-arch') do
|
2006-09-21 09:58:33 -04:00
|
|
|
puts "installing extension objects"
|
2007-11-03 07:35:59 -04:00
|
|
|
makedirs [archlibdir, sitearchlibdir, vendorarchlibdir, archhdrdir]
|
2006-09-17 04:43:19 -04:00
|
|
|
if noinst = CONFIG["no_install_files"] and noinst.empty?
|
|
|
|
noinst = nil
|
2006-09-16 03:06:57 -04:00
|
|
|
end
|
2008-02-13 10:49:56 -05:00
|
|
|
install_recursive("#{extout}/#{CONFIG['arch']}", archlibdir, :no_install => noinst, :mode => $prog_mode)
|
|
|
|
install_recursive("#{extout}/include/#{CONFIG['arch']}", archhdrdir, :glob => "*.h", :mode => $data_mode)
|
2006-09-16 03:06:57 -04:00
|
|
|
end
|
|
|
|
install?(:ext, :comm, :'ext-comm') do
|
2006-09-21 09:58:33 -04:00
|
|
|
puts "installing extension scripts"
|
2007-06-10 03:55:49 -04:00
|
|
|
hdrdir = rubyhdrdir + "/ruby"
|
2007-11-03 07:35:59 -04:00
|
|
|
makedirs [rubylibdir, sitelibdir, vendorlibdir, hdrdir]
|
2008-02-13 10:49:56 -05:00
|
|
|
install_recursive("#{extout}/common", rubylibdir, :mode => $data_mode)
|
|
|
|
install_recursive("#{extout}/include/ruby", hdrdir, :glob => "*.h", :mode => $data_mode)
|
2006-09-16 03:06:57 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-12-22 08:19:08 -05:00
|
|
|
install?(:doc, :rdoc) do
|
2006-09-17 04:43:19 -04:00
|
|
|
if $rdocdir
|
2006-09-21 09:58:33 -04:00
|
|
|
puts "installing rdoc"
|
|
|
|
|
2008-10-24 10:05:49 -04:00
|
|
|
ridatadir = RDoc::RI::Paths::SYSDIR
|
2006-09-17 04:43:19 -04:00
|
|
|
Config.expand(ridatadir)
|
|
|
|
makedirs [ridatadir]
|
2008-02-13 10:49:56 -05:00
|
|
|
install_recursive($rdocdir, ridatadir, :mode => $data_mode)
|
2006-09-17 04:43:19 -04:00
|
|
|
end
|
|
|
|
end
|
2008-12-22 08:19:08 -05:00
|
|
|
install?(:doc, :capi) do
|
|
|
|
puts "installing capi-docs"
|
|
|
|
|
|
|
|
makedirs [capidir]
|
|
|
|
Dir.chdir("doc")
|
|
|
|
install_recursive "capi", capidir, :mode => $data_mode
|
|
|
|
end
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2008-02-19 23:08:54 -05:00
|
|
|
install?(:local, :comm, :bin, :'bin-comm') do
|
2006-09-21 09:58:33 -04:00
|
|
|
puts "installing command scripts"
|
|
|
|
|
2006-09-17 04:43:19 -04:00
|
|
|
Dir.chdir srcdir
|
|
|
|
makedirs [bindir, rubylibdir]
|
|
|
|
|
|
|
|
ruby_shebang = File.join(bindir, ruby_install_name)
|
2008-03-20 20:24:30 -04:00
|
|
|
if File::ALT_SEPARATOR
|
2008-02-19 23:08:54 -05:00
|
|
|
ruby_bin = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
2006-09-16 03:06:57 -04:00
|
|
|
end
|
|
|
|
for src in Dir["bin/*"]
|
|
|
|
next unless File.file?(src)
|
|
|
|
next if /\/[.#]|(\.(old|bak|orig|rej|diff|patch|core)|~|\/core)$/i =~ src
|
2002-11-18 11:57:36 -05:00
|
|
|
|
2006-09-16 03:06:57 -04:00
|
|
|
name = ruby_install_name.sub(/ruby/, File.basename(src))
|
2003-01-21 03:03:05 -05:00
|
|
|
|
2006-09-16 03:06:57 -04:00
|
|
|
shebang = ''
|
|
|
|
body = ''
|
2008-02-19 23:08:54 -05:00
|
|
|
open(src, "rb") do |f|
|
2006-09-16 03:06:57 -04:00
|
|
|
shebang = f.gets
|
|
|
|
body = f.read
|
2008-02-19 23:08:54 -05:00
|
|
|
end
|
|
|
|
shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang}
|
|
|
|
shebang.sub!(/\r$/, '')
|
|
|
|
body.gsub!(/\r$/, '')
|
|
|
|
|
|
|
|
cmd = File.join(bindir, name)
|
|
|
|
cmd << ".#{$cmdtype}" if $cmdtype
|
2008-03-20 20:24:30 -04:00
|
|
|
open_for_install(cmd, $script_mode) do
|
2008-02-19 23:08:54 -05:00
|
|
|
case $cmdtype
|
|
|
|
when "bat"
|
2008-03-20 20:24:30 -04:00
|
|
|
"#{<<EOH}#{shebang}#{body}#{<<EOF}".gsub(/$/, "\r")
|
2002-11-22 05:22:29 -05:00
|
|
|
@echo off
|
2006-09-17 04:43:19 -04:00
|
|
|
@if not "%~d0" == "~d0" goto WinNT
|
2008-02-19 23:08:54 -05:00
|
|
|
#{ruby_bin} -x "#{cmd}" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
2006-09-17 04:43:19 -04:00
|
|
|
@goto endofruby
|
2002-11-22 05:22:29 -05:00
|
|
|
:WinNT
|
2004-02-25 07:16:30 -05:00
|
|
|
"%~dp0#{ruby_install_name}" -x "%~f0" %*
|
2006-09-17 04:43:19 -04:00
|
|
|
@goto endofruby
|
2002-11-22 05:22:29 -05:00
|
|
|
EOH
|
|
|
|
__END__
|
|
|
|
:endofruby
|
|
|
|
EOF
|
2008-02-19 23:08:54 -05:00
|
|
|
when "cmd"
|
2008-03-20 20:24:30 -04:00
|
|
|
"#{<<EOH}#{shebang}#{body}"
|
2008-02-19 23:08:54 -05:00
|
|
|
@"%~dp0#{ruby_install_name}" -x "%~f0" %*
|
|
|
|
@exit /b %ERRORLEVEL%
|
|
|
|
EOH
|
|
|
|
else
|
2008-03-20 20:24:30 -04:00
|
|
|
shebang + body
|
2008-02-19 23:08:54 -05:00
|
|
|
end
|
2006-09-16 03:06:57 -04:00
|
|
|
end
|
2003-01-21 03:03:05 -05:00
|
|
|
end
|
2006-09-21 09:58:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
install?(:local, :comm, :lib) do
|
|
|
|
puts "installing library scripts"
|
|
|
|
|
|
|
|
makedirs [rubylibdir]
|
2008-10-16 01:30:38 -04:00
|
|
|
noinst = %w[README* *.txt *.rdoc]
|
|
|
|
install_recursive(File.join(srcdir, "lib"), rubylibdir, :no_install => noinst, :mode => $data_mode)
|
2006-09-21 09:58:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
install?(:local, :arch, :lib) do
|
|
|
|
puts "installing headers"
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2006-09-17 04:43:19 -04:00
|
|
|
Dir.chdir(srcdir)
|
2007-06-09 23:06:15 -04:00
|
|
|
makedirs [rubyhdrdir]
|
|
|
|
noinst = []
|
|
|
|
unless RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
|
|
|
|
noinst << "win32.h"
|
2006-09-16 03:06:57 -04:00
|
|
|
end
|
2007-06-09 23:06:15 -04:00
|
|
|
noinst = nil if noinst.empty?
|
2008-02-13 10:49:56 -05:00
|
|
|
install_recursive("include", rubyhdrdir, :no_install => noinst, :glob => "*.h", :mode => $data_mode)
|
2005-03-03 04:44:33 -05:00
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2006-09-16 03:06:57 -04:00
|
|
|
install?(:local, :comm, :man) do
|
2006-09-21 09:58:33 -04:00
|
|
|
puts "installing manpages"
|
|
|
|
|
2008-10-25 11:15:24 -04:00
|
|
|
has_goruby = File.exist?(goruby_install_name+exeext)
|
|
|
|
Dir.chdir("#{srcdir}/man")
|
2006-09-16 03:06:57 -04:00
|
|
|
for mdoc in Dir["*.[1-9]"]
|
|
|
|
next unless File.file?(mdoc) and open(mdoc){|fh| fh.read(1) == '.'}
|
2008-10-25 11:15:24 -04:00
|
|
|
if mdoc == "goruby.1"
|
|
|
|
next unless has_goruby
|
|
|
|
end
|
2003-07-09 02:45:45 -04:00
|
|
|
|
2006-09-17 04:43:19 -04:00
|
|
|
destdir = mandir + mdoc[/(\d+)$/]
|
2008-10-25 11:15:24 -04:00
|
|
|
section = $1
|
|
|
|
destname = ruby_install_name.sub(/ruby/, File.basename(mdoc, ".#{section}"))
|
|
|
|
destfile = File.join(destdir, "#{destname}.#{section}")
|
2003-01-20 07:51:50 -05:00
|
|
|
|
2006-09-16 03:06:57 -04:00
|
|
|
makedirs destdir
|
2003-01-20 07:51:50 -05:00
|
|
|
|
2006-09-16 03:06:57 -04:00
|
|
|
if $mantype == "doc"
|
2008-02-13 10:49:56 -05:00
|
|
|
install mdoc, destfile, :mode => $data_mode
|
2006-09-16 03:06:57 -04:00
|
|
|
else
|
2008-10-25 13:20:05 -04:00
|
|
|
require "../tool/mdoc2man.rb"
|
2003-01-20 07:51:50 -05:00
|
|
|
|
2006-09-16 03:06:57 -04:00
|
|
|
w = Tempfile.open(mdoc)
|
2003-01-20 07:51:50 -05:00
|
|
|
|
2006-09-16 03:06:57 -04:00
|
|
|
open(mdoc) { |r|
|
|
|
|
Mdoc2Man.mdoc2man(r, w)
|
|
|
|
}
|
2003-01-20 07:51:50 -05:00
|
|
|
|
2006-09-16 03:06:57 -04:00
|
|
|
w.close
|
2003-01-20 07:51:50 -05:00
|
|
|
|
2008-02-13 10:49:56 -05:00
|
|
|
install w.path, destfile, :mode => $data_mode
|
2006-09-16 03:06:57 -04:00
|
|
|
end
|
2003-01-20 07:51:50 -05:00
|
|
|
end
|
|
|
|
end
|
2002-10-22 00:19:26 -04:00
|
|
|
|
2006-09-17 04:43:19 -04:00
|
|
|
$install << :local << :ext if $install.empty?
|
|
|
|
$install.each do |inst|
|
2008-02-19 23:08:54 -05:00
|
|
|
if !(procs = $install_procs[inst]) || procs.empty?
|
|
|
|
next warn("unknown install target - #{inst}")
|
|
|
|
end
|
|
|
|
procs.each do |block|
|
2006-09-17 04:43:19 -04:00
|
|
|
dir = Dir.pwd
|
|
|
|
begin
|
|
|
|
block.call
|
|
|
|
ensure
|
|
|
|
Dir.chdir(dir)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
1998-01-16 07:19:09 -05:00
|
|
|
# vi:set sw=2:
|