em-http-request 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of em-http-request might be problematic. Click here for more details.

@@ -0,0 +1,4 @@
1
+ *.bundle
2
+ *.o
3
+ Makefile
4
+ mkmf.log
@@ -59,13 +59,23 @@ Screencast / Demo of using EM-HTTP-Request:
59
59
  http.errback { failed }
60
60
  http.callback {
61
61
  p http.response_header
62
+ EventMachine.stop
63
+ }
64
+ }
65
+
66
+ == OAuth example
62
67
 
68
+ EventMachine.run {
69
+ http = EventMachine::HttpRequest.new('http://www.website.com/').get :head => {'authorization' => 'OAuth oauth_nonce=...'}
70
+ http.errback { failed }
71
+ http.callback {
72
+ p http.response_header
63
73
  EventMachine.stop
64
74
  }
65
75
  }
66
76
 
67
- == POST example
68
77
 
78
+ == POST example
69
79
  EventMachine.run {
70
80
  http1 = EventMachine::HttpRequest.new('http://www.website.com/').post :body => {"key1" => 1, "key2" => [2,3]}
71
81
  http2 = EventMachine::HttpRequest.new('http://www.website.com/').post :body => "some data"
@@ -80,3 +90,12 @@ Screencast / Demo of using EM-HTTP-Request:
80
90
 
81
91
  # ...
82
92
  }
93
+
94
+ == Proxy example
95
+ EventMachine.run {
96
+ http1 = EventMachine::HttpRequest.new('http://www.website.com/').get :proxy => {
97
+ :host => 'www.myproxy.com',
98
+ :port => 8080,
99
+ :authorization => ['username', 'password'] # authorization is optional
100
+ }
101
+
data/Rakefile CHANGED
@@ -97,7 +97,7 @@ begin
97
97
  gemspec.add_dependency('eventmachine', '>= 0.12.9')
98
98
  gemspec.add_dependency('addressable', '>= 2.0.0')
99
99
  gemspec.rubyforge_project = "em-http-request"
100
- gemspec.files = FileList["[A-Z]*", "{lib,test,ext}/**/*"]
100
+ gemspec.files = FileList[`git ls-files`.split]
101
101
  end
102
102
 
103
103
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.2.5
@@ -39,7 +39,7 @@ module EventMachine
39
39
  # Length of content as an integer, or nil if chunked/unspecified
40
40
  def content_length
41
41
  @content_length ||= ((s = self[HttpClient::CONTENT_LENGTH]) &&
42
- (s =~ /^(\d+)$/)) ? $1.to_i : nil
42
+ (s =~ /^(\d+)$/)) ? $1.to_i : nil
43
43
  end
44
44
 
45
45
  # Cookie header from the server
@@ -80,7 +80,6 @@ module EventMachine
80
80
  module HttpEncoding
81
81
  HTTP_REQUEST_HEADER="%s %s HTTP/1.1\r\n"
82
82
  FIELD_ENCODING = "%s: %s\r\n"
83
- BASIC_AUTH_ENCODING = "%s: Basic %s\r\n"
84
83
 
85
84
  # Escapes a URI.
86
85
  def escape(s)
@@ -141,18 +140,25 @@ module EventMachine
141
140
  end
142
141
 
143
142
  # Encode basic auth in an HTTP header
144
- def encode_basic_auth(k,v)
145
- BASIC_AUTH_ENCODING % [k, Base64.encode64(v.join(":")).chomp]
143
+ # In: Array ([user, pass]) - for basic auth
144
+ # String - custom auth string (OAuth, etc)
145
+ def encode_auth(k,v)
146
+ if v.is_a? Array
147
+ FIELD_ENCODING % [k, ["Basic", Base64.encode64(v.join(":")).chomp].join(" ")]
148
+ else
149
+ encode_field(k,v)
150
+ end
146
151
  end
147
152
 
148
153
  def encode_headers(head)
149
154
  head.inject('') do |result, (key, value)|
150
155
  # Munge keys from foo-bar-baz to Foo-Bar-Baz
151
- key = key.split('-').map { |k| k.capitalize }.join('-')
152
- unless key == "Authorization"
153
- result << encode_field(key, value)
156
+ key = key.split('-').map { |k| k.to_s.capitalize }.join('-')
157
+ result << case key
158
+ when 'Authorization', 'Proxy-authorization'
159
+ encode_auth(key, value)
154
160
  else
