aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-04 17:38:28 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-04 17:38:28 +0900
commitcb18deee7285dde67102c9702796d7eba0046af5 (patch)
tree6ea66bcfa353881978987b343d0f654b78b9ed10
parent7e3af23d1d66ec02da74a23cce1262af395064f9 (diff)
downloadruby-cb18deee7285dde67102c9702796d7eba0046af5.tar.gz
Substitute from the actual netinet6/in6.h
Xcode no longer links the system include files directory to `/usr`. Extract the actual header file path from cpp output.
-rw-r--r--ext/socket/extconf.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index b70a862414..8998bb5c2f 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -655,12 +655,20 @@ EOS
end
hdr = "netinet6/in6.h"
- if /darwin/ =~ RUBY_PLATFORM and !try_compile(<<"SRC", nil, :werror=>true)
+ /darwin/ =~ RUBY_PLATFORM and
+ checking_for("if apple's #{hdr} needs s6_addr patch") {!try_compile(<<"SRC", nil, :werror=>true)} and
#include <netinet/in.h>
int t(struct in6_addr *addr) {return IN6_IS_ADDR_UNSPECIFIED(addr);}
SRC
- print "fixing apple's netinet6/in6.h ..."; $stdout.flush
- in6 = File.read("/usr/include/#{hdr}")
+ checking_for("fixing apple's #{hdr}", "%s") do
+ file = xpopen(%w"clang -include netinet/in.h -E -xc -", in: IO::NULL) do |f|
+ re = %r[^# *\d+ *"(.*/netinet/in\.h)"]
+ Logging.message " grep(#{re})\n"
+ f.read[re, 1]
+ end
+ Logging.message "Substitute from #{file}\n"
+
+ in6 = File.read(file)
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?
@@ -673,9 +681,9 @@ SRC
open(hdr, "w") {|f| f.write(in6)}
$distcleanfiles << hdr
$distcleandirs << File.dirname(hdr)
- puts "done"
+ "done"
else
- puts "not needed"
+ "not needed"
end
end
create_makefile("socket")