OSDN Git Service

Replaced mongrel with thin
[redminele/redminele.git] / ruby / lib / ruby / gems / 1.8 / gems / eventmachine-0.12.10-x86-mswin32-60 / ext / extconf.rb
1 require 'mkmf'
2
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
7 def check_heads heads = [], fatal = false
8   heads.all? { |head| have_header(head) || (abort("could not find header: #{head}") if fatal)}
9 end
10
11 def add_define(name)
12   $defs.push("-D#{name}")
13 end
14
15 add_define 'BUILD_FOR_RUBY'
16 add_define 'HAVE_RBTRAP' if have_var('rb_trap_immediate', ['ruby.h', 'rubysig.h'])
17 add_define "HAVE_TBR" if have_func('rb_thread_blocking_region')# and have_macro('RUBY_UBF_IO', 'ruby.h')
18 add_define "HAVE_INOTIFY" if inotify = have_func('inotify_init', 'sys/inotify.h')
19 add_define "HAVE_OLD_INOTIFY" if !inotify && have_macro('__NR_inotify_init', 'sys/syscall.h')
20 add_define 'HAVE_WRITEV' if have_func('writev', 'sys/uio.h')
21 have_func('rb_thread_check_ints')
22 have_func('rb_time_new')
23
24 # Minor platform details between *nix and Windows:
25
26 if RUBY_PLATFORM =~ /(mswin|mingw|bccwin)/
27   GNU_CHAIN = $1 == 'mingw'
28   OS_WIN32 = true
29   add_define "OS_WIN32"
30 else
31   GNU_CHAIN = true
32   OS_UNIX = true
33   add_define 'OS_UNIX'
34
35   add_define "HAVE_KQUEUE" if have_header("sys/event.h") and have_header("sys/queue.h")
36 end
37
38 # Main platform invariances:
39
40 case RUBY_PLATFORM
41 when /mswin32/, /mingw32/, /bccwin32/
42   check_heads(%w[windows.h winsock.h], true)
43   check_libs(%w[kernel32 rpcrt4 gdi32], true)
44
45   if GNU_CHAIN
46     CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++"
47   else
48     $defs.push "-EHs"
49     $defs.push "-GR"
50   end
51
52 when /solaris/
53   add_define 'OS_SOLARIS8'
54   check_libs(%w[nsl socket], true)
55
56   # Patch by Tim Pease, fixes SUNWspro compile problems.
57   if CONFIG['CC'] == 'cc'
58     # SUN CHAIN
59     $CFLAGS = CONFIG['CFLAGS'] = "-KPIC -G"
60     CONFIG['CCDLFLAGS'] = "-KPIC"
61   else
62     # GNU CHAIN
63     # on Unix we need a g++ link, not gcc.
64     CONFIG['LDSHARED'] = "$(CXX) -shared"
65   end
66
67 when /openbsd/
68   # OpenBSD branch contributed by Guillaume Sellier.
69
70   # on Unix we need a g++ link, not gcc. On OpenBSD, linking against libstdc++ have to be explicitly done for shared libs
71   CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++ -fPIC"
72   CONFIG['LDSHAREDXX'] = "$(CXX) -shared -lstdc++ -fPIC"
73
74 when /darwin/
75   # on Unix we need a g++ link, not gcc.
76   # Ff line contributed by Daniel Harple.
77   CONFIG['LDSHARED'] = "$(CXX) " + CONFIG['LDSHARED'].split[1..-1].join(' ')
78
79 when /linux/
80   add_define 'HAVE_EPOLL' if have_func('epoll_create', 'sys/epoll.h')
81
82   # Original epoll test is inadequate because 2.4 kernels have the header
83   # but not the code.
84   # add_define 'HAVE_EPOLL' if have_header('sys/epoll.h')
85   # if have_header('sys/epoll.h')
86   #   File.open("hasEpollTest.c", "w") {|f|
87   #     f.puts "#include <sys/epoll.h>"
88   #     f.puts "int main() { epoll_create(1024); return 0;}"
89   #   }
90   #   (e = system( "gcc hasEpollTest.c -o hasEpollTest " )) and (e = $?.to_i)
91   #   `rm -f hasEpollTest.c hasEpollTest`
92   #   add_define 'HAVE_EPOLL' if e == 0
93   # end
94
95   # on Unix we need a g++ link, not gcc.
96   CONFIG['LDSHARED'] = "$(CXX) -shared"
97
98 when /aix/
99   CONFIG['LDSHARED'] = "$(CXX) -shared -Wl,-G -Wl,-brtl"
100
101 else
102   # on Unix we need a g++ link, not gcc.
103   CONFIG['LDSHARED'] = "$(CXX) -shared"
104 end
105
106 # OpenSSL:
107
108 def manual_ssl_config
109   ssl_libs_heads_args = {
110     :unix => [%w[ssl crypto], %w[openssl/ssl.h openssl/err.h]],
111     :darwin => [%w[ssl crypto C], %w[openssl/ssl.h openssl/err.h]],
112     # openbsd and linux:
113     :crypto_hack => [%w[crypto ssl crypto], %w[openssl/ssl.h openssl/err.h]],
114     :mswin => [%w[ssleay32 libeay32], %w[openssl/ssl.h openssl/err.h]],
115   }
116
117   dc_flags = ['ssl']
118   dc_flags += ["#{ENV['OPENSSL']}/include", ENV['OPENSSL']] if /linux/ =~ RUBY_PLATFORM
119
120   libs, heads = case RUBY_PLATFORM
121   when /mswin/    ; ssl_libs_heads_args[:mswin]
122   when /mingw/    ; ssl_libs_heads_args[:unix]
123   when /darwin/   ; ssl_libs_heads_args[:darwin]
124   when /openbsd/  ; ssl_libs_heads_args[:crypto_hack]
125   when /linux/    ; ssl_libs_heads_args[:crypto_hack]
126   else              ssl_libs_heads_args[:unix]
127   end
128   dir_config(*dc_flags)
129   check_libs(libs) and check_heads(heads)
130 end
131
132 # Try to use pkg_config first, fixes #73
133 if pkg_config('openssl') || manual_ssl_config
134   add_define "WITH_SSL"
135 else
136   add_define "WITHOUT_SSL"
137 end
138
139 # solaris c++ compiler doesn't have make_pair()
140 TRY_LINK.sub!('$(CC)', '$(CXX)')
141 add_define 'HAVE_MAKE_PAIR' if try_link(<<SRC, '-lstdc++')
142   #include <utility>
143   using namespace std;
144   int main(){ pair<int,int> tuple = make_pair(1,2); }
145 SRC
146 TRY_LINK.sub!('$(CXX)', '$(CC)')
147
148 create_makefile "rubyeventmachine"