diff --git a/ChangeLog b/ChangeLog index c8f07f3a42..5fc4e8e7da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Feb 22 12:58:35 2004 Nobuyoshi Nakada + + * 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 * re.c: corrected documentation format (rb_reg_initialize_m) diff --git a/Makefile.in b/Makefile.in index 26796342c5..bd626c4f1e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -64,7 +64,8 @@ LIBRUBYARG = @LIBRUBYARG@ LIBRUBYARG_STATIC = @LIBRUBYARG_STATIC@ LIBRUBYARG_SHARED = @LIBRUBYARG_SHARED@ -PREP = @PREP@ @ARCHFILE@ +PREP = @PREP@ +ARCHFILE = @ARCHFILE@ SETUP = EXTSTATIC = @EXTSTATIC@ @@ -118,7 +119,7 @@ SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \ --make="$(MAKE)" \ --mflags="$(MFLAGS)" \ --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) @$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS) @@ -143,7 +144,7 @@ $(LIBRUBY_A): $(OBJS) $(DMYEXT) @AR@ rcu $@ $(OBJS) $(DMYEXT) @-@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 $@ @-$(MINIRUBY) -e 'ARGV.each{|link| File.delete link if File.exist? link; \ File.symlink "$(LIBRUBY_SO)", link}' \ diff --git a/bcc32/Makefile.sub b/bcc32/Makefile.sub index 6de146eb12..b8ff2d4dec 100644 --- a/bcc32/Makefile.sub +++ b/bcc32/Makefile.sub @@ -214,7 +214,7 @@ SCRIPT_ARGS = "--dest-dir=$(DESTDIR)" \ "--make=$(MAKE)" \ "--mflags=$(MFLAGS)" \ "--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 \ $(LIBRUBY) $(MISCLIBS) diff --git a/ext/extmk.rb b/ext/extmk.rb index c20cd5a93a..1aefcb8715 100644 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -25,7 +25,7 @@ srcdir = Config::CONFIG["srcdir"] $:.replace [srcdir, srcdir+"/lib", "."] require 'mkmf' -require 'getopts' +require 'optparse/shellwords' $topdir = "." $top_srcdir = srcdir @@ -137,41 +137,45 @@ def extmake(target) end def parse_args() - getopts('n', 'extstatic:', 'extension:', 'dest-dir:', 'extout:', - 'make:', 'make-flags:', 'mflags:', 'message:') + $mflags = [] - $dryrun = $OPT['n'] - if $extension = $OPT['extension'] - if $extension.empty? - $extension = nil - elsif $extension == "none" - $extension = [] - else - $extension = $extension.split(/[\s,]+/) + opts = nil + ARGV.options do |opts| + opts.on('-n') {$dryrun = true} + opts.on('--[no-]extension [EXTS]', Array) do |v| + $extension = (v == false ? [] : v) end - end - if $extstatic = $OPT['extstatic'] - if $extstatic.empty? - $extstatic = nil - elsif $extstatic == "none" - $extstatic = "" - else - $force_static = true - $extstatic = nil if $extstatic == 'static' + opts.on('--[no-]extstatic [STATIC]', Array) do |v| + if ($extstatic = v) == false + $extstatic = [] + elsif v + $force_static = true + $extstatic.delete("static") + $extstatic = nil if $extstatic.empty? + end end - end - $destdir = $OPT['dest-dir'] || '' - if opt = $OPT['extout'] and !opt.empty? - $extout = opt - end - $make = $OPT['make'] || $make || 'make' - mflags = ($OPT['make-flags'] || '').strip - mflags = ($OPT['mflags'] || '').strip if mflags.empty? + opts.on('--dest-dir=DIR') do |v| + $destdir = v + end + opts.on('--extout=DIR') do |v| + $extout = (v unless v.empty?) + end + opts.on('--make=MAKE') do |v| + $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) - if arg = $mflags.first - arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg - end + $destdir ||= '' $make, *rest = Shellwords.shellwords($make) $mflags.unshift(*rest) unless rest.empty? @@ -200,8 +204,6 @@ def parse_args() $extout_prefix = $extout ? "$(extout)$(target_prefix)/" : "" $mflags << "extout=#$extout" << "extout_prefix=#$extout_prefix" end - - $message = $OPT['message'] end parse_args() diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 4454d5a6dc..73cd67e53f 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -207,7 +207,7 @@ SCRIPT_ARGS = "--dest-dir=$(DESTDIR)" \ "--make=$(MAKE)" \ "--mflags=$(MFLAGS)" \ "--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 \ $(LIBRUBY) $(MISCLIBS)