-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
extconf.rb
35 lines (22 loc) · 1 KB
/
extconf.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true
require "mkmf"
have_header("unistd.h")
$defs << "-DEV_USE_SELECT" if have_header("sys/select.h")
$defs << "-DEV_USE_POLL" if have_header("poll.h")
$defs << "-DEV_USE_EPOLL" if have_header("sys/epoll.h")
if have_header("sys/event.h") && have_header("sys/queue.h")
$defs << "-DEV_USE_KQUEUE"
end
$defs << "-DEV_USE_PORT" if have_header("port.h")
$defs << "-DHAVE_SYS_RESOURCE_H" if have_header("sys/resource.h")
CONFIG["optflags"] << " -fno-strict-aliasing" unless RUBY_PLATFORM =~ /mswin/
dir_config "nio4r_ext"
create_makefile "nio4r_ext"
# win32 needs to link in "just the right order" for some reason or
# ioctlsocket will be mapped to an [inverted] ruby specific version.
if RUBY_PLATFORM =~ /mingw|mswin/
makefile_contents = File.read "Makefile"
makefile_contents.gsub! "DLDFLAGS = ", "DLDFLAGS = -export-all "
makefile_contents.gsub! "LIBS = $(LIBRUBYARG_SHARED)", "LIBS = -lws2_32 $(LIBRUBYARG_SHARED)"
File.open("Makefile", "w") { |f| f.write makefile_contents }
end