root/trunk/ext/extconf.rb

Revision 788, 4.2 kB (checked in by raggi, 8 months ago)

Merge of branches/raggi
Most notable work and patches by Aman Gupta, Roger Pack, and James Tucker.
Patches / Tickets also submitted by: Jeremy Evans, aanand, darix, mmmurf,
danielaquino, macournoyer.

  • Moved docs into docs/ dir
  • Major refactor of rakefile, added generic rakefile helpers in tasks
  • Added example CPP build rakefile in tasks/cpp.rake
  • Moved rake tests out to tasks/tests.rake
  • Added svn ignores where appropriate
  • Fixed jruby build on older java platforms
  • Gem now builds from Rakefile rather than directly via extconf
  • Gem unified for jruby, C++ and pure ruby.
  • Correction for pure C++ build, removing ruby dependency
  • Fix for CYGWIN builds on ipv6
  • Major refactor for extconf.rb
  • Working mingw builds
  • extconf optionally uses pkg_config over manual configuration
  • extconf builds for 1.9 on any system that has 1.9
  • extconf no longer links pthread explicitly
  • looks for kqueue on all *nix systems
  • better error output on std::runtime_error, now says where it came from
  • Fixed some tests on jruby
  • Added test for general send_data flaw, required for a bugfix in jruby build
  • Added timeout to epoll tests
  • Added fixes for java reactor ruby api
  • Small addition of some docs in httpclient.rb and httpcli2.rb
  • Some refactor and fixes in smtpserver.rb
  • Added parenthesis where possible to avoid excess ruby warnings
  • Refactor of $eventmachine_library logic for accuracy and maintenance, jruby
  • EM::start_server now supports unix sockets
  • EM::connect now supports unix sockets
  • EM::defer @threadqueue now handled more gracefully
  • Added better messages on exceptions raised
  • Fix edge case in timer fires
  • Explicitly require buftok.rb
  • Add protocols to autoload, rather than require them all immediately
  • Fix a bug in pr_eventmachine for outbound_q
  • Refactors to take some of the use of defer out of tests.
  • Fixes in EM.defer under start/stop conditions. Reduced scope of threads.
  • Property svn:keywords set to Id
