Skip to content

Commit

Permalink
Added --with[out]-vendor-zlib to configure.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Jun 16, 2011
1 parent 122aa46 commit 4a8b9a4
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 23 deletions.
18 changes: 18 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class Configure

# Library configuration
@rb_readline = false
@vendor_zlib = true

# Essential settings (modify these for creating releases)
@libversion = "2.0"
Expand Down Expand Up @@ -314,6 +315,7 @@ class Configure
feature "execinfo", default_on
feature "C-readline", true
feature "ruby-readline", false
feature "vendor-zlib", true

o.doc "\n Help!"

Expand Down Expand Up @@ -852,6 +854,8 @@ int main() { return tgetnum(""); }
if @features["ruby-readline"] or !@defines.include?("HAS_READLINE")
@rb_readline = true
end

@vendor_zlib = false unless @features["vendor-zlib"]
end

def process
Expand Down Expand Up @@ -963,6 +967,7 @@ module Rubinius
:bsd => #{@bsd},
:linux => #{@linux},
:version_list => #{@version_list.inspect},
:vendor_zlib => #{@vendor_zlib},
}
end
EOC
Expand Down Expand Up @@ -998,6 +1003,12 @@ end
#define RBX_LLVM_API_VER #{@llvm_api_version}
EOC

if @vendor_zlib
f.puts %[#define RBX_ZLIB_PATH "#{@lib_path}/zlib/"]
else
f.puts %[#define RBX_ZLIB_PATH ""]
end

@supported_versions.each do |ver|
f.puts "#define RBX_DEFAULT_#{ver} #{ver == @default_version}"
end
Expand Down Expand Up @@ -1044,8 +1055,15 @@ end
#define RBX_RELEASE_DATE "#{@release_date}"
#define RBX_SIZEOF_LONG #{@sizeof_long}
#define RBX_LLVM_API_VER #{@llvm_api_version}
EOC

if @vendor_zlib
f.puts %[#define RBX_ZLIB_PATH "#{@lib_path}/zlib/"]
else
f.puts %[#define RBX_ZLIB_PATH ""]
end

if @little_endian
f.puts "#define RBX_LITTLE_ENDIAN 1"
end
Expand Down
5 changes: 3 additions & 2 deletions lib/zlib.rb.ffi
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,9 @@ module Zlib

extend FFI::Library

path = File.expand_path("../zlib", __FILE__)
ffi_lib ["#{path}/libz.so.1", "#{path}/libz.1.dylib", "#{path}/libz"]
ffi_lib %W[ #{Rubinius::ZLIB_PATH}libz.so.1
#{Rubinius::ZLIB_PATH}libz.1.dylib
#{Rubinius::ZLIB_PATH}libz ]

# deflateInit2 is a macro pointing to deflateInit2_
attach_function :deflateInit2_, [
Expand Down
28 changes: 15 additions & 13 deletions rakelib/blueprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,25 @@
end
end

zlib = i.external_lib "vm/external_libs/zlib" do |l|
l.cflags = ["-Ivm/external_libs/zlib"]
l.objects = []
l.to_build do |x|
unless File.exists?("Makefile") and File.exists?("zconf.h")
x.command "sh -c ./configure"
end
if Rubinius::BUILD_CONFIG[:vendor_zlib]
zlib = i.external_lib "vm/external_libs/zlib" do |l|
l.cflags = ["-Ivm/external_libs/zlib"]
l.objects = []
l.to_build do |x|
unless File.exists?("Makefile") and File.exists?("zconf.h")
x.command "sh -c ./configure"
end

if Rubinius::BUILD_CONFIG[:windows]
x.command "make -f win32/Makefile.gcc"
else
x.command make
if Rubinius::BUILD_CONFIG[:windows]
x.command "make -f win32/Makefile.gcc"
else
x.command make
end
end
end
end

gcc.add_library zlib
gcc.add_library zlib if Rubinius::BUILD_CONFIG[:vendor_zlib]
gcc.add_library udis
gcc.add_library ffi
gcc.add_library gdtoa
Expand All @@ -208,7 +210,7 @@
files << winp
end

files << zlib
files << zlib if Rubinius::BUILD_CONFIG[:vendor_zlib]
files << udis
files << ffi
files << gdtoa
Expand Down
8 changes: 5 additions & 3 deletions rakelib/install.rake
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ namespace :install do
install_file name, /^lib/, BUILD_CONFIG[:lib_path]
end

# Install the zlib library files
FileList["lib/zlib/*"].each do |name|
install_file name, /^lib/, BUILD_CONFIG[:lib_path]
if Rubinius::BUILD_CONFIG[:vendor_zlib]
# Install the zlib library files
FileList["lib/zlib/*"].each do |name|
install_file name, /^lib/, BUILD_CONFIG[:lib_path]
end
end

# Install the documentation site
Expand Down
15 changes: 10 additions & 5 deletions rakelib/vm.rake
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,16 @@ namespace :build do

end

directory 'lib/zlib'
if Rubinius::BUILD_CONFIG[:vendor_zlib]
directory 'lib/zlib'

task :zlib => ['lib/zlib', VM_EXE] do
FileList["vm/external_libs/zlib/libz.*"].each do |lib|
cp lib, 'lib/zlib/'
task :zlib => ['lib/zlib', VM_EXE] do
FileList["vm/external_libs/zlib/libz.*"].each do |lib|
cp lib, 'lib/zlib/'
end
end
else
task :zlib
end
end

Expand Down Expand Up @@ -311,7 +315,8 @@ namespace :vm do
'vm/test/runner.o',
VM_EXE,
'vm/.deps',
'lib/zlib/*'
'lib/zlib/*',
'lib/zlib'
].exclude("vm/gen/config.h")

files.each do |filename|
Expand Down
1 change: 1 addition & 0 deletions vm/ontology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ namespace rubinius {
G(rubinius)->set_const(state, "GEMS_PATH", String::create(state, RBX_GEMS_PATH));
G(rubinius)->set_const(state, "SITE_PATH", String::create(state, RBX_SITE_PATH));
G(rubinius)->set_const(state, "VENDOR_PATH", String::create(state, RBX_VENDOR_PATH));
G(rubinius)->set_const(state, "ZLIB_PATH", String::create(state, RBX_ZLIB_PATH));

G(rubinius)->set_const(state, "VERSION", String::create(state, RBX_VERSION));
G(rubinius)->set_const(state, "LIB_VERSION", String::create(state, RBX_LIB_VERSION));
Expand Down

0 comments on commit 4a8b9a4

Please sign in to comment.