drop Ruby 1.9.3 support, require 2.0+ for now
[unicorn.git] / ext / unicorn_http / extconf.rb
blob8bdc1c9141e8a4815bd0cd4b08f3cef9120ae152
1 # -*- encoding: binary -*-
2 require 'mkmf'
4 unless RUBY_VERSION < '3.1'
5   warn "Unicorn was only tested against MRI up to 3.0.\n" \
6        "It might not properly work with #{RUBY_VERSION}"
7 end
9 have_macro("SIZEOF_OFF_T", "ruby.h") or check_sizeof("off_t", "sys/types.h")
10 have_macro("SIZEOF_SIZE_T", "ruby.h") or check_sizeof("size_t", "sys/types.h")
11 have_macro("SIZEOF_LONG", "ruby.h") or check_sizeof("long", "sys/types.h")
12 have_func("rb_str_set_len", "ruby.h") or abort 'Ruby 2.0+ required'
13 have_func("rb_hash_clear", "ruby.h") or abort 'Ruby 2.0+ required'
14 have_func("gmtime_r", "time.h")
16 message('checking if String#-@ (str_uminus) dedupes... ')
17 begin
18   a = -(%w(t e s t).join)
19   b = -(%w(t e s t).join)
20   if a.equal?(b)
21     $CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=1 '
22     message("yes\n")
23   else
24     $CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=0 '
25     message("no, needs Ruby 2.5+\n")
26   end
27 rescue NoMethodError
28   $CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=0 '
29   message("no, String#-@ not available\n")
30 end
32 message('checking if Hash#[]= (rb_hash_aset) dedupes... ')
33 h = {}
34 x = {}
35 r = rand.to_s
36 h[%W(#{r}).join('')] = :foo
37 x[%W(#{r}).join('')] = :foo
38 if x.keys[0].equal?(h.keys[0])
39   $CPPFLAGS += ' -DHASH_ASET_DEDUPE=1 '
40   message("yes\n")
41 else
42   $CPPFLAGS += ' -DHASH_ASET_DEDUPE=0 '
43   message("no, needs Ruby 2.6+\n")
44 end
46 create_makefile("unicorn_http")