summaryrefslogtreecommitdiff
path: root/instruby.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-25 18:59:34 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-25 18:59:34 +0000
commit78f457a5d57b06e2e28931e46bef2ee64a0de8a9 (patch)
tree39811750f5d3501bbf07c86f93dd590d35aa406c /instruby.rb
parentcdc46f0f833cad58fd3a2e3499a6f06a11eebb5c (diff)
* instruby.rb, ext/extmk.rb, Makefile.in, win32/Makefile.sub,
bcc32/Makefile.sub: Replace the complicated MFLAGS/MAKEFLAGS parser with something plain and comprehensible. This fixes a bug where make flags were wrongly reordered and the resulted command line often did not make sense especially when BSD make is used with extra arguments given. Tested with FreeBSD and Linux by me and mswin32, bccwin32 and mingw by usa. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'instruby.rb')
-rw-r--r--instruby.rb68
1 files changed, 45 insertions, 23 deletions
diff --git a/instruby.rb b/instruby.rb
index 7483f1e..16caec1 100644
--- a/instruby.rb
+++ b/instruby.rb
@@ -11,18 +11,40 @@ require 'tempfile'
File.umask(0)
-getopts("n", "make:", "make-flags:", "mantype:doc")
-$dryrun = $OPT["n"]
-mflags = Shellwords.shellwords($OPT["make-flags"] || "").uniq
-mflags[0].sub!(/^\w+$/, '-\&') unless mflags.empty?
-make, *mflags[0, 0] = Shellwords.shellwords($OPT['make'] || ENV["MAKE"] || "")
-mflags = mflags.grep(/^-([^-])/){$1}.join
-mflags.downcase! if /nmake/i == make
-$dryrun = true if mflags.include?(?n)
-mantype = $OPT["mantype"]
-
-ARGV.delete_if{|x|x[0] == ?-}
-destdir = ARGV[0] || ''
+def parse_args()
+ getopts('n', 'dest-dir:',
+ 'make:', 'make-flags:', 'mflags:',
+ 'mantype:doc')
+
+ $dryrun = $OPT['n']
+ $destdir = $OPT['dest-dir'] || ''
+ $make = $OPT['make'] || $make
+ make_flags = ($OPT['make-flags'] || '').strip
+ mflags = ($OPT['mflags'] || '').strip
+ $mantype = $OPT["mantype"]
+
+ # BSD make defines both MFLAGS and MAKEFLAGS, and MAKEFLAGS it
+ # defines includes a preceding '-' unlike other implementations.
+ # So we use MFLAGS if defined, otherwise use ('-' + MAKEFLAGS).
+ if mflags.empty?
+ mflags = "-#{make_flags}" unless make_flags.empty?
+ end
+
+ $mflags = Shellwords.shellwords(mflags)
+ $make, *rest = Shellwords.shellwords($make)
+ $mflags.unshift(*rest) unless rest.empty?
+
+ $mflags << '-n' if $dryrun
+
+ $mflags << "DESTDIR=#{$destdir}"
+
+ # Most make implementations put each flag separated in MAKEFLAGS, so
+ # we can just search with exact match. Only nmake puts flags
+ # together, but nmake does not propagate -k via MAKEFLAGS anyway.
+ $continue = $mflags.include?('-k')
+end
+
+parse_args()
include FileUtils::Verbose
include FileUtils::NoWrite if $dryrun
@@ -36,13 +58,13 @@ ruby_install_name = CONFIG["ruby_install_name"]
rubyw_install_name = CONFIG["rubyw_install_name"]
version = CONFIG["ruby_version"]
-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")
+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")
configure_args = Shellwords.shellwords(CONFIG["configure_args"])
enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
dll = CONFIG["LIBRUBY_SO"]
@@ -139,12 +161,12 @@ end
Dir.glob("*.[1-9]") do |mdoc|
section = mdoc[-1,1]
- destdir = mandir + section
- destfile = File.join(destdir, mdoc.sub(/ruby/, ruby_install_name))
+ $destdir = mandir + section
+ destfile = File.join($destdir, mdoc.sub(/ruby/, ruby_install_name))
- makedirs destdir
+ makedirs $destdir
- if mantype == "doc"
+ if $mantype == "doc"
install mdoc, destfile, 0644
else
require 'mdoc2man.rb'