summaryrefslogtreecommitdiffstats
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
commitf0103202cc0764f3be151d954b411af0ced8ebcd (patch)
tree39811750f5d3501bbf07c86f93dd590d35aa406c /ext
parent8cc9a073b850c2f251af8301aca8a3b03bee402f (diff)
downloadruby-f0103202cc0764f3be151d954b411af0ced8ebcd.tar.gz
ruby-f0103202cc0764f3be151d954b411af0ced8ebcd.tar.xz
ruby-f0103202cc0764f3be151d954b411af0ced8ebcd.zip
* 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: http://svn.ruby-lang.org/repos/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 97cf4b4a2..2cee3df3d 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']