summaryrefslogtreecommitdiff
path: root/devel/ruby-zookeeper/patches/patch-ext_extconf.rb
blob: 632459ba42d8573ac59ec38b93af1565960a90fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
$NetBSD: patch-ext_extconf.rb,v 1.1 2016/01/08 12:53:11 fhajny Exp $

Link pkgsrc libzookeeper instead of the embedded build.

--- ext/extconf.rb.orig	2016-01-08 12:43:23.823917320 +0000
+++ ext/extconf.rb
@@ -2,96 +2,10 @@ require 'mkmf'
 require 'rbconfig'
 require 'fileutils'
 
-HERE = File.expand_path(File.dirname(__FILE__))
-BUNDLE = Dir.glob("zkc-*.tar.gz").sort.last
-ZKC_VERSION = BUNDLE[/(zkc-.*?)\.tar.gz$/, 1]
-PATCHES = Dir.glob("patches/#{ZKC_VERSION}*.patch")
-
-BUNDLE_PATH = File.join(HERE, ZKC_VERSION, 'c')
-
-$EXTRA_CONF = ''
-
-# CLANG!!!! jeez, if apple would only *stop* "thinking different"
-if cc = RbConfig::CONFIG['CC'] && cc =~ /^gcc/
-  $CC = cc
-  $EXTRA_CONF = "#{$EXTRA_CONF} CC=#{$CC}"
-end
-
-$CFLAGS = "#{$CFLAGS}".gsub("$(cflags)", "").gsub("-arch ppc", "")
-$LDFLAGS = "#{$LDFLAGS}".gsub("$(ldflags)", "").gsub("-arch ppc", "")
-$CXXFLAGS = " -std=gnu++98 #{$CFLAGS}"
-$CPPFLAGS = $ARCH_FLAG = ""
-
-if RUBY_VERSION == '1.8.7'
-  $CFLAGS << ' -DZKRB_RUBY_187'
-end
-
-ZK_DEBUG = (ENV['DEBUG'] or ARGV.any? { |arg| arg == '--debug' })
 ZK_DEV = ENV['ZK_DEV']
-DEBUG_CFLAGS = " -O0 -ggdb3 -DHAVE_DEBUG -fstack-protector-all"
-
-if ZK_DEBUG
-  $stderr.puts "*** Setting debug flags. ***"
-  $EXTRA_CONF = "#{$EXTRA_CONF} --enable-debug"
-  $CFLAGS.gsub!(/ -O[^0] /, ' ')
-  $CFLAGS << DEBUG_CFLAGS
-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 clobber' in ext/ first if you need to rebuild."
-  else
-    puts "Building zkc."
-
-    unless File.exists?('c')
-      safe_sh "tar xzf #{BUNDLE} 2>&1"
-      PATCHES.each do |patch|
-        safe_sh "patch -p0 < #{patch} 2>&1"
-      end
-    end
-
-    # clean up stupid apple rsrc fork bullshit
-    FileUtils.rm_f(Dir['**/._*'].select{|p| test(?f, p)})
-
-    Dir.chdir(BUNDLE_PATH) do
-      configure = "./configure --prefix=#{HERE} --with-pic --without-cppunit --disable-dependency-tracking #{$EXTRA_CONF} 2>&1"
-      configure = "env CFLAGS='#{DEBUG_CFLAGS}' #{configure}" if ZK_DEBUG
-
-      safe_sh(configure)
-      safe_sh("make  2>&1")
-      safe_sh("make install 2>&1")
-    end
-
-    system("rm -rf #{BUNDLE_PATH}") unless ZK_DEBUG or ZK_DEV
-  end
-end
-
-# Absolutely prevent the linker from picking up any other zookeeper_mt
-Dir.chdir("#{HERE}/lib") do
-  %w[st mt].each do |stmt|
-    %w[a la].each do |ext|
-      system("cp -f libzookeeper_#{stmt}.#{ext} libzookeeper_#{stmt}_gem.#{ext}")
-    end
-  end
-end
-
-# -lm must come after lzookeeper_st_gem to ensure proper link
-$LIBS << " -lzookeeper_st_gem -lm"
+build_root = ENV['PREFIX']
+ldflags = ENV['LDFLAGS']
+$LIBS << " -lzookeeper_st #{ldflags} -lm"
 
 have_func('rb_thread_blocking_region')
 have_func('rb_thread_fd_select')