155
- result << encode_basic_auth(key, value)
161
+ encode_field(key, value)
156
162
  end
157
163
  end
158
164
  end
@@ -185,24 +191,35 @@ module EventMachine
185
191
  def post_init
186
192
  @parser = HttpClientParser.new
187
193
  @data = EventMachine::Buffer.new
188
- @response_header = HttpResponseHeader.new
189
194
  @chunk_header = HttpChunkHeader.new
190
-
191
- @state = :response_header
195
+ @response_header = HttpResponseHeader.new
192
196
  @parser_nbytes = 0
193
197
  @response = ''
194
198
  @errors = ''
195
199
  @content_decoder = nil
196
200
  @stream = nil
201
+ @state = :response_header
197
202
  end
198
203
 
199
204
  # start HTTP request once we establish connection to host
200
- def connection_completed
201
- ssl = @options[:tls] || @options[:ssl] || {}
202
- start_tls(ssl) if @uri.scheme == "https" or @uri.port == 443
203
-
204
- send_request_header
205
- send_request_body
205
+ def connection_completed
206
+ # if connecting to proxy, then first negotiate the connection
207
+ # to intermediate server and wait for 200 response
208
+ if @options[:proxy] and @state == :response_header
209
+ @state = :response_proxy
210
+ send_request_header
211
+
212
+ # if connecting via proxy, then state will be :proxy_connected,
213
+ # indicating successful tunnel. from here, initiate normal http
214
+ # exchange
215
+ else
216
+ @state = :response_header
217
+
218
+ ssl = @options[:tls] || @options[:ssl] || {}
219
+ start_tls(ssl) if @uri.scheme == "https" or @uri.port == 443
220
+ send_request_header
221
+ send_request_body
222
+ end
206
223
  end
207
224
 
208
225
  # request is done, invoke the callback
@@ -236,36 +253,46 @@ module EventMachine
236
253
  @options[:body]
237
254
  end
238
255
  end
239
-
256
+
240
257
  def send_request_header
241
258
  query = @options[:query]
242
259
  head = @options[:head] ? munge_header_keys(@options[:head]) : {}
243
260
  body = normalize_body
261
+ request_header = nil
244
262
 
245
- # Set the Host header if it hasn't been specified already
246
- head['host'] ||= encode_host
263
+ if @state == :response_proxy
264
+ proxy = @options[:proxy]
247
265
 
248
- # Set the Content-Length if body is given
249
- head['content-length'] = body.length if body
266
+ # initialize headers to establish the HTTP tunnel
267
+ head = proxy[:head] ? munge_header_keys(proxy[:head]) : {}
268
+ head['proxy-authorization'] = proxy[:authorization] if proxy[:authorization]
269
+ request_header = HTTP_REQUEST_HEADER % ['CONNECT', "#{@uri.host}:#{@uri.port}"]
250
270
 
251
- # Set the User-Agent if it hasn't been specified
252
- head['user-agent'] ||= "EventMachine HttpClient"
271
+ else
272
+ # Set the Content-Length if body is given
273
+ head['content-length'] = body.length if body
253
274
 
254
- # Set the cookie header if provided
255
- if cookie = head.delete('cookie')
256
- head['cookie'] = encode_cookie(cookie)
257
- end
275
+ # Set the cookie header if provided
276
+ if cookie = head.delete('cookie')
277
+ head['cookie'] = encode_cookie(cookie)
278
+ end
258
279
 
259
- # Set content-type header if missing and body is a Ruby hash
260
- if not head['content-type'] and options[:body].is_a? Hash
261
- head['content-type'] = "application/x-www-form-urlencoded"
280
+ # Set content-type header if missing and body is a Ruby hash
281
+ if not head['content-type'] and options[:body].is_a? Hash
282
+ head['content-type'] = "application/x-www-form-urlencoded"
283
+ end
262
284
  end
263
285
 
264
- # Build the request
265
- request_header = encode_request(@method, @uri.path, query, @uri.query)
286
+ # Set the Host header if it hasn't been specified already
287
+ head['host'] ||= encode_host
288
+
289
+ # Set the User-Agent if it hasn't been specified
290
+ head['user-agent'] ||= "EventMachine HttpClient"
291
+
292
+ # Build the request headers
293
+ request_header ||= encode_request(@method, @uri.path, query, @uri.query)
266
294
  request_header << encode_headers(head)
