From 21255071d873144d5b0d6bb25b7b17fb20ea5299 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 22 Sep 2016 06:35:28 +0000 Subject: zlib: try zlib source * ext/zlib/extconf.rb: try building zlib from the source if exists. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/zlib/extconf.rb | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'ext/zlib') diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb index 8bbede63b2..71bcc577d1 100644 --- a/ext/zlib/extconf.rb +++ b/ext/zlib/extconf.rb @@ -13,7 +13,24 @@ dir_config 'zlib' 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 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)} + zsrc = dirs.max_by {|x| x.scan(/\d+/).map(&:to_i)} + end + if zsrc + $INCFLAGS << " -I$(ZSRC)" + if $mswin or $mingw + $libs = append_library($libs, "zdll") + dll = "zlib1.dll" + end + have_zlib = true + end +end +if have_zlib defines = [] Logging::message 'checking for kind of operating system... ' @@ -57,6 +74,21 @@ if %w'z libz zlib1 zlib zdll zlibwapi'.find {|z| have_library(z, 'deflateReset') have_func('adler32_combine', 'zlib.h') have_type('z_crc_t', 'zlib.h') - create_makefile('zlib') + create_makefile('zlib') {|conf| + if zsrc + conf << "ZSRC = $(srcdir)/#{File.basename(zsrc)}\n" + conf << "all:\n" + if $mingw or $mswin + conf << "ZIMPLIB = zdll.lib\n" + conf << "$(TARGET_SO): $(ZIMPLIB)\n" + conf << "$(ZIMPLIB):\n" + conf << "\t$(MAKE) -f $(ZSRC)/win32/Makefile.#{$nmake ? 'msc' : 'gcc'} TOP=$(ZSRC) $@\n" + conf << "install-so: $(topdir)/#{dll}" + conf << "$(topdir)/#{dll}: $(ZIMPLIB)\n" + conf << "\t$(Q) $(COPY) #{dll} $(BINDIR)\n" + end + end + conf + } end -- cgit v1.2.3