summaryrefslogtreecommitdiff
path: root/instruby.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-22 04:19:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-22 04:19:26 +0000
commitdb1c27bb3752307d6a0cd3d1f2cc9a69b5e715ab (patch)
tree9ca18bafd96f4a37b3c6ef3586d128166c6b5b0c /instruby.rb
parent79c8b98fac05a37cd4d83982e9ad2820a15de420 (diff)
* instruby.rb: add dryrun mode.
* ext/extmk.rb (extmake): avoid Borland make's quirk behavior. * lib/mkmf.rb (link_command): opt is not a makefile macro. * bcc32/Makefile.sub ($(LIBRUBY_SO) $(LIBRUBY)): EXTOBJS were not linked. * bcc32/Makefile.sub (ext/extinit.obj): missing. * bcc32/Makefile.sub (TRY_LINK): options have to place before any non-option arguments. * win32/Makefile.sub (TRY_LINK): need -link and -libpath options. * bcc32/Makefile.sub, win32/Makefile.sub (RANLIB): logical operator never work with command.com. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'instruby.rb')
-rw-r--r--instruby.rb148
1 files changed, 83 insertions, 65 deletions
diff --git a/instruby.rb b/instruby.rb
index 26f97db0da..557a81b03f 100644
--- a/instruby.rb
+++ b/instruby.rb
@@ -4,96 +4,114 @@ load "./rbconfig.rb"
include Config
File.umask(0)
-destdir = ARGV[0] || ''
+
+while arg = ARGV.shift
+ case arg
+ when /^--/ # ignore
+ when /^-/
+ $dryrun = /n/ =~ arg
+ when /=/ # ignore
+ else
+ destdir ||= arg
+ break
+ end
+end
+destdir ||= ''
$:.unshift CONFIG["srcdir"]+"/lib"
-require "ftools"
-require "find"
+require 'ftools'
-exeext = CONFIG["EXEEXT"]
-if ENV["prefix"]
- prefix = ENV["prefix"]
-else
- prefix = CONFIG["prefix"]
+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
end
+exeext = CONFIG["EXEEXT"]
+
ruby_install_name = CONFIG["ruby_install_name"]
-version = "/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
-arch = "/"+CONFIG["arch"]
-sitearch = "/"+CONFIG["sitearch"]
+rubyw_install_name = CONFIG["rubyw_install_name"]
+version = CONFIG["ruby_version"]
bindir = destdir+CONFIG["bindir"]
libdir = destdir+CONFIG["libdir"]
-rubylibdir = destdir+CONFIG["prefix"]+"/lib/ruby"+version
-archlibdir = rubylibdir+arch
-sitelibdir = destdir+CONFIG["sitedir"]+version
-sitearchlibdir = sitelibdir+sitearch
+rubylibdir = destdir+CONFIG["rubylibdir"]
+archlibdir = destdir+CONFIG["archdir"]
+sitelibdir = destdir+CONFIG["sitelibdir"]
+sitearchlibdir = destdir+CONFIG["sitearchdir"]
mandir = destdir+CONFIG["mandir"] + "/man1"
-wdir = Dir.getwd
-
-File.makedirs bindir, true
-File.install ruby_install_name+exeext,
- "#{bindir}/#{ruby_install_name}#{exeext}", 0755, true
-rubyw = ruby_install_name.sub(/ruby/, '\&w')+exeext
-if File.exist? rubyw
- File.install rubyw, "#{bindir}/#{rubyw}", 0755, true
-end
-for dll in Dir['*.dll']
- File.install dll, "#{bindir}/#{dll}", 0755, true
+dll = CONFIG["LIBRUBY_SO"]
+lib = CONFIG["LIBRUBY"]
+arc = CONFIG["LIBRUBY_A"]
+
+Installer.makedirs bindir, libdir, rubylibdir, archlibdir, sitelibdir, sitearchlibdir, mandir, true
+
+Installer.install ruby_install_name+exeext, bindir+"/"+ruby_install_name+exeext, 0755, true
+if rubyw_install_name and !rubyw_install_name.empty?
+ Installer.install rubyw_install_name+exeext, bindir, 0755, true
end
-File.makedirs libdir, true
-if CONFIG["LIBRUBY"] != CONFIG["LIBRUBY_A"]
- for lib in [CONFIG["LIBRUBY"]]
- if File.exist? lib
- File.install lib, libdir, 0555, true
- end
+Installer.install dll, bindir, 0755, true unless dll == lib
+Installer.install lib, libdir, 0555, true unless lib == arc
+Installer.install arc, archlibdir, 0644, true
+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
end
end
-Dir.chdir libdir
-if File.exist? CONFIG["LIBRUBY_SO"]
+
+if dll == lib and dll != arc
for link in CONFIG["LIBRUBY_ALIASES"].split
- if File.exist? link
- File.delete link
- end
- File.symlink CONFIG["LIBRUBY_SO"], link
- print "link #{CONFIG['LIBRUBY_SO']} -> #{link}\n"
+ Installer.makelink(dll, File.join(libdir, link), true)
end
end
-Dir.chdir wdir
-File.makedirs rubylibdir, true
-File.makedirs archlibdir, true
-File.makedirs sitelibdir, true
-File.makedirs sitearchlibdir, true
-
-if RUBY_PLATFORM =~ /-aix/
- File.install "ruby.imp", archlibdir, 0644, true
-end
-
-system "#{CONFIG['MINIRUBY']} #{CONFIG['srcdir']}/ext/extmk.rb install #{destdir}"
Dir.chdir CONFIG["srcdir"]
-File.install "sample/irb.rb", "#{bindir}/irb", 0755, true
+Installer.install "sample/irb.rb", "#{bindir}/irb", 0755, true
-Find.find("lib") do |f|
- next unless /\.rb$/ =~ f || /help-message$/ =~ f
- dir = rubylibdir+"/"+File.dirname(f[4..-1])
- File.makedirs dir, true unless File.directory? dir
- File.install f, dir, 0644, true
+Dir.glob("lib/*{.rb,help-message}") do |f|
+ dir = File.dirname(f).sub!(/\Alib/, rubylibdir) || rubylibdir
+ Installer.makedirs dir, true unless File.directory? dir
+ Installer.install f, dir, 0644, true
end
for f in Dir["*.h"]
- File.install f, archlibdir, 0644, true
+ Installer.install f, archlibdir, 0644, true
end
if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
- File.makedirs archlibdir + "/win32", true
- File.install "win32/win32.h", archlibdir + "/win32", 0644, true
+ Installer.makedirs archlibdir + "/win32", true
+ Installer.install "win32/win32.h", archlibdir + "/win32", 0644, true
end
-File.install wdir+'/'+CONFIG['LIBRUBY_A'], archlibdir, 0644, true
-File.makedirs mandir, true
-File.install "ruby.1", mandir+"/"+ruby_install_name+".1", 0644, true
-Dir.chdir wdir
-File.install "config.h", archlibdir, 0644, true
-File.install "rbconfig.rb", archlibdir, 0644, true
+Installer.makedirs mandir, true
+Installer.install "ruby.1", mandir+"/"+ruby_install_name+".1", 0644, true
+
# vi:set sw=2: