def self.portability_cflags
flags = ["-D_REENTRANT -I/usr/local/include"]
hash_namespace = nil
ok = false
['__gnu_cxx', '', 'std', 'stdext'].each do |namespace|
['ext/hash_map', 'hash_map'].each do |hash_map_header|
ok = try_compile(:cxx, %Q{
#include <#{hash_map_header}>
int
main() {
#{namespace}::hash_map<int, int> m;
return 0;
}
})
if ok
hash_namespace = namespace
flags << "-DHASH_NAMESPACE=\"#{namespace}\""
end
end
break if ok
end
['ext/hash_fun.h', 'functional', 'tr1/functional',
'ext/stl_hash_fun.h', 'hash_fun.h', 'stl_hash_fun.h',
'stl/_hash_fun.h'].each do |hash_function_header|
ok = try_compile(:cxx, %Q{
#include <#{hash_function_header}>
int
main() {
#{hash_namespace}::hash<int>()(5);
return 0;
}
})
if ok
flags << "-DHASH_FUN_H=\"<#{hash_function_header}>\""
break
end
end
if RUBY_PLATFORM =~ /solaris/
flags << '-pthreads'
if RUBY_PLATFORM =~ /solaris2.11/
flags << '-D__EXTENSIONS__ -D__SOLARIS__ -D_FILE_OFFSET_BITS=64'
else
flags << '-D_XOPEN_SOURCE=500 -D_XPG4_2 -D__EXTENSIONS__ -D__SOLARIS__ -D_FILE_OFFSET_BITS=64'
flags << '-D__SOLARIS9__ -DBOOST__STDC_CONSTANT_MACROS_DEFINED' if RUBY_PLATFORM =~ /solaris2.9/
end
flags << '-D_XOPEN_SOURCE=500 -D_XPG4_2 -D__EXTENSIONS__ -D__SOLARIS__ -D_FILE_OFFSET_BITS=64'
flags << '-DBOOST_HAS_STDINT_H' unless RUBY_PLATFORM =~ /solaris2.9/
flags << '-mcpu=ultrasparc' if RUBY_PLATFORM =~ /sparc/
elsif RUBY_PLATFORM =~ /openbsd/
flags << '-DBOOST_HAS_STDINT_H -D_GLIBCPP__PTHREADS'
elsif RUBY_PLATFORM =~ /aix/
flags << '-DOXT_DISABLE_BACKTRACES'
elsif RUBY_PLATFORM =~ /(sparc-linux|arm-linux|^arm.*-linux|sh4-linux)/
flags << '-DBOOST_SP_USE_PTHREADS'
end
flags << '-DHAS_ALLOCA_H' if has_alloca_h?
flags << '-DHAS_SFENCE' if supports_sfence_instruction?
flags << '-DHAS_LFENCE' if supports_lfence_instruction?
return flags.compact.join(" ").strip
end