267
295
  request_header << CRLF
268
-
269
296
  send_data request_header
270
297
  end
271
298
 
@@ -303,7 +330,7 @@ module EventMachine
303
330
 
304
331
  def unbind
305
332
  if @state == :finished || (@state == :body && @bytes_remaining.nil?)
306
- succeed(self)
333
+ succeed(self)
307
334
  else
308
335
  fail(self)
309
336
  end
@@ -316,6 +343,8 @@ module EventMachine
316
343
 
317
344
  def dispatch
318
345
  while case @state
346
+ when :response_proxy
347
+ parse_response_proxy
319
348
  when :response_header
320
349
  parse_response_header
321
350
  when :chunk_header
@@ -354,6 +383,28 @@ module EventMachine
354
383
 
355
384
  true
356
385
  end
386
+
387
+ # TODO: refactor with parse_response_header
388
+ def parse_response_proxy
389
+ return false unless parse_header(@response_header)
390
+
391
+ unless @response_header.http_status and @response_header.http_reason
392
+ @state = :invalid
393
+ on_error "no HTTP response"
394
+ return false
395
+ end
396
+
397
+ # when a successfull tunnel is established, the proxy responds with a
398
+ # 200 response code. from here, the tunnel is transparent.
399
+ if @response_header.http_status.to_i == 200
400
+ @response_header = HttpResponseHeader.new
401
+ connection_completed
402
+ else
403
+ @state = :invalid
404
+ on_error "proxy not accessible"
405
+ return false
406
+ end
407
+ end
357
408
 
358
409
  def parse_response_header
359
410
  return false unless parse_header(@response_header)
@@ -378,7 +429,7 @@ module EventMachine
378
429
  end
379
430
  end
380
431
 
381
- # shortcircuit on HEAD requests
432
+ # shortcircuit on HEAD requests
382
433
  if @method == "HEAD"
383
434
  @state = :finished
384
435
  on_request_complete
@@ -388,7 +439,7 @@ module EventMachine
388
439
  @state = :chunk_header
389
440
  elsif @response_header.content_length
390
441
  @state = :body
391
- @bytes_remaining = @response_header.content_length
442
+ @bytes_remaining = @response_header.content_length
392
443
  else
393
444
  @state = :body
394
445
  @bytes_remaining = nil
@@ -9,7 +9,6 @@ module EventMachine
9
9
  #
10
10
  # == Example
11
11
  #
12
- #
13
12
  # EventMachine.run {
14
13
  # http = EventMachine::HttpRequest.new('http://127.0.0.1/').get :query => {'keyname' => 'value'}
15
14
  #
@@ -58,22 +57,31 @@ module EventMachine
58
57
 
59
58
  def setup_request(method, options)
60
59
  raise ArgumentError, "invalid request path" unless /^\// === @uri.path
61
-
62
60
  @options = options
61
+
62
+ if proxy = options[:proxy]
63
+ @host_to_connect = proxy[:host]
64
+ @port_to_connect = proxy[:port]
65
+ else
66
+ @host_to_connect = @uri.host
67
+ @port_to_connect = @uri.port
68
+ end
69
+
70
+ # default connect & inactivity timeouts
71
+ @options[:timeout] = 10 if not @options[:timeout]
63
72
 
64
- # default connect & inactivity timeouts
65
- @options[:timeout] = 5 if not @options[:timeout]
66
-
67
- # Make sure the port is set as Addressable::URI doesn't set the
68
- # port if it isn't there.
73
+ # Make sure the ports are set as Addressable::URI doesn't
74
+ # set the port if it isn't there
69
75
  @uri.port ||= 80
76
+ @port_to_connect ||= 80
77
+
70
78
  @method = method.to_s.upcase
71
79
  send_request
72
80
  end
73
81
 
74
82
  def send_request
75
83
  begin
