* 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
This commit is contained in:
knu 2003-01-25 18:59:34 +00:00
Родитель cdc46f0f83
Коммит 78f457a5d5
6 изменённых файлов: 121 добавлений и 57 удалений

Просмотреть файл

@ -1,3 +1,13 @@
Sun Jan 26 03:37:18 2003 Akinori MUSHA <knu@iDaemons.org>
* 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.
Fri Jan 24 18:15:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org> Fri Jan 24 18:15:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y: tMINUS should have lower precedence than tPOW. * parse.y: tMINUS should have lower precedence than tPOW.

Просмотреть файл

@ -102,8 +102,13 @@ OBJS = array.@OBJEXT@ \
MANTYPE = @MANTYPE@ MANTYPE = @MANTYPE@
SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
--make="$(MAKE)" \
--mflags="$(MFLAGS)" \
--make-flags="$(MAKEFLAGS)"
all: @MAKEFILES@ miniruby$(EXEEXT) rbconfig.rb $(LIBRUBY) all: @MAKEFILES@ miniruby$(EXEEXT) rbconfig.rb $(LIBRUBY)
@$(MINIRUBY) $(srcdir)/ext/extmk.rb --extstatic="@EXTSTATIC@" --make="$(MAKE)" --make-flags="$(MFLAGS)$(MAKEFLAGS)" @$(MINIRUBY) $(srcdir)/ext/extmk.rb --extstatic="@EXTSTATIC@" $(SCRIPT_ARGS)
miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) dmyext.@OBJEXT@ miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) dmyext.@OBJEXT@
@rm -f $@ @rm -f $@
@ -128,15 +133,15 @@ ruby.imp: $(LIBRUBY_A)
# $(MINIRUBY) $< $@ # $(MINIRUBY) $< $@
install: rbconfig.rb install: rbconfig.rb
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" --make-flags="$(MFLAGS)$(MAKEFLAGS)" --mantype=$(MANTYPE) $(DESTDIR) $(MINIRUBY) $(srcdir)/instruby.rb $(SCRIPT_ARGS) --mantype="$(MANTYPE)"
$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --make-flags="$(MFLAGS)$(MAKEFLAGS) DESTDIR=$(DESTDIR)" install $(MINIRUBY) $(srcdir)/ext/extmk.rb $(SCRIPT_ARGS) install
what-where no-install: rbconfig.rb what-where no-install: rbconfig.rb
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" --make-flags="$(MFLAGS)$(MAKEFLAGS) -n" --mantype=$(MANTYPE) $(DESTDIR) $(MINIRUBY) $(srcdir)/instruby.rb -n $(SCRIPT_ARGS) --mantype="$(MANTYPE)"
$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --make-flags="$(MFLAGS)$(MAKEFLAGS) -n DESTDIR=$(DESTDIR)" install $(MINIRUBY) $(srcdir)/ext/extmk.rb -n $(SCRIPT_ARGS) install
clean-ext: clean-ext:
@-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --make-flags="$(MFLAGS)$(MAKEFLAGS)" clean 2> /dev/null || true @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(SCRIPT_ARGS) clean 2> /dev/null || true
clean-local: clean-local:
@rm -f $(OBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES) @rm -f $(OBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES)
@ -146,7 +151,7 @@ clean-local:
clean: clean-ext clean-local clean: clean-ext clean-local
distclean-ext: distclean-ext:
@-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --make-flags="$(MFLAGS)$(MAKEFLAGS)" distclean 2> /dev/null || true @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(SCRIPT_ARGS) distclean 2> /dev/null || true
distclean-local: clean-local distclean-local: clean-local
@rm -f @MAKEFILES@ config.h rbconfig.rb @rm -f @MAKEFILES@ config.h rbconfig.rb

Просмотреть файл

