Top Level Namespace

Defined Under Namespace

Modules: LevelDB

Instance Method Summary collapse

Instance Method Details

#add_define(name) ⇒ Object

[View source]

15
# File 'ext/leveldb/platform.rb', line 15

def add_define name; $defs.push "-D#{name}" end

#check_heads(heads = [], fatal = false) ⇒ Object

[View source]

11
12
13
# File 'ext/leveldb/platform.rb', line 11

def check_heads heads=[], fatal=false
  heads.all? { |head| have_header(head) || (abort("could not find header: #{head}") if fatal)}
end

#check_libs(libs = [], fatal = false) ⇒ Object

here lies some platform-specific C++ compile and link environment variable hacking.

this code is entirely stolen from eventmachine’s extconf.rb. many thanks to @tmm1 for the pointer.

[View source]

7
8
9
# File 'ext/leveldb/platform.rb', line 7

def check_libs libs=[], fatal=false
  libs.all? { |lib| have_library(lib) || (abort("could not find library: #{lib}") if fatal) }
end

#set_platform_specific_variables!Object

[View source]

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
# File 'ext/leveldb/platform.rb', line 17

def set_platform_specific_variables!
  puts "setting build environment for #{RUBY_PLATFORM}..."
  case RUBY_PLATFORM
  when /mswin32/, /mingw32/, /bccwin32/
    check_heads(%w[windows.h winsock.h], true)
    check_libs(%w[kernel32 rpcrt4 gdi32], true)

    if GNU_CHAIN
      CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++"
    else
      $defs.push "-EHs"
      $defs.push "-GR"
    end

  when /solaris/
    add_define 'OS_SOLARIS8'
    check_libs(%w[nsl socket], true)

    if CONFIG['CC'] == 'cc' and `cc -flags 2>&1` =~ /Sun/ # detect SUNWspro compiler
      # SUN CHAIN
      add_define 'CC_SUNWspro'
      $preload = ["\nCXX = CC"] # hack a CXX= line into the makefile
      $CFLAGS = CONFIG['CFLAGS'] = "-KPIC"
      CONFIG['CCDLFLAGS'] = "-KPIC"
      CONFIG['LDSHARED'] = "$(CXX) -G -KPIC -lCstd"
    else
      # GNU CHAIN
      # on Unix we need a g++ link, not gcc.
      CONFIG['LDSHARED'] = "$(CXX) -shared"
    end

  when /openbsd/
    # OpenBSD branch contributed by Guillaume Sellier.

    # on Unix we need a g++ link, not gcc. On OpenBSD, linking against libstdc++ have to be explicitly done for shared libs
    CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++ -fPIC"
    CONFIG['LDSHAREDXX'] = "$(CXX) -shared -lstdc++ -fPIC"

  when /darwin/
    # on Unix we need a g++ link, not gcc.
    # Ff line contributed by Daniel Harple.
    CONFIG['LDSHARED'] = "$(CXX) " + CONFIG['LDSHARED'].split[1..-1].join(' ')

  when /linux/
    add_define 'HAVE_EPOLL' if have_func('epoll_create', 'sys/epoll.h')

    # on Unix we need a g++ link, not gcc.
    CONFIG['LDSHARED'] = "$(CXX) -shared"

  when /aix/
    CONFIG['LDSHARED'] = "$(CXX) -shared -Wl,-G -Wl,-brtl"

  when /cygwin/
    # For rubies built with Cygwin, CXX may be set to CC, which is just
    # a wrapper for gcc.
    # This will compile, but it will not link to the C++ std library.
    # Explicitly set CXX to use g++.
    CONFIG['CXX'] = "g++"
    # on Unix we need a g++ link, not gcc.
    CONFIG['LDSHARED'] = "$(CXX) -shared"

  else
    # on Unix we need a g++ link, not gcc.
    CONFIG['LDSHARED'] = "$(CXX) -shared"
  end
end