2010-05-06 02:59:24 -04:00
|
|
|
require 'mkmf'
|
|
|
|
|
|
|
|
# :stopdoc:
|
|
|
|
|
|
|
|
dir_config 'libffi'
|
|
|
|
|
2010-06-15 12:43:46 -04:00
|
|
|
pkg_config("libffi")
|
|
|
|
unless have_header('ffi.h')
|
2010-05-06 02:59:24 -04:00
|
|
|
if have_header('ffi/ffi.h')
|
|
|
|
$defs.push(format('-DUSE_HEADER_HACKS'))
|
|
|
|
else
|
2012-05-18 03:02:25 -04:00
|
|
|
raise "ffi.h is missing. Please install libffi."
|
2010-05-06 02:59:24 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-11-04 11:15:39 -04:00
|
|
|
unless have_library('ffi') || have_library('libffi')
|
2012-05-18 03:02:25 -04:00
|
|
|
raise "libffi is missing. Please install libffi."
|
2010-05-06 02:59:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
have_header 'sys/mman.h'
|
|
|
|
|
2012-11-27 14:54:50 -05:00
|
|
|
if have_header "dlfcn.h"
|
|
|
|
have_library "dl"
|
|
|
|
|
|
|
|
%w{ dlopen dlclose dlsym }.each do |func|
|
|
|
|
abort "missing function #{func}" unless have_func(func)
|
|
|
|
end
|
|
|
|
|
|
|
|
have_func "dlerror"
|
|
|
|
elsif have_header "windows.h"
|
|
|
|
%w{ LoadLibrary FreeLibrary GetProcAddress }.each do |func|
|
|
|
|
abort "missing function #{func}" unless have_func(func)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-30 10:57:21 -05:00
|
|
|
have_const('FFI_STDCALL', 'ffi.h') || have_const('FFI_STDCALL', 'ffi/ffi.h')
|
|
|
|
|
2012-02-25 00:47:16 -05:00
|
|
|
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("-DTYPE_%s=TYPE_%s", signed||type, size)
|
|
|
|
end
|
|
|
|
if signed
|
|
|
|
check_signedness(type.downcase, "stddef.h")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-05-06 02:59:24 -04:00
|
|
|
create_makefile 'fiddle'
|
|
|
|
|
|
|
|
# :startdoc:
|