summaryrefslogtreecommitdiff
path: root/ext/socket/extconf.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-26 02:31:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-26 02:31:40 +0000
commita110d1782ef8a1f42654906248d5a0ba960dd0b7 (patch)
tree5b10da5d218776968491b92fa78db609ef0bbe42 /ext/socket/extconf.rb
parent28afe277a8e543da0e6353bdacbcad0b69739e06 (diff)
extconf.rb: fix warnings
* ext/socket/extconf.rb: fix warnings from IN6_IS_ADDR_ macros in apple's netinet6/in6.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/extconf.rb')
-rw-r--r--ext/socket/extconf.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 8740939..82f7562 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -497,5 +497,29 @@ if have_func(test_func)
$defs << "-DSOCKS"
end
end
+ hdr = "netinet6/in6.h"
+ if /darwin/ =~ RUBY_PLATFORM and !try_compile(<<"SRC", nil, :werror=>true)
+#include <netinet/in.h>
+int t(struct in6_addr *addr) {return IN6_IS_ADDR_UNSPECIFIED(addr);}
+SRC
+ print "fixing apple's netinet6/in6.rb ..."; $stdout.flush
+ in6 = File.read("/usr/include/#{hdr}")
+ if in6.gsub!(/\*\(const\s+__uint32_t\s+\*\)\(const\s+void\s+\*\)\(&(\(\w+\))->s6_addr\[(\d+)\]\)/) do
+ i, r = $2.to_i.divmod(4)
+ if r.zero?
+ "#$1->__u6_addr.__u6_addr32[#{i}]"
+ else
+ $&
+ end
+ end
+ FileUtils.mkdir_p(File.dirname(hdr))
+ open(hdr, "w") {|f| f.write(in6)}
+ $distcleanfiles << hdr
+ $distcleandirs << File.dirname(hdr)
+ puts "done"
+ else
+ puts "not needed"
+ end
+ end
create_makefile("socket")
end