76
- EventMachine.connect(@uri.host, @uri.port, EventMachine::HttpClient) { |c|
84
+ EventMachine.connect(@host_to_connect, @port_to_connect, EventMachine::HttpClient) { |c|
77
85
  c.uri = @uri
78
86
  c.method = @method
79
87
  c.options = @options
@@ -127,15 +127,19 @@ Stallion.saddle :spec do |stable|
127
127
  stable.response.status = 304
128
128
 
129
129
  elsif stable.request.env["HTTP_AUTHORIZATION"]
130
- auth = "Basic %s" % Base64.encode64(['user', 'pass'].join(':')).chomp
131
-
132
- if auth == stable.request.env["HTTP_AUTHORIZATION"]
130
+ if stable.request.path_info == '/oauth_auth'
133
131
  stable.response.status = 200
134
- stable.response.write 'success'
132
+ stable.response.write stable.request.env["HTTP_AUTHORIZATION"]
135
133
  else
136
- stable.response.status = 401
137
- end
134
+ auth = "Basic %s" % Base64.encode64(['user', 'pass'].join(':')).chomp
138
135
 
136
+ if auth == stable.request.env["HTTP_AUTHORIZATION"]
137
+ stable.response.status = 200
138
+ stable.response.write 'success'
139
+ else
140
+ stable.response.status = 401
141
+ end
142
+ end
139
143
  elsif stable.request.path_info == '/relative-location'
140
144
  stable.response.status = 301
141
145
  stable.response["Location"] = '/forwarded'
@@ -155,4 +159,61 @@ Thread.new do
155
159
  end
156
160
  end
157
161
 
162
+ #
163
+ # HTTP Proxy server
164
+ #
165
+ Thread.new do
166
+ server = TCPServer.new('127.0.0.1', 8082)
167
+ loop do
168
+ session = server.accept
169
+ request = ""
170
+ while (data = session.gets) != "\r\n"
171
+ request << data
172
+ end
173
+ parts = request.split("\r\n")
174
+ method, destination, http_version = parts.first.split(' ')
175
+ if method == 'CONNECT'
176
+ target_host, target_port = destination.split(':')
177
+ client = TCPSocket.open(target_host, target_port)
178
+ session.write "HTTP/1.1 200 Connection established\r\nProxy-agent: Whatever\r\n\r\n"
179
+ session.flush
180
+
181
+ content_length = -1
182
+ verb = ""
183
+ req = ""
184
+
185
+ while data = session.gets
186
+ if request = data.match(/(\w+).*HTTP\/1\.1/)
187
+ verb = request[1]
188
+ end
189
+
190
+ if post = data.match(/Content-Length: (\d+)/)
191
+ content_length = post[1].to_i
192
+ end
193
+
194
+ req += data
195
+
196
+ # read POST data
197
+ if data == "\r\n" and verb == "POST"
198
+ req += session.read(content_length)
199
+ end
200
+
201
+ if data == "\r\n"
202
+ client.write req
203
+ client.flush
204
+ client.close_write
205
+ break
206
+ end
207
+ end
208
+
209
+ while data = client.gets
210
+ session.write data
211
+ end
212
+ session.flush
213
+ client.close
214
+ end
215
+ session.close
216
+ end
217
+ end
218
+
158
219
  sleep(1)
@@ -11,7 +11,7 @@ describe EventMachine::MultiRequest do
11
11
 
12
12
  # add multiple requests to the multi-handler
13
13
  multi.add(EventMachine::HttpRequest.new('http://127.0.0.1:8080/').get(:query => {:q => 'test'}))
14
- multi.add(EventMachine::HttpRequest.new('http://0.0.0.0:8081/').get(:timeout => 1))
14
+ multi.add(EventMachine::HttpRequest.new('http://0.0.0.0:8083/').get(:timeout => 1))
15
15
 
16
16
  multi.callback {
17
17
  # verify successfull request
@@ -223,7 +223,7 @@ describe EventMachine::HttpRequest do
223
223
  http = EventMachine::HttpRequest.new('http://digg.com/').get
224
224
 
225
225
  http.errback { failed }
226
- http.callback {
226
+ http.callback {
227
227
  http.response_header.status.should == 200
228
228
  EventMachine.stop
229
229
  }
@@ -242,6 +242,20 @@ describe EventMachine::HttpRequest do
242
242
  }
243
243
  }
244
244
  end
245
+
246
+ it "should send proper OAuth auth header" do
247
+ EventMachine.run {
248
+ oauth_header = 'OAuth oauth_nonce="oqwgSYFUD87MHmJJDv7bQqOF2EPnVus7Wkqj5duNByU", b=c, d=e'
249
+ http = EventMachine::HttpRequest.new('http://127.0.0.1:8080/oauth_auth').get :head => {'authorization' => oauth_header}
250
+
251
+ http.errback { failed }
252
+ http.callback {
253
+ http.response_header.status.should == 200
254
+ http.response.should == oauth_header
255
+ EventMachine.stop
256
+ }
257
+ }
258
+ end
245
259
 
246
260
  it "should work with keep-alive servers" do
247
261
  EventMachine.run {
@@ -472,5 +486,38 @@ describe EventMachine::HttpRequest do
472
486
  EventMachine.stop
473
487
  }
474
488
  }
489
+ end
490
+
491
+ context "connections via proxy" do
492
+
493
+ it "should work with proxy servers" do
494
+ EventMachine.run {
495
+
496
+ http = EventMachine::HttpRequest.new('http://127.0.0.1:8080/').get :proxy => {:host => '127.0.0.1', :port => 8082}
497
+
498
+ http.errback { p http.inspect; failed }
499
+ http.callback {
500
+ http.response_header.status.should == 200
501
+ http.response.should == 'Hello, World!'
502
+ EventMachine.stop
503
+ }
504
+ }
505
+ end
506
+
507
+ it "should proxy POST data" do
508
+ EventMachine.run {
509
+
510
+ http = EventMachine::HttpRequest.new('http://127.0.0.1:8080/').post({
511
+ :body => "data", :proxy => {:host => '127.0.0.1', :port => 8082}})
512
+
513
+ http.errback { failed }
514
+ http.callback {
515
+ http.response_header.status.should == 200
516
+ http.response.should match(/data/)
517
+ EventMachine.stop
518
+ }
519
+ }
520
+ end
521
+
475
522
  end
476
- end
523
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-http-request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Grigorik
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-01 00:00:00 -05:00
12
+ date: 2009-12-12 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -43,16 +43,17 @@ extra_rdoc_files:
43
43
  - LICENSE
44
44
  - README.rdoc
45
45
  files:
46
+ - .gitignore
46
47
  - LICENSE
47
48
  - README.rdoc
48
49
  - Rakefile
49
50
  - VERSION
51
+ - examples/fetch.rb
52
+ - examples/fibered-http.rb
50
53
  - ext/buffer/em_buffer.c
51
54
  - ext/buffer/extconf.rb
52
- - ext/http11_client/Makefile
53
55
  - ext/http11_client/ext_help.h
54
56
  - ext/http11_client/extconf.rb
55
- - ext/http11_client/http11_client.bundle
56
57
  - ext/http11_client/http11_client.c
57
58
  - ext/http11_client/http11_parser.c
58
59
  - ext/http11_client/http11_parser.h
@@ -1,157 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- #### Start of system configuration section. ####
5
-
6
- srcdir = .
7
- topdir = /opt/local/lib/ruby/1.8/i686-darwin10
8
- hdrdir = $(topdir)
9
- VPATH = $(srcdir):$(topdir):$(hdrdir)
10
- exec_prefix = $(prefix)
11
- prefix = $(DESTDIR)/opt/local
12
- sharedstatedir = $(prefix)/com
13
- mandir = $(DESTDIR)/opt/local/share/man
14
- psdir = $(docdir)
15
- oldincludedir = $(DESTDIR)/usr/include
16
- localedir = $(datarootdir)/locale
17
- bindir = $(exec_prefix)/bin
18
- libexecdir = $(exec_prefix)/libexec
19
- sitedir = $(libdir)/ruby/site_ruby
20
- htmldir = $(docdir)
21
- vendorarchdir = $(vendorlibdir)/$(sitearch)
22
- includedir = $(prefix)/include
23
- infodir = $(datarootdir)/info
24
- vendorlibdir = $(vendordir)/$(ruby_version)
25
- sysconfdir = $(prefix)/etc
26
- libdir = $(exec_prefix)/lib
27
- sbindir = $(exec_prefix)/sbin
28
- rubylibdir = $(libdir)/ruby/$(ruby_version)
29
- docdir = $(datarootdir)/doc/$(PACKAGE)
30
- dvidir = $(docdir)
31
- vendordir = $(DESTDIR)/opt/local/lib/ruby/vendor_ruby
32
- datarootdir = $(prefix)/share
33
- pdfdir = $(docdir)
34
- archdir = $(rubylibdir)/$(arch)
35
- sitearchdir = $(sitelibdir)/$(sitearch)
36
- datadir = $(datarootdir)
37
- localstatedir = $(prefix)/var
38
- sitelibdir = $(sitedir)/$(ruby_version)
39
-
40
- CC = /usr/bin/gcc-4.2
41
- LIBRUBY = $(LIBRUBY_SO)
42
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
43
- LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
44
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
45
-
46
- RUBY_EXTCONF_H =
47
- CFLAGS = -fno-common -O2 -arch x86_64 -fno-common -pipe -fno-common $(cflags) -arch x86_64
48
- INCFLAGS = -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin10 -I.
49
- DEFS =
50
- CPPFLAGS = -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/include
51
- CXXFLAGS = $(CFLAGS)
52
- ldflags = -L. -L/opt/local/lib
53
- dldflags =
54
- archflag = -arch x86_64
55
- DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
56
- LDSHARED = $(CC) -dynamic -bundle -undefined suppress -flat_namespace
57
- AR = ar
58
- EXEEXT =
59
-
60
- RUBY_INSTALL_NAME = ruby
61
- RUBY_SO_NAME = ruby
62
- arch = i686-darwin10
63
- sitearch = i686-darwin10
64
- ruby_version = 1.8
65
- ruby = /opt/local/bin/ruby
66
- RUBY = $(ruby)
67
- RM = rm -f
68
- MAKEDIRS = mkdir -p
69
- INSTALL = /usr/bin/install -c
70
- INSTALL_PROG = $(INSTALL) -m 0755
71
- INSTALL_DATA = $(INSTALL) -m 644
72
- COPY = cp
73
-
74
- #### End of system configuration section. ####
75
-
76
- preload =
77
-
78
- libpath = . $(libdir)
79
- LIBPATH = -L. -L$(libdir)
80
- DEFFILE =
81
-
82
- CLEANFILES = mkmf.log
83
- DISTCLEANFILES =
84
-
85
- extout =
86
- extout_prefix =
87
- target_prefix =
88
- LOCAL_LIBS =
89
- LIBS = $(LIBRUBYARG_SHARED) -lc -lpthread -ldl -lobjc
90
- SRCS = http11_client.c http11_parser.c
91
- OBJS = http11_client.o http11_parser.o
92
- TARGET = http11_client
93
- DLLIB = $(TARGET).bundle
94
- EXTSTATIC =
95
- STATIC_LIB =
96
-
97
- BINDIR = $(bindir)
98
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
99
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
100
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
101
-
102
- TARGET_SO = $(DLLIB)
103
- CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
104
- CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
105
-
106
- all: $(DLLIB)
107
- static: $(STATIC_LIB)
108
-
109
- clean:
110
- @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
111
-
112
- distclean: clean
113
- @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
114
- @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
115
-
116
- realclean: distclean
117
- install: install-so install-rb
118
-
119
- install-so: $(RUBYARCHDIR)
120
- install-so: $(RUBYARCHDIR)/$(DLLIB)
121
- $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
122
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
123
- install-rb: pre-install-rb install-rb-default
124
- install-rb-default: pre-install-rb-default
125
- pre-install-rb: Makefile
126
- pre-install-rb-default: Makefile
127
- $(RUBYARCHDIR):
128
- $(MAKEDIRS) $@
129
-
130
- site-install: site-install-so site-install-rb
131
- site-install-so: install-so
132
- site-install-rb: install-rb
133
-
134
- .SUFFIXES: .c .m .cc .cxx .cpp .C .o
135
-
136
- .cc.o:
137
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
138
-
139
- .cxx.o:
140
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
141
-
142
- .cpp.o:
143
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
144
-
145
- .C.o:
146
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
147
-
148
- .c.o:
149
- $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
150
-
151
- $(DLLIB): $(OBJS) Makefile
152
- @-$(RM) $@
153
- $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
154
-
155
-
156
-
157
- $(OBJS): ruby.h defines.h