require 'mkmf' flags = [] # configuration for libev if have_header('sys/select.h') flags << '-DEV_USE_SELECT' end if have_header('poll.h') flags << '-DEV_USE_POLL' end if have_header('sys/epoll.h') flags << '-DEV_USE_EPOLL' end if have_header('sys/event.h') and have_header('sys/queue.h') flags << '-DEV_USE_KQUEUE' end if have_header('port.h') flags << '-DEV_USE_PORT' end if have_header('sys/inotify.h') flags << '-DEV_USE_INOTIFY' end have_library("c", "main") have_library("stdc++", "main") if have_library("rt", "clock_gettime") flags << '-DHAVE_LIBRT=1' end if !have_library("pthread", "pthread_create") STDERR.puts "pthread library required to build evdispatch" exit(1) end if have_header("curl/curl.h") and have_library("curl", "curl_easy_init") and have_library("curl", "curl_multi_socket_action") flags << '-DHAVE_CURL_CURL_H=1' flags << '-DHAVE_CURL_SOCKET_T=1' else STDERR.puts "libcurl 7.18.x > required to build evdispatch" exit(1) end build_dir= File.dirname(__FILE__) libdispatch_build_dir=File.expand_path(File.join(build_dir,"libdispatch","src")) libev_build_dir=File.expand_path(File.join(build_dir,"libdispatch","libev-3.31")) $LDFLAGS << " -lpthread -lcurl" $CPPFLAGS << " -DBUILD_EXTENSION -I#{libdispatch_build_dir} -I#{libev_build_dir} " << flags.join(' ') $defs << "-DRUBY_VERSION_CODE=#{RUBY_VERSION.gsub(/\D/, '')}" dir_config("revdispatch") create_makefile("revdispatch") puts "LDFLAGS: #{$LDFLAGS}\nLIBS: #{$LIBS}\nCPPFLAGS: #{$CPPFLAGS}"