diff options
Diffstat (limited to 'ext/zlib/extconf.rb')
| -rw-r--r-- | ext/zlib/extconf.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb index fd2f168522..2b2dbb1a5b 100644 --- a/ext/zlib/extconf.rb +++ b/ext/zlib/extconf.rb @@ -10,11 +10,11 @@ require 'rbconfig' dir_config 'zlib' +libs = $libs +have_zlib = %w'z libz zlib1 zlib zdll zlibwapi'.any? {|z| have_library(z, 'deflateReset(NULL)', 'zlib.h')} -if %w'z libz zlib1 zlib zdll zlibwapi'.find {|z| have_library(z, 'deflateReset')} and - have_header('zlib.h') then - have_zlib = true -else +unless have_zlib + $libs = libs unless File.directory?(zsrc = "#{$srcdir}/zlib") dirs = Dir.open($srcdir) {|z| z.grep(/\Azlib-\d+[.\d]*\z/) {|x|"#{$srcdir}/#{x}"}} dirs.delete_if {|x| !File.directory?(x)} @@ -31,9 +31,12 @@ else $extso << dll $cleanfiles << "$(topdir)/#{dll}" << "$(ZIMPLIB)" zmk = "\t$(MAKE) -f $(ZMKFILE) TOP=$(ZSRC)" + zopts = [] if $nmake zmkfile = "$(ZSRC)/win32/Makefile.msc" m = "#{zsrc}/win32/Makefile.msc" + # zopts << "USE_ASM=1" + zopts << "ARCH=#{RbConfig::CONFIG['target_cpu']}" else zmkfile = "$(ZSRC)/win32/Makefile.gcc" m = "#{zsrc}/win32/Makefile.gcc" @@ -43,7 +46,7 @@ else end m = File.read(m) zimplib = m[/^IMPLIB[ \t]*=[ \t]*(\S+)/, 1] - $LOCAL_LIBS << " " << zimplib + ($LOCAL_LIBS << " ./" << zimplib).strip! unless $nmake or /^TOP[ \t]/ =~ m m.gsub!(/win32\/zlib\.def/, '$(TOP)/\&') m.gsub!(/^(\t.*[ \t])(\S+\.rc)/, '\1-I$(<D) $<') @@ -55,10 +58,11 @@ else addconf.push( "ZMKFILE = #{zmkfile}\n", "ZIMPLIB = #{zimplib}\n", + "ZOPTS = #{zopts.join(' ')}\n", "$(TARGET_SO): $(ZIMPLIB)\n", "$(ZIMPLIB):\n", - "#{zmk} $@\n", - "install-so: $(topdir)/#{dll}", + "#{zmk} $(ZOPTS) $@\n", + "install-so static: $(topdir)/#{dll}", "$(topdir)/#{dll}: $(ZIMPLIB)\n", "\t$(Q) $(COPY) #{dll} $(@D)\n", "clean: clean-zsrc\n", @@ -116,10 +120,18 @@ if have_zlib $defs << "-DHAVE_CRC32_COMBINE" $defs << "-DHAVE_ADLER32_COMBINE" $defs << "-DHAVE_TYPE_Z_CRC_T" + $defs << "-DHAVE_CRC32_Z" + $defs << "-DHAVE_ADLER32_Z" + $defs << "-DHAVE_ZLIB_SIZE_T_FUNCS" else have_func('crc32_combine', 'zlib.h') have_func('adler32_combine', 'zlib.h') have_type('z_crc_t', 'zlib.h') + if (have_type('z_size_t', 'zlib.h') && + have_func('crc32_z', 'zlib.h') && + have_func('adler32_z', 'zlib.h')) + $defs << "-DHAVE_ZLIB_SIZE_T_FUNCS" + end end create_makefile('zlib') {|conf| |
