--- ext/curses/extconf.rb.orig	2012-07-29 12:23:21.000000000 +1000
+++ ext/curses/extconf.rb	2021-02-10 10:06:50.000000000 +1100
@@ -9,9 +9,9 @@
 
 have_library("mytinfo", "tgetent") if /bow/ =~ RUBY_PLATFORM
 have_library("tinfo", "tgetent") or have_library("termcap", "tgetent")
-if have_header(*curses=%w"ncurses.h") and (have_library("ncursesw", "initscr") or have_library("ncurses", "initscr"))
+if have_header(*curses=%w"ncurses.h") and (have_library("ncursesw", "initscr", *curses=%w"ncurses.h") or have_library("ncurses", "initscr", *curses=%w"ncurses.h"))
   make=true
-elsif have_header(*curses=%w"ncurses/curses.h") and have_library("ncurses", "initscr")
+elsif have_header(*curses=%w"ncurses/curses.h") and have_library("ncurses", "initscr", *curses=%w"ncurses/curses.h")
   make=true
 elsif have_header(*curses=%w"curses_colr/curses.h") and have_library("cur_colr", "initscr")
   curses.unshift("varargs.h")
--- ext/dl/extconf.rb.orig	2010-02-26 09:49:20.000000000 +1100
+++ ext/dl/extconf.rb	2021-02-10 10:10:17.000000000 +1100
@@ -11,9 +11,9 @@
 check = true
 if( have_header("dlfcn.h") )
   have_library("dl")
-  check &&= have_func("dlopen")
-  check &&= have_func("dlclose")
-  check &&= have_func("dlsym")
+  check &&= have_func("dlopen", "dlfcn.h")
+  check &&= have_func("dlclose", "dlfcn.h")
+  check &&= have_func("dlsym", "dlfcn.h")
   have_func("dlerror")
 elsif( have_header("windows.h") )
   check &&= have_func("LoadLibrary")
--- ext/fiddle/extconf.rb.orig	2012-12-20 20:45:19.000000000 +1100
+++ ext/fiddle/extconf.rb	2021-02-10 10:14:09.000000000 +1100
@@ -23,10 +23,10 @@
   have_library "dl"
 
   %w{ dlopen dlclose dlsym }.each do |func|
-    abort "missing function #{func}" unless have_func(func)
+    abort "missing function #{func}" unless have_func(func, "dlfcn.h")
   end
 
-  have_func "dlerror"
+  have_func "dlerror", "dlfcn.h"
 elsif have_header "windows.h"
   %w{ LoadLibrary FreeLibrary GetProcAddress }.each do |func|
     abort "missing function #{func}" unless have_func(func)
--- ext/gdbm/extconf.rb.orig	2009-10-02 20:45:39.000000000 +1000
+++ ext/gdbm/extconf.rb	2021-02-10 10:16:00.000000000 +1100
@@ -1,7 +1,7 @@
 require 'mkmf'
 
 dir_config("gdbm")
-if have_library("gdbm", "gdbm_open") and
+if have_library("gdbm", "gdbm_open", "gdbm.h") and
    have_header("gdbm.h")
   create_makefile("gdbm")
 end
--- ext/psych/extconf.rb.orig	2012-08-08 06:50:05.000000000 +1000
+++ ext/psych/extconf.rb	2021-02-10 09:52:54.000000000 +1100
@@ -9,7 +9,7 @@
 end
 
 asplode('yaml.h')  unless find_header  'yaml.h'
-asplode('libyaml') unless find_library 'yaml', 'yaml_get_version'
+asplode('libyaml') unless have_library 'yaml', 'yaml_get_version', 'yaml.h'
 
 create_makefile 'psych'
 
--- ext/readline/extconf.rb.orig	2012-09-09 16:44:20.000000000 +1000
+++ ext/readline/extconf.rb	2021-02-10 10:30:55.000000000 +1100
@@ -30,7 +30,7 @@
 enable_libedit = enable_config("libedit")
 
 have_library("user32", nil) if /cygwin/ === RUBY_PLATFORM
-have_library("ncurses", "tgetnum") ||
+have_library("ncurses", "tgetnum", "ncurses.h") ||
   have_library("termcap", "tgetnum") ||
   have_library("curses", "tgetnum")
 
@@ -39,24 +39,24 @@
   # --enable-libedit
   unless (have_readline_header("editline/readline.h") ||
           have_readline_header("readline/readline.h")) &&
-          have_library("edit", "readline")
+          have_library("edit", "readline", "editline/readline.h")
     raise "libedit not found"
   end
 when false
   # --disable-libedit
   unless ((have_readline_header("readline/readline.h") &&
            have_readline_header("readline/history.h")) &&
-           have_library("readline", "readline"))
+           have_library("readline", "readline", "readline/readline.h"))
     raise "readline not found"
   end
 else
   # does not specify
   unless ((have_readline_header("readline/readline.h") &&
            have_readline_header("readline/history.h")) &&
-           (have_library("readline", "readline") ||
-            have_library("edit", "readline"))) ||
+           (have_library("readline", "readline", "readline/readline.h") ||
+            have_library("edit", "readline", "editline/readline.h"))) ||
             (have_readline_header("editline/readline.h") &&
-             have_library("edit", "readline"))
+             have_library("edit", "readline", "editline/readline.h"))
     raise "readline nor libedit not found"
   end
 end
