Top Level Namespace

Defined Under Namespace

Modules: Rlibmemcached Classes: Memcached

Constant Summary collapse

HERE =
ENV['HERE']
BUNDLE_PATH =
Dir.glob("libmemcached-*").first
SOLARIS_32 =
RbConfig::CONFIG['target'] == "i386-pc-solaris2.10"
BSD =
RbConfig::CONFIG['build_os'] =~ /^freebsd|^openbsd/
LIBM_CFLAGS =

JRuby’s default configure options can’t build libmemcached properly

defined?(JRUBY_VERSION) ? "-fPIC -g -O2" : $CFLAGS
LIBM_LDFLAGS =
defined?(JRUBY_VERSION) ? "-fPIC -lsasl2 -lm" : $LDFLAGS
GMAKE_CMD =
RbConfig::CONFIG['host_os'].downcase =~ /bsd|solaris/ ? "gmake" : "make"
TAR_CMD =
SOLARIS_32 ? 'gtar' : 'tar'
PATCH_CMD =
SOLARIS_32 ? 'gpatch' : 'patch'

Instance Method Summary collapse

Instance Method Details

#check_libmemcachedObject



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
# File 'ext/extconf.rb', line 36

def check_libmemcached
  return if ENV["EXTERNAL_LIB"]

  $includes = " -I#{HERE}/include"
  $libraries = " -L#{HERE}/lib"
  $CFLAGS = "#{$includes} #{$libraries} #{$CFLAGS}"
  $LDFLAGS = "-lsasl2 -lm #{$libraries} #{$LDFLAGS}"
  $LIBPATH = ["#{HERE}/lib"]
  $DEFLIBPATH = [] unless SOLARIS_32

  Dir.chdir(HERE) do
    Dir.chdir(BUNDLE_PATH) do
      ts_now=Time.now.strftime("%Y%m%d%H%M.%S")
      run("find . | xargs touch -t #{ts_now}", "Touching all files so autoconf doesn't run.")
      run("env CFLAGS='-fPIC #{LIBM_CFLAGS}' LDFLAGS='-fPIC #{LIBM_LDFLAGS}' ./configure --prefix=#{HERE} --libdir=#{HERE}/lib --without-memcached --disable-shared --disable-utils --disable-dependency-tracking #{$CC} #{$EXTRA_CONF} 2>&1", "Configuring libmemcached.")
    end

    Dir.chdir(BUNDLE_PATH) do
      #Running the make command in another script invoked by another shell command solves the "cd ." issue on FreeBSD 6+
      run("GMAKE_CMD='#{GMAKE_CMD}' CXXFLAGS='#{$CXXFLAGS} #{LIBM_CFLAGS}' SOURCE_DIR='#{BUNDLE_PATH}' HERE='#{HERE}' ruby ../extconf-make.rb", "Making libmemcached.")
    end
  end

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

#run(cmd, reason) ⇒ Object



67
68
69
70
71
# File 'ext/extconf.rb', line 67

def run(cmd, reason)
  puts reason
  puts cmd
  raise "'#{cmd}' failed" unless system(cmd)
end