3 $CPPFLAGS += " -D_BSD_SOURCE=1 "
5 # XXX let me know if this works for you...
6 if ! defined?(RUBY_VERSION) || RUBY_VERSION !~ /\A1\.[89]\./
7 raise "Invalid RUBY_VERSION for C extension"
10 have_header('ruby.h') or raise "ruby.h header not found!"
12 if have_header('fcntl.h')
13 have_macro('F_GETFL', %w(fcntl.h))
14 have_macro('O_NONBLOCK', %w(unistd.h fcntl.h))
17 $CPPFLAGS += '-D_POSIX_C_SOURCE=200112L'
18 unless have_macro('CLOCK_MONOTONIC', 'time.h')
19 have_func('CLOCK_MONOTONIC', 'time.h')
21 have_type('clockid_t', 'time.h')
22 have_func('clock_gettime', 'time.h')
23 have_func('localtime_r', 'time.h') or raise "localtime_r needed"
24 have_func('gmtime_r', 'time.h') or raise "gmtime_r needed"
25 have_struct_member('struct tm', 'tm_gmtoff', 'time.h')
26 have_func('rb_str_set_len', 'ruby.h')
27 have_func('rb_thread_blocking_region', 'ruby.h')
28 have_func('rb_thread_io_blocking_region', 'ruby.h')
29 create_makefile('clogger_ext')
31 warn "E: #{err.inspect}"
32 warn "Skipping C extension, pure Ruby version will be used instead"
34 # generate a dummy Makefile to fool rubygems installer
35 targets = %w(all static clean distclean realclean
36 install install-so install-rb install-rb-default
37 pre-install-rb pre-install-rb-default
38 site-install site-install-so site-install-rb)
39 File.open(File.dirname(__FILE__) << "/Makefile", "wb") do |fp|
40 fp.puts targets.join(' ') << ":"
41 fp.puts "\techo >&2 extension disabled"