diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-22 06:35:28 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-22 06:35:28 +0000 |
commit | 21255071d873144d5b0d6bb25b7b17fb20ea5299 (patch) | |
tree | 19a0fd5b3e5433f0bc0d76c688a53726260f71bd /ext | |
parent | 958c04898c01620d7b1f9f04aa888a4a5ac5aec8 (diff) |
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
Diffstat (limited to 'ext')
-rw-r--r-- | ext/zlib/extconf.rb | 34 |
1 files changed, 33 insertions, 1 deletions
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 |