diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/mkmf.rb | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 68b324a82..a0e01c47c 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -204,14 +204,6 @@ def try_compile(src, opt="") end end -def macro_defined?(macro, src, opt="") - try_cpp(src + <<EOP, opt) -#ifndef #{macro} -# error -#endif -EOP -end - def try_cpp(src, opt="") cfile = open("conftest.c", "w") cfile.print src @@ -252,6 +244,14 @@ def egrep_cpp(pat, src, opt="") end end +def macro_defined?(macro, src, opt="") + try_cpp(src + <<EOP, opt) +#ifndef #{macro} +# error +#endif +EOP +end + def try_run(src, opt="") begin if try_link0(src, opt) @@ -439,6 +439,40 @@ SRC return true end +def have_struct_member(type, member, header=nil) + message "checking for #{type}.#{member}... " + + src = + if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM + r = <<"SRC" +#include <windows.h> +#include <winsock.h> +SRC + else + "" + end + unless header.nil? + header = [header] unless header.kind_of? Array + header.each {|h| + src << <<"SRC" +#include <#{h}> +SRC + } + end + src << <<"SRC" +int main() { return 0; } +int s = (char *)&((#{type}*)0)->#{member} - (char *)0; +SRC + r = try_compile(src) + unless r + message "no\n" + return false + end + $defs.push(format("-DHAVE_ST_%s", member.upcase)) + message "yes\n" + return true +end + def find_executable(bin, path = nil) message "checking for #{bin}... " |