@ -182,9 +182,14 @@ OBJS = array.obj \
version.obj \ version.obj \
$(MISSING) $(MISSING)
SCRIPT_ARGS = "--dest-dir=$(DESTDIR)" \
"--make=$(MAKE)" \
"--mflags=$(MFLAGS)" \
"--make-flags=$(MAKEFLAGS)"
all: miniruby$(EXEEXT) rbconfig.rb \ all: miniruby$(EXEEXT) rbconfig.rb \
$(LIBRUBY) $(MISCLIBS) $(LIBRUBY) $(MISCLIBS)
.\miniruby$(EXEEXT) $(srcdir)ext/extmk.rb --extstatic=$(EXTSTATIC) --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS)" .\miniruby$(EXEEXT) $(srcdir)ext/extmk.rb --extstatic=$(EXTSTATIC) $(SCRIPT_ARGS)
ruby: $(PROGRAM) ruby: $(PROGRAM)
rubyw: $(WPROGRAM) rubyw: $(WPROGRAM)
@ -408,12 +413,12 @@ $(RUBYDEF): $(LIBRUBY_A) miniruby$(EXEEXT)
$(MINIRUBY) $(srcdir)bcc32/mkexports.rb -output=$@ $(LIBRUBY_A) $(MINIRUBY) $(srcdir)bcc32/mkexports.rb -output=$@ $(LIBRUBY_A)
install: rbconfig.rb install: rbconfig.rb
$(MINIRUBY) $(srcdir)instruby.rb --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS)" $(DESTDIR) $(MINIRUBY) $(srcdir)instruby.rb $(SCRIPT_ARGS)
$(MINIRUBY) $(srcdir)ext/extmk.rb --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS) DESTDIR=$(DESTDIR)" install $(MINIRUBY) $(srcdir)ext/extmk.rb $(SCRIPT_ARGS) install
what-where no-install: rbconfig.rb what-where no-install: rbconfig.rb
$(MINIRUBY) $(srcdir)instruby.rb --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS) -n" $(DESTDIR) $(MINIRUBY) $(srcdir)instruby.rb -n $(SCRIPT_ARGS)
$(MINIRUBY) $(srcdir)ext/extmk.rb --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS) -n DESTDIR=$(DESTDIR)" install $(MINIRUBY) $(srcdir)ext/extmk.rb -n $(SCRIPT_ARGS) install
clean: clean-ext clean-local clean: clean-ext clean-local
@ -430,7 +435,7 @@ clean-local:
@if exist *.il? del *.il? @if exist *.il? del *.il?
clean-ext: clean-ext:
@-$(MINIRUBY) $(srcdir)ext/extmk.rb --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS)" clean @-$(MINIRUBY) $(srcdir)ext/extmk.rb $(SCRIPT_ARGS) clean
distclean: distclean-ext distclean-local distclean: distclean-ext distclean-local
@ -464,7 +469,7 @@ distclean-local: clean-local
@if exist miniruby$(EXEEXT) del miniruby$(EXEEXT) @if exist miniruby$(EXEEXT) del miniruby$(EXEEXT)
distclean-ext: distclean-ext:
@-$(MINIRUBY) $(srcdir)ext/extmk.rb --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS)" distclean @-$(MINIRUBY) $(srcdir)ext/extmk.rb $(SCRIPT_ARGS) distclean
realclean: distclean realclean: distclean
@if exist parse.c del parse.c @if exist parse.c del parse.c

Просмотреть файл

@ -27,6 +27,7 @@ $:.replace [srcdir, srcdir+"/lib", "."]
require 'mkmf' require 'mkmf'
require 'ftools' require 'ftools'
require 'shellwords' require 'shellwords'
require 'getopts'
$topdir = File.expand_path(".") $topdir = File.expand_path(".")
$top_srcdir = srcdir $top_srcdir = srcdir
@ -113,22 +114,40 @@ def extmake(target)
true true
end end
require 'getopts' def parse_args()
getopts('n', 'extstatic:', 'dest-dir:',
'make:', 'make-flags:', 'mflags:')
getopts('', 'extstatic', 'make:', 'make-flags:') $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
$force_static = $OPT['extstatic'] == 'static' # BSD make defines both MFLAGS and MAKEFLAGS, and MAKEFLAGS it
$make = $OPT['make'] || $make # defines includes a preceding '-' unlike other implementations.
$mflags = Shellwords.shellwords($OPT['make-flags'] || "").uniq # So we use MFLAGS if defined, otherwise use ('-' + MAKEFLAGS).
$mflags[0].sub!(/^\w+$/, '-\&') unless $mflags.empty? if mflags.empty?
$make, *$mflags[0, 0] = Shellwords.shellwords($make) mflags = "-#{make_flags}" unless make_flags.empty?
end
$mflags.delete_if{|x| x == '-' || x == '--'} $mflags = Shellwords.shellwords(mflags)
$make, *rest = Shellwords.shellwords($make)
$mflags.unshift(*rest) unless rest.empty?
mflags = $mflags.grep(/^-([^-])/){$1}.join $mflags << '-n' if $dryrun
mflags.downcase! if $nmake == ?m
$continue = mflags.include?(?k) $mflags << "DESTDIR=#{$destdir}"
$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 unless $message
if $message = ARGV.shift and /^[a-z]+$/ =~ $message if $message = ARGV.shift and /^[a-z]+$/ =~ $message
@ -149,8 +168,6 @@ unless $message
end end
end end
$mflags = $mflags.partition{|x| x[0] == ?-}.flatten!
EXEEXT = CONFIG['EXEEXT'] EXEEXT = CONFIG['EXEEXT']
if CROSS_COMPILING if CROSS_COMPILING
$ruby = CONFIG['MINIRUBY'] $ruby = CONFIG['MINIRUBY']

Просмотреть файл

@ -11,18 +11,40 @@ require 'tempfile'
File.umask(0) File.umask(0)
getopts("n", "make:", "make-flags:", "mantype:doc") def parse_args()
$dryrun = $OPT["n"] getopts('n', 'dest-dir:',
mflags = Shellwords.shellwords($OPT["make-flags"] || "").uniq 'make:', 'make-flags:', 'mflags:',
mflags[0].sub!(/^\w+$/, '-\&') unless mflags.empty? 'mantype:doc')
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] == ?-} $dryrun = $OPT['n']
destdir = ARGV[0] || '' $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::Verbose
include FileUtils::NoWrite if $dryrun include FileUtils::NoWrite if $dryrun
@ -36,13 +58,13 @@ ruby_install_name = CONFIG["ruby_install_name"]
rubyw_install_name = CONFIG["rubyw_install_name"] rubyw_install_name = CONFIG["rubyw_install_name"]
version = CONFIG["ruby_version"] version = CONFIG["ruby_version"]
bindir = destdir+CONFIG["bindir"] bindir = $destdir+CONFIG["bindir"]
libdir = destdir+CONFIG["libdir"] libdir = $destdir+CONFIG["libdir"]
rubylibdir = destdir+CONFIG["rubylibdir"] rubylibdir = $destdir+CONFIG["rubylibdir"]
archlibdir = destdir+CONFIG["archdir"] archlibdir = $destdir+CONFIG["archdir"]
sitelibdir = destdir+CONFIG["sitelibdir"] sitelibdir = $destdir+CONFIG["sitelibdir"]
sitearchlibdir = destdir+CONFIG["sitearchdir"] sitearchlibdir = $destdir+CONFIG["sitearchdir"]
mandir = File.join(destdir+CONFIG["mandir"], "man") mandir = File.join($destdir+CONFIG["mandir"], "man")
configure_args = Shellwords.shellwords(CONFIG["configure_args"]) configure_args = Shellwords.shellwords(CONFIG["configure_args"])
enable_shared = CONFIG["ENABLE_SHARED"] == 'yes' enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
dll = CONFIG["LIBRUBY_SO"] dll = CONFIG["LIBRUBY_SO"]
@ -139,12 +161,12 @@ end
Dir.glob("*.[1-9]") do |mdoc| Dir.glob("*.[1-9]") do |mdoc|
section = mdoc[-1,1] section = mdoc[-1,1]
destdir = mandir + section $destdir = mandir + section
destfile = File.join(destdir, mdoc.sub(/ruby/, ruby_install_name)) destfile = File.join($destdir, mdoc.sub(/ruby/, ruby_install_name))
makedirs destdir makedirs $destdir
if mantype == "doc" if $mantype == "doc"
install mdoc, destfile, 0644 install mdoc, destfile, 0644
else else
require 'mdoc2man.rb' require 'mdoc2man.rb'

