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"
|
1998-01-16 07:19:09 -05:00
|
|
|
include Config
|
|
|
|
|
2002-12-26 13:01:34 -05:00
|
|
|
$:.unshift File.join(CONFIG["srcdir"], "lib")
|
|
|
|
require 'fileutils'
|
|
|
|
require 'shellwords'
|
2002-12-27 11:28:10 -05:00
|
|
|
require 'getopts'
|
2003-01-20 07:51:50 -05:00
|
|
|
require 'tempfile'
|
2002-12-26 13:01:34 -05:00
|
|
|
|
2000-12-18 04:46:21 -05:00
|
|
|
File.umask(0)
|
2002-10-22 00:19:26 -04:00
|
|
|
|
2003-01-25 13:59:34 -05:00
|
|
|
def parse_args()
|
|
|
|
getopts('n', 'dest-dir:',
|
|
|
|
'make:', 'make-flags:', 'mflags:',
|
|
|
|
'mantype:doc')
|
|
|
|
|
|
|
|
$dryrun = $OPT['n']
|
|
|
|
$destdir = $OPT['dest-dir'] || ''
|
2003-01-26 03:56:01 -05:00
|
|
|
$make = $OPT['make'] || $make || 'make'
|
2003-01-27 14:48:02 -05:00
|
|
|
$mantype = $OPT['mantype']
|
|
|
|
mflags = ($OPT['make-flags'] || '').strip
|
|
|
|
mflags = ($OPT['mflags'] || '').strip if mflags.empty?
|
2003-01-25 13:59:34 -05:00
|
|
|
|
|
|
|
$mflags = Shellwords.shellwords(mflags)
|
2003-01-27 14:48:02 -05:00
|
|
|
if arg = $mflags.first
|
|
|
|
arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
|
|
|
|
end
|
|
|
|
|
2003-01-25 13:59:34 -05:00
|
|
|
$make, *rest = Shellwords.shellwords($make)
|
|
|
|
$mflags.unshift(*rest) unless rest.empty?
|
|
|
|
|
2003-01-26 03:56:01 -05:00
|
|
|
def $mflags.set?(flag)
|
2003-01-27 14:48:02 -05:00
|
|
|
grep(/\A-(?!-).*#{'%c' % flag}/i) { return true }
|
|
|
|
false
|
2003-01-26 03:56:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
if $mflags.set?(?n)
|
|
|
|
$dryrun = true
|
|
|
|
else
|
|
|
|
$mflags << '-n' if $dryrun
|
|
|
|
end
|
2003-01-25 13:59:34 -05:00
|
|
|
|
|
|
|
$mflags << "DESTDIR=#{$destdir}"
|
|
|
|
|
2003-01-26 03:56:01 -05:00
|
|
|
$continue = $mflags.set?(?k)
|
2003-01-25 13:59:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
parse_args()
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2003-01-25 16:42:42 -05:00
|
|
|
include FileUtils
|
2002-12-26 13:01:34 -05:00
|
|
|
include FileUtils::NoWrite if $dryrun
|
|
|
|
@fileutils_output = STDOUT
|
|
|
|
@fileutils_label = ''
|
|
|
|
alias makelink ln_sf
|
2003-01-25 16:42:42 -05:00
|
|
|
class << self
|
|
|
|
body = proc {|*args|super(*args<<:verbose)}
|
2003-01-25 17:23:17 -05:00
|
|
|
for func in [:install, :makelink]
|
2003-01-25 16:42:42 -05:00
|
|
|
define_method(func, body)
|
|
|
|
end
|
|
|
|
end
|
2003-01-25 17:23:17 -05:00
|
|
|
$made_dirs = {}
|
|
|
|
def makedirs(dirs)
|
|
|
|
dirs = fu_list(dirs)
|
|
|
|
dirs.reject! do |dir|
|
|
|
|
$made_dirs.fetch(dir) do
|
|
|
|
$made_dirs[dir] = true
|
|
|
|
File.directory?(dir)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
super(dirs, :verbose) unless dirs.empty?
|
|
|
|
end
|
2000-02-17 02:11:22 -05:00
|
|
|
|
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"]
|
2000-02-17 02:11:22 -05:00
|
|
|
|
2002-10-22 00:19:26 -04:00
|
|
|
version = CONFIG["ruby_version"]
|
2003-01-25 13:59:34 -05:00
|
|
|
bindir = $destdir+CONFIG["bindir"]
|
|
|
|
libdir = $destdir+CONFIG["libdir"]
|
|
|
|
rubylibdir = $destdir+CONFIG["rubylibdir"]
|
|
|
|
archlibdir = $destdir+CONFIG["archdir"]
|
|
|
|
sitelibdir = $destdir+CONFIG["sitelibdir"]
|
|
|
|
sitearchlibdir = $destdir+CONFIG["sitearchdir"]
|
|
|
|
mandir = File.join($destdir+CONFIG["mandir"], "man")
|
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"]
|
|
|
|
|
2003-01-20 07:51:50 -05:00
|
|
|
makedirs [bindir, libdir, rubylibdir, archlibdir, sitelibdir, sitearchlibdir]
|
2002-10-22 00:19:26 -04:00
|
|
|
|
2003-01-22 16:42:25 -05:00
|
|
|
ruby_bin = File.join(bindir, ruby_install_name)
|
2003-01-21 03:03:05 -05:00
|
|
|
|
|
|
|
install ruby_install_name+exeext, ruby_bin+exeext, 0755
|
2002-10-22 00:19:26 -04:00
|
|
|
if rubyw_install_name and !rubyw_install_name.empty?
|
2002-12-26 13:01:34 -05:00
|
|
|
install rubyw_install_name+exeext, bindir, 0755
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
2002-12-26 13:01:34 -05:00
|
|
|
install dll, bindir, 0755 if enable_shared and dll != lib
|
|
|
|
install lib, libdir, 0555 unless lib == arc
|
|
|
|
install arc, libdir, 0644
|
|
|
|
install "config.h", archlibdir, 0644
|
|
|
|
install "rbconfig.rb", archlibdir, 0644
|
2002-10-22 00:19:26 -04:00
|
|
|
if CONFIG["ARCHFILE"]
|
|
|
|
for file in CONFIG["ARCHFILE"].split
|
2002-12-26 13:01:34 -05:00
|
|
|
install file, archlibdir, 0644
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
|
|
|
end
|
2002-10-22 00:19:26 -04:00
|
|
|
|
|
|
|
if dll == lib and dll != arc
|
1999-08-13 01:45:20 -04:00
|
|
|
for link in CONFIG["LIBRUBY_ALIASES"].split
|
2002-12-26 13:01:34 -05:00
|
|
|
makelink(dll, File.join(libdir, link))
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
end
|
2002-09-08 05:08:15 -04:00
|
|
|
|
1998-01-16 07:19:09 -05:00
|
|
|
Dir.chdir CONFIG["srcdir"]
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2003-01-22 16:42:25 -05:00
|
|
|
ruby_shebang = File.join(CONFIG["bindir"], ruby_install_name)
|
2002-11-18 12:26:03 -05:00
|
|
|
for src in Dir["bin/*"]
|
|
|
|
next unless File.file?(src)
|
2002-11-18 15:16:54 -05:00
|
|
|
next if /\/[.#]|(\.(old|bak|orig|rej|diff|patch|core)|~|\/core)$/i =~ src
|
2002-11-18 11:57:36 -05:00
|
|
|
|
2002-11-18 12:26:03 -05:00
|
|
|
name = ruby_install_name.sub(/ruby/, File.basename(src))
|
|
|
|
dest = File.join(bindir, name)
|
2002-11-18 11:57:36 -05:00
|
|
|
|
2002-12-26 13:01:34 -05:00
|
|
|
install src, dest, 0755
|
2002-11-18 12:26:03 -05:00
|
|
|
|
2003-01-21 03:03:05 -05:00
|
|
|
next if $dryrun
|
|
|
|
|
|
|
|
shebang = ''
|
|
|
|
body = ''
|
2002-11-18 12:26:03 -05:00
|
|
|
open(dest, "r+") { |f|
|
2003-01-21 03:03:05 -05:00
|
|
|
shebang = f.gets
|
2002-11-22 05:22:29 -05:00
|
|
|
body = f.read
|
2002-11-18 12:26:03 -05:00
|
|
|
|
2003-01-22 16:42:25 -05:00
|
|
|
if shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang}
|
2003-01-21 03:03:05 -05:00
|
|
|
f.rewind
|
|
|
|
f.print shebang, body
|
|
|
|
f.truncate(f.pos)
|
|
|
|
end
|
|
|
|
}
|
2002-11-22 05:22:29 -05:00
|
|
|
|
2003-01-21 03:03:05 -05:00
|
|
|
if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
|
|
|
|
ruby_bin_dosish = ruby_bin.gsub(Regexp.compile(File::SEPARATOR), File::ALT_SEPARATOR)
|
|
|
|
batfile = dest + ".bat"
|
|
|
|
open(batfile, "w") { |b|
|
|
|
|
b.print <<EOH, shebang, body, <<EOF
|
2002-11-22 05:22:29 -05:00
|
|
|
@echo off
|
|
|
|
if "%OS%" == "Windows_NT" goto WinNT
|
2003-01-21 03:03:05 -05:00
|
|
|
#{ruby_bin_dosish} -x "#{batfile}" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
2002-11-22 05:22:29 -05:00
|
|
|
goto endofruby
|
|
|
|
:WinNT
|
2003-01-21 03:03:05 -05:00
|
|
|
#{ruby_bin_dosish} -x "#{batfile}" %*
|
2002-11-22 05:22:29 -05:00
|
|
|
goto endofruby
|
|
|
|
EOH
|
|
|
|
__END__
|
|
|
|
:endofruby
|
|
|
|
EOF
|
2003-01-21 03:03:05 -05:00
|
|
|
}
|
|
|
|
end
|
2002-11-18 11:57:36 -05:00
|
|
|
end
|
2000-07-14 00:34:43 -04:00
|
|
|
|
2002-10-23 13:40:36 -04:00
|
|
|
Dir.glob("lib/**/*{.rb,help-message}") do |f|
|
2002-10-22 00:19:26 -04:00
|
|
|
dir = File.dirname(f).sub!(/\Alib/, rubylibdir) || rubylibdir
|
2003-01-25 17:23:17 -05:00
|
|
|
makedirs dir
|
2002-12-26 13:01:34 -05:00
|
|
|
install f, dir, 0644
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
|
|
|
|
2003-01-20 07:51:50 -05:00
|
|
|
Dir.glob("*.h") do |f|
|
2002-12-26 13:01:34 -05:00
|
|
|
install f, archlibdir, 0644
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
2003-01-20 07:51:50 -05:00
|
|
|
|
2002-06-10 21:27:48 -04:00
|
|
|
if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
|
2002-12-26 13:01:34 -05:00
|
|
|
makedirs File.join(archlibdir, "win32")
|
|
|
|
install "win32/win32.h", File.join(archlibdir, "win32"), 0644
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2003-01-20 07:51:50 -05:00
|
|
|
Dir.glob("*.[1-9]") do |mdoc|
|
|
|
|
section = mdoc[-1,1]
|
|
|
|
|
2003-01-25 13:59:34 -05:00
|
|
|
$destdir = mandir + section
|
|
|
|
destfile = File.join($destdir, mdoc.sub(/ruby/, ruby_install_name))
|
2003-01-20 07:51:50 -05:00
|
|
|
|
2003-01-25 13:59:34 -05:00
|
|
|
makedirs $destdir
|
2003-01-20 07:51:50 -05:00
|
|
|
|
2003-01-25 13:59:34 -05:00
|
|
|
if $mantype == "doc"
|
2003-01-20 07:51:50 -05:00
|
|
|
install mdoc, destfile, 0644
|
|
|
|
else
|
|
|
|
require 'mdoc2man.rb'
|
|
|
|
|
|
|
|
w = Tempfile.open(mdoc)
|
|
|
|
|
|
|
|
open(mdoc) { |r|
|
|
|
|
Mdoc2Man.mdoc2man(r, w)
|
|
|
|
}
|
|
|
|
|
|
|
|
w.close
|
|
|
|
|
|
|
|
install w.path, destfile, 0644
|
|
|
|
end
|
|
|
|
end
|
2002-10-22 00:19:26 -04:00
|
|
|
|
1998-01-16 07:19:09 -05:00
|
|
|
# vi:set sw=2:
|