Sha256: 10f18969d0ab14869cce267d972711d5889278044d06dec957ec1db4faa24600

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

require 'mkmf'
require 'rbconfig'

HERE = File.expand_path(File.dirname(__FILE__))
BUNDLE = Dir.glob("zkc-*.tar.gz").first
BUNDLE_PATH = "c"

$CFLAGS = "#{RbConfig::CONFIG['CFLAGS']} #{$CFLAGS}".gsub("$(cflags)", "").gsub("-arch ppc", "")
$LDFLAGS = "#{RbConfig::CONFIG['LDFLAGS']} #{$LDFLAGS}".gsub("$(ldflags)", "").gsub("-arch ppc", "")
$CXXFLAGS = " -std=gnu++98 #{$CFLAGS}"
$CPPFLAGS = $ARCH_FLAG = $DLDFLAGS = ""


if ENV['DEBUG']
  $stderr.puts "*** Setting debug flags. ***"
  $CFLAGS << " -O0 -ggdb3 -DHAVE_DEBUG"
  $EXTRA_CONF = " --enable-debug"
  $CFLAGS.gsub!(/ -O[^0] /, ' ')
end

$includes = " -I#{HERE}/include"
$libraries = " -L#{HERE}/lib -L#{RbConfig::CONFIG['libdir']}"
$CFLAGS = "#{$includes} #{$libraries} #{$CFLAGS}"
$LDFLAGS = "#{$libraries} #{$LDFLAGS}"
$LIBPATH = ["#{HERE}/lib"]
$DEFLIBPATH = []

def safe_sh(cmd)
  puts cmd
  system(cmd)
  unless $?.exited? and $?.success?
    raise "command failed! #{cmd}"
  end
end

Dir.chdir(HERE) do
  if File.exist?("lib")
    puts "Zkc already built; run 'rake clean' first if you need to rebuild."
  else
    puts "Building zkc."

    unless File.exists?('c')
      puts(cmd = "tar xzf #{BUNDLE} 2>&1")
      raise "'#{cmd}' failed" unless system(cmd)
    end

    Dir.chdir(BUNDLE_PATH) do        
      safe_sh("./configure --prefix=#{HERE} --with-pic --without-cppunit --disable-dependency-tracking #{$EXTRA_CONF} 2>&1")
      safe_sh("make  2>&1")
      safe_sh("make install 2>&1")
    end

    system("rm -rf #{BUNDLE_PATH}") unless ENV['DEBUG'] or ENV['DEV']
  end
end

# Absolutely prevent the linker from picking up any other zookeeper_mt
Dir.chdir("#{HERE}/lib") do
  system("cp -f libzookeeper_mt.a libzookeeper_mt_gem.a") 
  system("cp -f libzookeeper_mt.la libzookeeper_mt_gem.la") 
end
$LIBS << " -lzookeeper_mt_gem"

create_makefile 'zookeeper_c'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slyphon-zookeeper-0.2.5 ext/extconf.rb
slyphon-zookeeper-0.2.5-java ext/extconf.rb