From 5c51ccc35c78651cfa98546fae06901db76c3265 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 2 Apr 2004 09:00:12 +0000 Subject: [PATCH] * ext/extmk.rb (extmake): extract necessary variables for static link from Makefile. * lib/mkmf.rb (create_makefile): save preload and libpath for next compile. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 +++++++++- ext/extmk.rb | 36 ++++++++++++++++++++++++++++-------- lib/mkmf.rb | 10 ++++++---- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index b0d798d985..c3bdb164f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Apr 2 18:00:05 2004 Nobuyoshi Nakada + + * ext/extmk.rb (extmake): extract necessary variables for static link + from Makefile. + + * lib/mkmf.rb (create_makefile): save preload and libpath for next + compile. + Fri Apr 2 17:27:17 2004 Yukihiro Matsumoto * eval.c (top_include): include in the wrapped load is done for @@ -50,7 +58,7 @@ Thu Apr 1 19:58:37 2004 NAKAMURA, Hiroshi object with soap/marshal. added URIFactory class for URI mapping. BasetypeFactory checks instance_variables when original mapping is not allowed (ivar must - be empty). Instance of URI have instance_variables but it must be + be empty). Instance of URI have instance_variables but it must be llowed whenever original mapping is allowed or not. Wed Mar 31 19:06:23 2004 Tanaka Akira diff --git a/ext/extmk.rb b/ext/extmk.rb index 94c091728f..f6f5224652 100644 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -16,6 +16,7 @@ alias $PROGRAM_NAME $0 alias $0 $progname $extlist = [] +$extupdate = false $:.replace ["."] require 'rbconfig' @@ -74,8 +75,7 @@ def extmake(target) $preload = nil makefile = "./Makefile" unless $ignore - if $static || - !(t = modified?(makefile, MTIMES)) || + if !(t = modified?(makefile, MTIMES)) || %W<#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb #{$srcdir}/depend #{$srcdir}/MANIFEST>.any? {|f| modified?(f, [t])} then @@ -91,6 +91,7 @@ def extmake(target) else create_makefile(target) end + $extupdate = true File.exist?(makefile) rescue SystemExit # ignore @@ -100,6 +101,19 @@ def extmake(target) Config::CONFIG["srcdir"] = $top_srcdir end else + if $static + m = File.read(makefile) + $preload = Shellwords.shellwords(m[/^preload[ \t]*=[ \t]*(.*)/, 1] || "") + $DLDFLAGS += " " + (m[/^DLDFLAGS[ \t]*=[ \t]*(.*)/, 1] || "") + if s = m[/^LIBS[ \t]*=[ \t]*(.*)/, 1] + s.sub!(/^#{Regexp.quote($LIBRUBYARG)} */, "") + s.sub!(/ *#{Regexp.quote($LIBS)}$/, "") + $libs = s + end + $LOCAL_LIBS = m[/^LOCAL_LIBS[ \t]*=[ \t]*(.*)/, 1] || "" + $LIBPATH = Shellwords.shellwords(m[/^libpath[ \t]*=[ \t]*(.*)/, 1] || "") - + %w[$(libdir) $(topdir)] + end true end else @@ -124,8 +138,7 @@ def extmake(target) $extlibs ||= [] $extpath ||= [] unless $mswin - $extflags += " " + $DLDFLAGS unless $DLDFLAGS.empty? - $extflags += " " + $LDFLAGS unless $LDFLAGS.empty? + $extflags = ($extflags.split | $DLDFLAGS.split | $LDFLAGS.split).join(" ") end $extlibs = merge_libs($extlibs, $libs.split, $LOCAL_LIBS.split) $extpath |= $LIBPATH @@ -180,7 +193,12 @@ def parse_args() opts.on('--message [MESSAGE]', String) do |v| $message = v end - opts.parse! + begin + opts.parse! + rescue OptionParser::InvalidOption => e + retry if /^--/ =~ e.args[0] + raise + end end or abort opts.to_s $destdir ||= '' @@ -334,7 +352,7 @@ if $extlist.size > 0 list = $extlist.dup while e = list.shift s,t,i,r = e - if r + if r and !r.empty? l = list.size if (while l > 0; break true if r.include?(list[l-=1][1]) end) list.insert(l + 1, e) @@ -375,11 +393,13 @@ SRC end rubies = [] %w[RUBY RUBYW].each {|r| - config_string(r+"_INSTALL_NAME") {|r| rubies << r+EXEEXT} + if r = arg_config("--"+r.downcase) || config_string(r+"_INSTALL_NAME") + rubies << r+EXEEXT + end } Dir.chdir ".." -if $extlist.size > 0 +if !$extlist.empty? and $extupdate rm_f(Config::CONFIG["LIBRUBY_SO"]) end puts "making #{rubies.join(', ')}" diff --git a/lib/mkmf.rb b/lib/mkmf.rb index be6062829b..8dbd064930 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -803,7 +803,7 @@ def dummy_makefile(srcdir) CLEANFILES = #{$cleanfiles.join(' ')} DISTCLEANFILES = #{$distcleanfiles.join(' ')} -all install install-so install-rb: Makefile +all install static install-so install-rb: Makefile RULES end @@ -868,6 +868,8 @@ def create_makefile(target, srcprefix = nil) mfile = open("Makefile", "wb") mfile.print configuration(srcdir) mfile.print %{ +preload = #{$preload.join(" ") if $preload} +libpath = #{$LIBPATH.join(" ")} LIBPATH = #{libpath} DEFFILE = #{deffile} @@ -915,9 +917,9 @@ static: $(STATIC_LIB) mfile.print CLEANINGS dirs = [] mfile.print "install: install-so install-rb\n\n" - if not $static and target - dirs << (dir = "$(RUBYARCHDIR)") - mfile.print("install-so: #{dir}\n") + dirs << (dir = "$(RUBYARCHDIR)") + mfile.print("install-so: #{dir}\n") + if target f = "$(DLLIB)" dest = "#{dir}/#{f}" mfile.print "install-so: #{dest}\n"