* ext/extmk.rb: use optparse instead of getopts.

* Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2004-02-22 03:58:44 +00:00
parent ac19769719
commit 883857d842
5 changed files with 48 additions and 39 deletions

View File

@ -1,3 +1,9 @@
Sun Feb 22 12:58:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb: use optparse instead of getopts.
* Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub: ditto.
Sat Feb 22 09:51:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au> Sat Feb 22 09:51:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
* re.c: corrected documentation format (rb_reg_initialize_m) * re.c: corrected documentation format (rb_reg_initialize_m)

View File

@ -64,7 +64,8 @@ LIBRUBYARG = @LIBRUBYARG@
LIBRUBYARG_STATIC = @LIBRUBYARG_STATIC@ LIBRUBYARG_STATIC = @LIBRUBYARG_STATIC@
LIBRUBYARG_SHARED = @LIBRUBYARG_SHARED@ LIBRUBYARG_SHARED = @LIBRUBYARG_SHARED@
PREP = @PREP@ @ARCHFILE@ PREP = @PREP@
ARCHFILE = @ARCHFILE@
SETUP = SETUP =
EXTSTATIC = @EXTSTATIC@ EXTSTATIC = @EXTSTATIC@
@ -118,7 +119,7 @@ SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
--make="$(MAKE)" \ --make="$(MAKE)" \
--mflags="$(MFLAGS)" \ --mflags="$(MFLAGS)" \
--make-flags="$(MAKEFLAGS)" --make-flags="$(MAKEFLAGS)"
EXTMK_ARGS = $(SCRIPT_ARGS) --extout="$(EXTOUT)" --extension="$(EXTS)" --extstatic="$(EXTSTATIC)" EXTMK_ARGS = $(SCRIPT_ARGS) --extout="$(EXTOUT)" --extension $(EXTS) --extstatic $(EXTSTATIC)
all: @MAKEFILES@ miniruby$(EXEEXT) rbconfig.rb $(LIBRUBY) all: @MAKEFILES@ miniruby$(EXEEXT) rbconfig.rb $(LIBRUBY)
@$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS) @$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
@ -143,7 +144,7 @@ $(LIBRUBY_A): $(OBJS) $(DMYEXT)
@AR@ rcu $@ $(OBJS) $(DMYEXT) @AR@ rcu $@ $(OBJS) $(DMYEXT)
@-@RANLIB@ $@ 2> /dev/null || true @-@RANLIB@ $@ 2> /dev/null || true
$(LIBRUBY_SO): $(OBJS) $(DLDOBJS) miniruby$(EXEEXT) $(PREP) $(LIBRUBY_SO): $(OBJS) $(DLDOBJS) miniruby$(EXEEXT) $(PREP) $(ARCHFILE)
$(LDSHARED) $(DLDFLAGS) $(OBJS) $(DLDOBJS) $(SOLIBS) -o $@ $(LDSHARED) $(DLDFLAGS) $(OBJS) $(DLDOBJS) $(SOLIBS) -o $@
@-$(MINIRUBY) -e 'ARGV.each{|link| File.delete link if File.exist? link; \ @-$(MINIRUBY) -e 'ARGV.each{|link| File.delete link if File.exist? link; \
File.symlink "$(LIBRUBY_SO)", link}' \ File.symlink "$(LIBRUBY_SO)", link}' \

View File

@ -214,7 +214,7 @@ SCRIPT_ARGS = "--dest-dir=$(DESTDIR)" \
"--make=$(MAKE)" \ "--make=$(MAKE)" \
"--mflags=$(MFLAGS)" \ "--mflags=$(MFLAGS)" \
"--make-flags=$(MAKEFLAGS)" "--make-flags=$(MAKEFLAGS)"
EXTMK_ARGS = $(SCRIPT_ARGS) --extout="$(EXTOUT)" --extension="$(EXTS)" --extstatic="$(EXTSTATIC)" EXTMK_ARGS = $(SCRIPT_ARGS) --extout="$(EXTOUT)" --extension $(EXTS) --extstatic $(EXTSTATIC)
all: miniruby$(EXEEXT) rbconfig.rb \ all: miniruby$(EXEEXT) rbconfig.rb \
$(LIBRUBY) $(MISCLIBS) $(LIBRUBY) $(MISCLIBS)

View File

@ -25,7 +25,7 @@ srcdir = Config::CONFIG["srcdir"]
$:.replace [srcdir, srcdir+"/lib", "."] $:.replace [srcdir, srcdir+"/lib", "."]
require 'mkmf' require 'mkmf'
require 'getopts' require 'optparse/shellwords'
$topdir = "." $topdir = "."
$top_srcdir = srcdir $top_srcdir = srcdir
@ -137,41 +137,45 @@ def extmake(target)
end end
def parse_args() def parse_args()
getopts('n', 'extstatic:', 'extension:', 'dest-dir:', 'extout:', $mflags = []
'make:', 'make-flags:', 'mflags:', 'message:')
$dryrun = $OPT['n'] opts = nil
if $extension = $OPT['extension'] ARGV.options do |opts|
if $extension.empty? opts.on('-n') {$dryrun = true}
$extension = nil opts.on('--[no-]extension [EXTS]', Array) do |v|
elsif $extension == "none" $extension = (v == false ? [] : v)
$extension = []
else
$extension = $extension.split(/[\s,]+/)
end end
end opts.on('--[no-]extstatic [STATIC]', Array) do |v|
if $extstatic = $OPT['extstatic'] if ($extstatic = v) == false
if $extstatic.empty? $extstatic = []
$extstatic = nil elsif v
elsif $extstatic == "none" $force_static = true
$extstatic = "" $extstatic.delete("static")
else $extstatic = nil if $extstatic.empty?
$force_static = true end
$extstatic = nil if $extstatic == 'static'
end end
end opts.on('--dest-dir=DIR') do |v|
$destdir = $OPT['dest-dir'] || '' $destdir = v
if opt = $OPT['extout'] and !opt.empty? end
$extout = opt opts.on('--extout=DIR') do |v|
end $extout = (v unless v.empty?)
$make = $OPT['make'] || $make || 'make' end
mflags = ($OPT['make-flags'] || '').strip opts.on('--make=MAKE') do |v|
mflags = ($OPT['mflags'] || '').strip if mflags.empty? $make = v || 'make'
end
opts.on('--make-flags=FLAGS', '--mflags', Shellwords) do |v|
if arg = v.first
arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
end
$mflags.concat(v)
end
opts.on('--message [MESSAGE]', String) do |v|
$message = v
end
opts.parse!
end or abort opts.to_s
$mflags = Shellwords.shellwords(mflags) $destdir ||= ''
if arg = $mflags.first
arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
end
$make, *rest = Shellwords.shellwords($make) $make, *rest = Shellwords.shellwords($make)
$mflags.unshift(*rest) unless rest.empty? $mflags.unshift(*rest) unless rest.empty?
@ -200,8 +204,6 @@ def parse_args()
$extout_prefix = $extout ? "$(extout)$(target_prefix)/" : "" $extout_prefix = $extout ? "$(extout)$(target_prefix)/" : ""
$mflags << "extout=#$extout" << "extout_prefix=#$extout_prefix" $mflags << "extout=#$extout" << "extout_prefix=#$extout_prefix"
end end
$message = $OPT['message']
end end
parse_args() parse_args()

View File

@ -207,7 +207,7 @@ SCRIPT_ARGS = "--dest-dir=$(DESTDIR)" \
"--make=$(MAKE)" \ "--make=$(MAKE)" \
"--mflags=$(MFLAGS)" \ "--mflags=$(MFLAGS)" \
"--make-flags=$(MAKEFLAGS)" "--make-flags=$(MAKEFLAGS)"
EXTMK_ARGS = $(SCRIPT_ARGS) --extout="$(EXTOUT)" --extension="$(EXTS)" --extstatic="$(EXTSTATIC)" EXTMK_ARGS = $(SCRIPT_ARGS) --extout="$(EXTOUT)" --extension $(EXTS) --extstatic $(EXTSTATIC)
all: ext miniruby$(EXEEXT) rbconfig.rb \ all: ext miniruby$(EXEEXT) rbconfig.rb \
$(LIBRUBY) $(MISCLIBS) $(LIBRUBY) $(MISCLIBS)