* ext/extmk.rb (extmake): remove extinit files if no statically linked

extensions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2006-05-27 02:30:10 +00:00
parent 3449f576f4
commit 2ad6b5a887
3 changed files with 20 additions and 10 deletions

View File

@ -1,3 +1,8 @@
Sat May 27 11:29:46 2006 nobuyoshi nakada <nobu@ruby-lang.org>
* ext/extmk.rb (extmake): remove extinit files if no statically linked
extensions.
Fri May 26 09:05:11 2006 nobuyoshi nakada <nobu@ruby-lang.org> Fri May 26 09:05:11 2006 nobuyoshi nakada <nobu@ruby-lang.org>
* ruby.h, lib/mkmf.rb (create_header): clear command line options for * ruby.h, lib/mkmf.rb (create_header): clear command line options for

View File

@ -70,7 +70,7 @@ def extract_makefile(makefile, keep = true)
end end
$target = target $target = target
$extconf_h = m[/^RUBY_EXTCONF_H[ \t]*=[ \t]*(\S+)/, 1] $extconf_h = m[/^RUBY_EXTCONF_H[ \t]*=[ \t]*(\S+)/, 1]
$static = m[/^EXTSTATIC[ \t]*=[ \t]*(\S+)/, 1] || false $static ||= m[/^EXTSTATIC[ \t]*=[ \t]*(\S+)/, 1] || false
/^STATIC_LIB[ \t]*=[ \t]*\S+/ =~ m or $static = nil /^STATIC_LIB[ \t]*=[ \t]*\S+/ =~ m or $static = nil
$preload = Shellwords.shellwords(m[/^preload[ \t]*=[ \t]*(.*)/, 1] || "") $preload = Shellwords.shellwords(m[/^preload[ \t]*=[ \t]*(.*)/, 1] || "")
$DLDFLAGS += " " + (m[/^DLDFLAGS[ \t]*=[ \t]*(.*)/, 1] || "") $DLDFLAGS += " " + (m[/^DLDFLAGS[ \t]*=[ \t]*(.*)/, 1] || "")
@ -92,7 +92,6 @@ def extmake(target)
else else
$static = false $static = false
end end
$default_static = $static
unless $ignore unless $ignore
return true if $nodynamic and not $static return true if $nodynamic and not $static
@ -131,7 +130,6 @@ def extmake(target)
!(t = modified?(makefile, MTIMES)) || !(t = modified?(makefile, MTIMES)) ||
%W"#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb #{$srcdir}/depend".any? {|f| modified?(f, [t])}) %W"#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb #{$srcdir}/depend".any? {|f| modified?(f, [t])})
then then
$default_static = $static
ok = false ok = false
init_mkmf init_mkmf
Logging::logfile 'mkmf.log' Logging::logfile 'mkmf.log'
@ -404,8 +402,13 @@ end
$hdrdir = $top_srcdir = srcdir $hdrdir = $top_srcdir = srcdir
$topdir = "." $topdir = "."
extinit = Struct.new(:c, :o) {
def initialize(src)
super("#{src}.c", "#{src}.#{$OBJEXT}")
end
}.new("extinit")
if $ignore if $ignore
FileUtils.rm_f(%W"extinit.c extinit.#{$OBJEXT}") if $clean FileUtils.rm_f(extinit.to_a) if $clean
Dir.chdir ".." Dir.chdir ".."
if $clean if $clean
Dir.rmdir('ext') rescue nil Dir.rmdir('ext') rescue nil
@ -436,16 +439,16 @@ if $extlist.size > 0
end end
end end
src = <<SRC src = %{\
extern char *ruby_sourcefile, *rb_source_filename(); extern char *ruby_sourcefile, *rb_source_filename();
#define init(func, name) (ruby_sourcefile = src = rb_source_filename(name), func(), rb_provide(src)) #define init(func, name) (ruby_sourcefile = src = rb_source_filename(name), func(), rb_provide(src))
void Init_ext() {\n\tchar* src;\n#$extinit} void Init_ext() {\n\tchar* src;\n#$extinit}
SRC }
if !modified?("extinit.c", MTIMES) || IO.read("extinit.c") != src if !modified?(extinit.c, MTIMES) || IO.read(extinit.c) != src
open("extinit.c", "w") {|f| f.print src} open(extinit.c, "w") {|f| f.print src}
end end
$extobjs = "ext/extinit.#{$OBJEXT} " + $extobjs $extobjs = "ext/#{extinit.o} " + $extobjs
if RUBY_PLATFORM =~ /m68k-human|beos/ if RUBY_PLATFORM =~ /m68k-human|beos/
$extflags.delete("-L/usr/local/lib") $extflags.delete("-L/usr/local/lib")
end end
@ -461,6 +464,8 @@ SRC
puts conf puts conf
$stdout.flush $stdout.flush
$mflags.concat(conf) $mflags.concat(conf)
else
FileUtils.rm_f(extinit.to_a)
end end
rubies = [] rubies = []
%w[RUBY RUBYW STATIC_RUBY].each {|r| %w[RUBY RUBYW STATIC_RUBY].each {|r|

View File

@ -1101,7 +1101,7 @@ SRCS = #{srcs.collect(&File.method(:basename)).join(' ')}
OBJS = #{$objs} OBJS = #{$objs}
TARGET = #{target} TARGET = #{target}
DLLIB = #{dllib} DLLIB = #{dllib}
EXTSTATIC = #{$default_static != $static && $static || ""} EXTSTATIC = #{$static || ""}
STATIC_LIB = #{staticlib unless $static.nil?} STATIC_LIB = #{staticlib unless $static.nil?}
} }