File: extconf.rb

package info (click to toggle)
ruby2.1 2.1.5-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 59,972 kB
  • sloc: ruby: 625,579; ansic: 295,220; xml: 25,445; yacc: 9,155; lisp: 2,433; tcl: 949; makefile: 535; sh: 402; perl: 62; python: 47; awk: 36; asm: 35; sed: 31
file content (48 lines) | stat: -rw-r--r-- 1,212 bytes parent folder | download | duplicates (2)
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
require 'mkmf'

if RbConfig::CONFIG['GCC'] == 'yes'
  flag = " -fno-defer-pop"
  if have_macro("__clang__")
    $LDFLAGS << flag if try_ldflags(flag)
  else
    $CFLAGS << flag
  end
  $CFLAGS << " -fno-omit-frame-pointer"
end

$INSTALLFILES = [
  ["dl.h", "$(HDRDIR)"],
]

check = true
if( have_header("dlfcn.h") )
  have_library("dl")
  check &&= have_func("dlopen")
  check &&= have_func("dlclose")
  check &&= have_func("dlsym")
  have_func("dlerror")
elsif( have_header("windows.h") )
  check &&= have_func("LoadLibrary")
  check &&= have_func("FreeLibrary")
  check &&= have_func("GetProcAddress")
else
  check = false
end

if check
  config = File.read(RbConfig.expand(File.join($arch_hdrdir, "ruby/config.h")))
  types = {"SIZE_T"=>"SSIZE_T", "PTRDIFF_T"=>nil, "INTPTR_T"=>nil}
  types.each do |type, signed|
    if /^\#define\s+SIZEOF_#{type}\s+(SIZEOF_(.+)|\d+)/ =~ config
      if size = $2 and size != 'VOIDP'
        size = types.fetch(size) {size}
        $defs << format("-DDLTYPE_%s=DLTYPE_%s", signed||type, size)
      end
      if signed
        check_signedness(type.downcase, "stddef.h")
      end
    end
  end
  $defs << %[-DRUBY_VERSION=\\"#{RUBY_VERSION}\\"]
  create_makefile("dl")
end