Просмотреть файл

@ -169,9 +169,14 @@ OBJS = array.obj \
version.obj \ version.obj \
$(MISSING) $(MISSING)
SCRIPT_ARGS = "--dest-dir=$(DESTDIR)" \
"--make=$(MAKE)" \
"--mflags=$(MFLAGS)" \
"--make-flags=$(MAKEFLAGS)"
all: ext miniruby$(EXEEXT) rbconfig.rb \ all: ext miniruby$(EXEEXT) rbconfig.rb \
$(LIBRUBY) $(MISCLIBS) $(LIBRUBY) $(MISCLIBS)
@$(MINIRUBY) $(srcdir)/ext/extmk.rb --extstatic=$(EXTSTATIC) --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS)" @$(MINIRUBY) $(srcdir)/ext/extmk.rb --extstatic=$(EXTSTATIC) $(SCRIPT_ARGS)
ext: ext:
@mkdir $@ @mkdir $@
@ -408,12 +413,12 @@ $(RUBYDEF): $(LIBRUBY_A) miniruby$(EXEEXT)
$(AR) $(ARFLAGS)$@ -def:$< $(AR) $(ARFLAGS)$@ -def:$<
install: rbconfig.rb install: rbconfig.rb
$(MINIRUBY) $(srcdir)/instruby.rb --make-flags "$(MFLAGS)$(MAKEFLAGS)" $(DESTDIR) $(MINIRUBY) $(srcdir)/instruby.rb $(SCRIPT_ARGS)
$(MINIRUBY) $(srcdir)/ext/extmk.rb --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS) DESTDIR=$(DESTDIR)" install $(MINIRUBY) $(srcdir)/ext/extmk.rb $(SCRIPT_ARGS) install
what-where no-install: rbconfig.rb what-where no-install: rbconfig.rb
$(MINIRUBY) $(srcdir)/instruby.rb --make-flags "$(MFLAGS)$(MAKEFLAGS) -n" $(DESTDIR) $(MINIRUBY) $(srcdir)/instruby.rb -n $(SCRIPT_ARGS)
$(MINIRUBY) $(srcdir)/ext/extmk.rb --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS) -n DESTDIR=$(DESTDIR)" install $(MINIRUBY) $(srcdir)/ext/extmk.rb -n $(SCRIPT_ARGS) install
clean: clean-ext clean-local clean: clean-ext clean-local
@ -428,7 +433,7 @@ clean-local:
@if exist *.res del *.res @if exist *.res del *.res
clean-ext: clean-ext:
@-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS)" clean @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(SCRIPT_ARGS) clean
distclean: distclean-ext distclean-local distclean: distclean-ext distclean-local
@ -462,7 +467,7 @@ distclean-local: clean-local
@if exist miniruby$(EXEEXT) del miniruby$(EXEEXT) @if exist miniruby$(EXEEXT) del miniruby$(EXEEXT)
distclean-ext: distclean-ext:
@-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make "$(MAKE)" --make-flags "$(MFLAGS)$(MAKEFLAGS)" distclean @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(SCRIPT_ARGS) distclean
realclean: distclean realclean: distclean
@if exist parse.c del parse.c @if exist parse.c del parse.c