summaryrefslogtreecommitdiff
path: root/ext
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 /ext
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 'ext')
-rw-r--r--ext/extmk.rb45
1 files changed, 31 insertions, 14 deletions
diff --git a/ext/extmk.rb b/ext/extmk.rb
index 97cf4b4a2f..2cee3df3dc 100644
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -27,6 +27,7 @@ $:.replace [srcdir, srcdir+"/lib", "."]
require 'mkmf'
require 'ftools'
require 'shellwords'
+require 'getopts'
$topdir = File.expand_path(".")
$top_srcdir = srcdir
@@ -113,22 +114,40 @@ def extmake(target)
true
end
-require 'getopts'
+def parse_args()
+ getopts('n', 'extstatic:', 'dest-dir:',
+ 'make:', 'make-flags:', 'mflags:')
+
+ $dryrun = $OPT['n']
+ $force_static = $OPT['extstatic'] == 'static'
+ $destdir = $OPT['dest-dir'] || ''
+ $make = $OPT['make'] || $make
+ make_flags = ($OPT['make-flags'] || '').strip
+ mflags = ($OPT['mflags'] || '').strip
+
+ # 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
-getopts('', 'extstatic', 'make:', 'make-flags:')
+ $mflags = Shellwords.shellwords(mflags)
+ $make, *rest = Shellwords.shellwords($make)
+ $mflags.unshift(*rest) unless rest.empty?
-$force_static = $OPT['extstatic'] == 'static'
-$make = $OPT['make'] || $make
-$mflags = Shellwords.shellwords($OPT['make-flags'] || "").uniq
-$mflags[0].sub!(/^\w+$/, '-\&') unless $mflags.empty?
-$make, *$mflags[0, 0] = Shellwords.shellwords($make)
+ $mflags << '-n' if $dryrun
-$mflags.delete_if{|x| x == '-' || x == '--'}
+ $mflags << "DESTDIR=#{$destdir}"
-mflags = $mflags.grep(/^-([^-])/){$1}.join
-mflags.downcase! if $nmake == ?m
-$continue = mflags.include?(?k)
-$dryrun = mflags.include?(?n)
+ # Most make implementations put each flag separated in MAKEFLAGS, so
+ # we can just search for an option with exact match. Only nmake
+ # puts flags together, but nmake does not propagate -k via MAKEFLAGS
+ # anyway.
+ $continue = $mflags.include?('-k')
+end
+
+parse_args()
unless $message
if $message = ARGV.shift and /^[a-z]+$/ =~ $message
@@ -149,8 +168,6 @@ unless $message
end
end
-$mflags = $mflags.partition{|x| x[0] == ?-}.flatten!
-
EXEEXT = CONFIG['EXEEXT']
if CROSS_COMPILING
$ruby = CONFIG['MINIRUBY']