Line 
1 # $Id$
2 #
3 #----------------------------------------------------------------------------
4 #
5 # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
6 # Gmail: blackhedd
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of either: 1) the GNU General Public License
10 # as published by the Free Software Foundation; either version 2 of the
11 # License, or (at your option) any later version; or 2) Ruby's License.
12 #
13 # See the file COPYING for complete licensing information.
14 #
15 #---------------------------------------------------------------------------
16 #
17 # extconf.rb for Ruby/EventMachine
18 # We have to munge LDSHARED because this code needs a C++ link.
19 #
20
21 def check_libs libs = [], fatal = false
22   libs.all? { |lib| have_library(lib) || (abort("could not find library: #{lib}") if fatal) }
23 end
24
25 def check_heads heads = [], fatal = false
26   heads.all? { |head| have_header(head) || (abort("could not find header: #{head}") if fatal)}
27 end
28
29 def add_define(name)
30   $defs.push("-D#{name}")
31 end
32
33 require 'mkmf'
34
35 add_define 'BUILD_FOR_RUBY'
36
37 add_define "HAVE_TBR" if have_func('rb_thread_blocking_region') and have_macro('RB_UBF_DFL', 'ruby.h')
38
39 # Minor platform details between *nix and Windows:
40
41 if RUBY_PLATFORM =~ /(mswin|mingw|bccwin)/
42   GNU_CHAIN = $1 == 'mingw'
43   OS_WIN32 = true
44   add_define "OS_WIN32"
45 else
46   GNU_CHAIN = true
47   OS_UNIX = true
48   add_define 'OS_UNIX'
49
50   add_define "HAVE_KQUEUE" if have_header("sys/event.h") and have_header("sys/queue.h")
51
52   # check_libs(%w[pthread], true)
53 end
54
55 # Main platform invariances:
56
57 case RUBY_PLATFORM
58 when /mswin32/, /mingw32/, /bccwin32/
59   check_heads(%w[windows.h winsock.h], true)
60   check_libs(%w[kernel32 rpcrt4 gdi32], true)
61
62   if GNU_CHAIN
63     CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++"
64   else
65     $defs.push "-EHs"
66     $defs.push "-GR"
67   end
68
69 when /solaris/
70   check_libs(%w[nsl socket], true)
71
72   add_define 'OS_SOLARIS8'
73
74   # on Unix we need a g++ link, not gcc.
75   CONFIG['LDSHARED'] = "$(CXX) -shared"
76
77   # Patch by Tim Pease, fixes SUNWspro compile problems.
78   if CONFIG['CC'] == 'cc'
79     $CFLAGS = CONFIG['CFLAGS'] = "-g -O2 -fPIC"
80     CONFIG['CCDLFLAGS'] = "-fPIC"
81   end
82
83 when /openbsd/
84   # OpenBSD branch contributed by Guillaume Sellier.
85
86   # on Unix we need a g++ link, not gcc. On OpenBSD, linking against libstdc++ have to be explicitly done for shared libs
87   CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++"
88
89 when /darwin/
90
91   # on Unix we need a g++ link, not gcc.
92   # Ff line contributed by Daniel Harple.
93   CONFIG['LDSHARED'] = "$(CXX) " + CONFIG['LDSHARED'].split[1..-1].join(' ')
94
95 when /linux/
96
97   # Original epoll test is inadequate because 2.4 kernels have the header
98   # but not the code.
99   # add_define 'HAVE_EPOLL' if have_header('sys/epoll.h')
100   if have_header('sys/epoll.h')
101     File.open("hasEpollTest.c", "w") {|f|
102       f.puts "#include <sys/epoll.h>"
103       f.puts "int main() { epoll_create(1024); return 0;}"
104     }
105     (e = system( "gcc hasEpollTest.c -o hasEpollTest " )) and (e = $?.to_i)
106     `rm -f hasEpollTest.c hasEpollTest`
107     add_define 'HAVE_EPOLL' if e == 0
108   end
109
110   # on Unix we need a g++ link, not gcc.
111   CONFIG['LDSHARED'] = "$(CXX) -shared"
112 else
113   # on Unix we need a g++ link, not gcc.
114   CONFIG['LDSHARED'] = "$(CXX) -shared"
115 end
116
117 # OpenSSL:
118
119 def manual_ssl_config
120   ssl_libs_heads_args = {
121     :unix => [%w[ssl crypto], %w[openssl/ssl.h openssl/err.h]],
122     :darwin => [%w[ssl crypto C], %w[openssl/ssl.h openssl/err.h]],
123     # openbsd and linux:
124     :crypto_hack => [%w[crypto ssl crypto], %w[openssl/ssl.h openssl/err.h]],
125     :mswin => [%w[ssleay32 libeay32], %w[openssl/ssl.h openssl/err.h]],
126   }
127
128   dc_flags = ['ssl']
129   dc_flags += ["#{ENV['OPENSSL']}/include", ENV['OPENSSL']] if /linux/ =~ RUBY_PLATFORM
130
131   libs, heads = case RUBY_PLATFORM
132   when /mswin/    ; ssl_libs_heads_args[:mswin]
133   when /mingw/    ; ssl_libs_heads_args[:unix]
134   when /darwin/   ; ssl_libs_heads_args[:darwin]
135   when /openbsd/  ; ssl_libs_heads_args[:crypto_hack]
136   when /linux/    ; ssl_libs_heads_args[:crypto_hack]
137   else              ssl_libs_heads_args[:unix]
138   end
139   dir_config(*dc_flags)
140   check_libs(libs) and check_heads(heads)
141 end
142
143 # Try to use pkg_config first, fixes #73
144 if pkg_config('openssl') || manual_ssl_config
145   add_define "WITH_SSL"
146 else
147   add_define "WITHOUT_SSL"
148 end
149
150 create_makefile "rubyeventmachine"
Note: See TracBrowser for help on using the browser.