Top Level Namespace

Defined Under Namespace

Modules: Curl

Instance Method Summary collapse

Instance Method Details

#define(s, v = 1) ⇒ Object

Check arch flags TODO: detect mismatched arch types when libcurl mac ports is mixed with native mac ruby or vice versa archs = $CFLAGS.scan(/-archs(.*?)s/).first # get the first arch flag if archs and archs.size >= 1

# need to reduce the number of archs...
# guess the first one is correct... at least the first one is probably the ruby installed arch...
# this could lead to compiled binaries that crash at runtime...
$CFLAGS.gsub!(/-arch\s(.*?)\s/,' ')
$CFLAGS << " -arch #{archs.first}"
puts "Selected arch: #{archs.first}"

end


40
41
42
# File 'ext/extconf.rb', line 40

def define(s, v=1)
  $defs.push( format("-D HAVE_%s=%d", s.to_s.upcase, v) )
end

#have_constant(name) ⇒ Object


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'ext/extconf.rb', line 44

def have_constant(name)
  sname = name.is_a?(Symbol) ? name.to_s : name.upcase
  checking_for name do
    src = %{
      #include <curl/curl.h>
      int main() {
        int test = (int)#{sname};
        return 0;
      }
    }
    if try_compile(src,"#{$CFLAGS} #{$LIBS}")
      define name
      true
    else
      #define name, 0
      false
    end
  end
end

#test_for(name, const, src) ⇒ Object

do some checking to detect ruby 1.8 hash.c vs ruby 1.9 hash.c


446
447
448
449
450
451
452
453
454
455
# File 'ext/extconf.rb', line 446

def test_for(name, const, src)
  checking_for name do
    if try_compile(src,"#{$CFLAGS} #{$LIBS}")
      define const
      true
    else
      false
    end
  end
end