--- ext/socket/extconf.rb.orig	2013-06-26 17:12:18.000000000 +1000
+++ ext/socket/extconf.rb	2021-02-10 10:43:54.000000000 +1100
@@ -125,7 +125,7 @@
   }
 end
 
-if have_func("sendmsg") | have_func("recvmsg")
+if have_func("sendmsg", "sys/socket.h") | have_func("recvmsg", "sys/socket.h")
   have_struct_member('struct msghdr', 'msg_control', ['sys/types.h', 'sys/socket.h'])
   have_struct_member('struct msghdr', 'msg_accrights', ['sys/types.h', 'sys/socket.h'])
 end
@@ -387,8 +387,8 @@
 end
 
 have_type("struct addrinfo", headers)
-have_func("freehostent")
-have_func("freeaddrinfo")
+have_func("freehostent", "netdb.h")
+have_func("freeaddrinfo", "netdb.h")
 if /haiku/ !~ RUBY_PLATFORM and have_func("gai_strerror")
   if checking_for("gai_strerror() returns const pointer") {!try_compile(<<EOF)}
 #{cpp_include(headers)}
@@ -434,14 +434,14 @@
   $defs << "-DGETADDRINFO_EMU"
 end
 
-have_func("inet_ntop") or have_func("inet_ntoa")
-have_func("inet_pton") or have_func("inet_aton")
-have_func("getservbyport")
+have_func("inet_ntop", "arpa/inet.h") or have_func("inet_ntoa", "arpa/inet.h")
+have_func("inet_pton", "arpa/inet.h") or have_func("inet_aton", "arpa/inet.h")
+have_func("getservbyport", "netdb.h")
 have_header("arpa/nameser.h")
 have_header("resolv.h")
 
 have_header("ifaddrs.h")
-have_func("getifaddrs")
+have_func("getifaddrs", "ifaddrs.h")
 have_header("sys/ioctl.h")
 have_header("sys/sockio.h")
 have_header("net/if.h", headers)
@@ -467,12 +467,12 @@
 have_type("struct sockcred", headers)
 have_type("struct cmsgcred", headers)
 
-have_func("getpeereid")
+have_func("getpeereid", "unistd.h")
 
 have_header("ucred.h", headers)
 have_func("getpeerucred")
 
-have_func("if_indextoname")
+have_func("if_indextoname", "net/if.h")
 
 have_type("struct ip_mreq", headers) # 4.4BSD
 have_type("struct ip_mreqn", headers) # Linux 2.4
@@ -483,12 +483,12 @@
 
 $distcleanfiles << "constants.h" << "constdefs.*"
 
-if have_func(test_func)
+if have_func(test_func, "sys/socket.h")
   have_func("hsterror")
-  have_func("getipnodebyname") or have_func("gethostbyname2")
-  have_func("socketpair") unless $defs.include?("-DHAVE_SOCKETPAIR")
-  unless have_func("gethostname")
-    have_func("uname")
+  have_func("getipnodebyname", "netdb.h") or have_func("gethostbyname2", "netdb.h")
+  have_func("socketpair", "sys/socket.h") unless $defs.include?("-DHAVE_SOCKETPAIR")
+  unless have_func("gethostname", "unistd.h")
+    have_func("uname", "sys/utsname.h")
   end
   if enable_config("socks", ENV["SOCKS_SERVER"])
     if have_library("socks5", "SOCKSinit")
--- ext/syslog/extconf.rb.orig	2009-10-02 22:04:37.000000000 +1000
+++ ext/syslog/extconf.rb	2021-02-10 10:47:48.000000000 +1100
@@ -4,7 +4,7 @@
 require 'mkmf'
 
 have_header("syslog.h") &&
-  have_func("openlog") &&
-  have_func("setlogmask") &&
+  have_func("openlog", "syslog.h") &&
+  have_func("setlogmask", "syslog.h") &&
   create_makefile("syslog")
 
--- ext/zlib/extconf.rb.orig	2012-11-08 19:34:18.000000000 +1100
+++ ext/zlib/extconf.rb	2021-02-10 10:49:26.000000000 +1100
@@ -10,7 +10,7 @@
 dir_config 'zlib'
 
 
-if %w'z libz zlib1 zlib zdll zlibwapi'.find {|z| have_library(z, 'deflateReset')} and
+if %w'z libz zlib1 zlib zdll zlibwapi'.find {|z| have_library(z, 'deflateReset', 'zlib.h')} and
     have_header('zlib.h') then
 
   defines = []
--- missing/finite.c.orig	2010-07-28 18:12:01.000000000 +1000
+++ missing/finite.c	2021-02-12 19:52:53.000000000 +1100
@@ -1,6 +1,7 @@
 /* public domain rewrite of finite(3) */
 
 #include "ruby/missing.h"
+#include <math.h>
 
 int
 finite(double n)
