* ext/zlib/extconf.rb: fix building zlib for mingw, and for
  cross-compiling.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-03-03 09:27:27 +00:00
Родитель bf5b0c4956
Коммит d2e61b41f5
1 изменённых файлов: 24 добавлений и 3 удалений

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

@ -27,13 +27,34 @@ else
]
$INCFLAGS << " -I$(ZSRC)"
if $mswin or $mingw
$libs = append_library($libs, "zdll")
dll = "zlib1.dll"
$extso << dll
$cleanfiles << "$(topdir)/#{dll}" << "$(ZIMPLIB)"
zmk = "\t$(MAKE) -f $(ZSRC)/win32/Makefile.#{$nmake ? 'msc' : 'gcc'} TOP=$(ZSRC)"
zmk = "\t$(MAKE) -f $(ZMKFILE) TOP=$(ZSRC)"
if $nmake
zmkfile = "$(ZSRC)/win32/Makefile.msc"
m = "#{zsrc}/win32/Makefile.msc"
else
zmkfile = "$(ZSRC)/win32/Makefile.gcc"
m = "#{zsrc}/win32/Makefile.gcc"
zmk += " PREFIX="
zmk << CONFIG['CC'][/(.*-)gcc([^\/]*)\z/, 1]
zmk << " CC=$(CC)" if $2
end
m = File.read(m)
zimplib = m[/^IMPLIB[ \t]*=[ \t]*(\S+)/, 1]
$LOCAL_LIBS << " " << zimplib
unless $nmake or /^TOP[ \t]/ =~ m
m.gsub!(/win32\/zlib\.def/, '$(TOP)/\&')
m.gsub!(/^(\t.*[ \t])(\S+\.rc)/, '\1-I$(<D) $<')
m = "TOP = .\n""VPATH=$(TOP)\n" + m
zmkfile = File.basename(zmkfile)
File.rename(zmkfile, zmkfile+".orig") if File.exist?(zmkfile)
File.write(zmkfile, m)
end
addconf.push(
"ZIMPLIB = zdll.lib\n",
"ZMKFILE = #{zmkfile}\n",
"ZIMPLIB = #{zimplib}\n",
"$(TARGET_SO): $(ZIMPLIB)\n",
"$(ZIMPLIB):\n",
"#{zmk} $@\n",