summaryrefslogtreecommitdiff
path: root/ext/zlib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-03 09:27:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-03 09:27:27 +0000
commitd2e61b41f50ef1688dac98f6c48dd44c80ac5c6e (patch)
tree0ca641ea1346d25c9d9f5475773a59692da8b362 /ext/zlib
parentbf5b0c4956ec89904fcbc952b1145a5190e5cc11 (diff)
zlib for mingw
* 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
Diffstat (limited to 'ext/zlib')
-rw-r--r--ext/zlib/extconf.rb27
1 files changed, 24 insertions, 3 deletions
diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb
index d3aa1b2..fd2f168 100644
--- a/ext/zlib/extconf.rb
+++ b/ext/zlib/extconf.rb
@@ -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",