PageRenderTime 55ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/css-nite-aomori/vendor/bundler/ruby/1.9.1/gems/eventmachine-1.0.3/ext/extconf.rb

https://bitbucket.org/calmtech/wdha-035
Ruby | 177 lines | 119 code | 34 blank | 24 comment | 25 complexity | 89c075f2b9c15548f3dd1522a05d9779 MD5 | raw file
  1. require 'fileutils'
  2. require 'mkmf'
  3. def check_libs libs = [], fatal = false
  4. libs.all? { |lib| have_library(lib) || (abort("could not find library: #{lib}") if fatal) }
  5. end
  6. def check_heads heads = [], fatal = false
  7. heads.all? { |head| have_header(head) || (abort("could not find header: #{head}") if fatal)}
  8. end
  9. def add_define(name)
  10. $defs.push("-D#{name}")
  11. end
  12. ##
  13. # OpenSSL:
  14. # override append_library, so it actually appends (instead of prepending)
  15. # this fixes issues with linking ssl, since libcrypto depends on symbols in libssl
  16. def append_library(libs, lib)
  17. libs + " " + format(LIBARG, lib)
  18. end
  19. def manual_ssl_config
  20. ssl_libs_heads_args = {
  21. :unix => [%w[ssl crypto], %w[openssl/ssl.h openssl/err.h]],
  22. :mswin => [%w[ssleay32 eay32], %w[openssl/ssl.h openssl/err.h]],
  23. }
  24. dc_flags = ['ssl']
  25. dc_flags += ["#{ENV['OPENSSL']}/include", ENV['OPENSSL']] if /linux/ =~ RUBY_PLATFORM and ENV['OPENSSL']
  26. libs, heads = case RUBY_PLATFORM
  27. when /mswin/ ; ssl_libs_heads_args[:mswin]
  28. else ssl_libs_heads_args[:unix]
  29. end
  30. dir_config(*dc_flags)
  31. check_libs(libs) and check_heads(heads)
  32. end
  33. if ENV['CROSS_COMPILING']
  34. openssl_version = ENV.fetch("OPENSSL_VERSION", "1.0.0j")
  35. openssl_dir = File.expand_path("~/.rake-compiler/builds/openssl-#{openssl_version}/")
  36. if File.exists?(openssl_dir)
  37. FileUtils.mkdir_p Dir.pwd+"/openssl/"
  38. FileUtils.cp Dir[openssl_dir+"/include/openssl/*.h"], Dir.pwd+"/openssl/", :verbose => true
  39. FileUtils.cp Dir[openssl_dir+"/lib*.a"], Dir.pwd, :verbose => true
  40. $INCFLAGS << " -I#{Dir.pwd}" # for the openssl headers
  41. else
  42. STDERR.puts
  43. STDERR.puts "**************************************************************************************"
  44. STDERR.puts "**** Cross-compiled OpenSSL not found"
  45. STDERR.puts "**** Run: hg clone http://bitbucket.org/ged/ruby-pg && cd ruby-pg && rake openssl_libs"
  46. STDERR.puts "**************************************************************************************"
  47. STDERR.puts
  48. end
  49. end
  50. # Try to use pkg_config first, fixes #73
  51. if (!ENV['CROSS_COMPILING'] and pkg_config('openssl')) || manual_ssl_config
  52. add_define "WITH_SSL"
  53. else
  54. add_define "WITHOUT_SSL"
  55. end
  56. add_define 'BUILD_FOR_RUBY'
  57. add_define 'HAVE_RBTRAP' if have_var('rb_trap_immediate', ['ruby.h', 'rubysig.h'])
  58. add_define "HAVE_TBR" if have_func('rb_thread_blocking_region')# and have_macro('RUBY_UBF_IO', 'ruby.h')
  59. add_define "HAVE_INOTIFY" if inotify = have_func('inotify_init', 'sys/inotify.h')
  60. add_define "HAVE_OLD_INOTIFY" if !inotify && have_macro('__NR_inotify_init', 'sys/syscall.h')
  61. add_define 'HAVE_WRITEV' if have_func('writev', 'sys/uio.h')
  62. have_func('rb_wait_for_single_fd')
  63. have_func('rb_enable_interrupt')
  64. have_func('rb_time_new')
  65. # Minor platform details between *nix and Windows:
  66. if RUBY_PLATFORM =~ /(mswin|mingw|bccwin)/
  67. GNU_CHAIN = ENV['CROSS_COMPILING'] || $1 == 'mingw'
  68. OS_WIN32 = true
  69. add_define "OS_WIN32"
  70. else
  71. GNU_CHAIN = true
  72. OS_UNIX = true
  73. add_define 'OS_UNIX'
  74. add_define "HAVE_KQUEUE" if have_header("sys/event.h") and have_header("sys/queue.h")
  75. end
  76. # Adjust number of file descriptors (FD) on Windows
  77. if RbConfig::CONFIG["host_os"] =~ /mingw/
  78. found = RbConfig::CONFIG.values_at("CFLAGS", "CPPFLAGS").
  79. any? { |v| v.include?("FD_SETSIZE") }
  80. add_define "FD_SETSIZE=32767" unless found
  81. end
  82. # Main platform invariances:
  83. case RUBY_PLATFORM
  84. when /mswin32/, /mingw32/, /bccwin32/
  85. check_heads(%w[windows.h winsock.h], true)
  86. check_libs(%w[kernel32 rpcrt4 gdi32], true)
  87. if GNU_CHAIN
  88. CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++"
  89. else
  90. $defs.push "-EHs"
  91. $defs.push "-GR"
  92. end
  93. when /solaris/
  94. add_define 'OS_SOLARIS8'
  95. check_libs(%w[nsl socket], true)
  96. if CONFIG['CC'] == 'cc' and `cc -flags 2>&1` =~ /Sun/ # detect SUNWspro compiler
  97. # SUN CHAIN
  98. add_define 'CC_SUNWspro'
  99. $preload = ["\nCXX = CC"] # hack a CXX= line into the makefile
  100. $CFLAGS = CONFIG['CFLAGS'] = "-KPIC"
  101. CONFIG['CCDLFLAGS'] = "-KPIC"
  102. CONFIG['LDSHARED'] = "$(CXX) -G -KPIC -lCstd"
  103. else
  104. # GNU CHAIN
  105. # on Unix we need a g++ link, not gcc.
  106. CONFIG['LDSHARED'] = "$(CXX) -shared"
  107. end
  108. when /openbsd/
  109. # OpenBSD branch contributed by Guillaume Sellier.
  110. # on Unix we need a g++ link, not gcc. On OpenBSD, linking against libstdc++ have to be explicitly done for shared libs
  111. CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++ -fPIC"
  112. CONFIG['LDSHAREDXX'] = "$(CXX) -shared -lstdc++ -fPIC"
  113. when /darwin/
  114. # on Unix we need a g++ link, not gcc.
  115. # Ff line contributed by Daniel Harple.
  116. CONFIG['LDSHARED'] = "$(CXX) " + CONFIG['LDSHARED'].split[1..-1].join(' ')
  117. when /linux/
  118. add_define 'HAVE_EPOLL' if have_func('epoll_create', 'sys/epoll.h')
  119. # on Unix we need a g++ link, not gcc.
  120. CONFIG['LDSHARED'] = "$(CXX) -shared"
  121. when /aix/
  122. CONFIG['LDSHARED'] = "$(CXX) -shared -Wl,-G -Wl,-brtl"
  123. when /cygwin/
  124. # For rubies built with Cygwin, CXX may be set to CC, which is just
  125. # a wrapper for gcc.
  126. # This will compile, but it will not link to the C++ std library.
  127. # Explicitly set CXX to use g++.
  128. CONFIG['CXX'] = "g++"
  129. # on Unix we need a g++ link, not gcc.
  130. CONFIG['LDSHARED'] = "$(CXX) -shared"
  131. else
  132. # on Unix we need a g++ link, not gcc.
  133. CONFIG['LDSHARED'] = "$(CXX) -shared"
  134. end
  135. # solaris c++ compiler doesn't have make_pair()
  136. TRY_LINK.sub!('$(CC)', '$(CXX)')
  137. add_define 'HAVE_MAKE_PAIR' if try_link(<<SRC, '-lstdc++')
  138. #include <utility>
  139. using namespace std;
  140. int main(){ pair<int,int> tuple = make_pair(1,2); }
  141. SRC
  142. TRY_LINK.sub!('$(CXX)', '$(CC)')
  143. create_makefile "rubyeventmachine"