diff -ur ../ruby-1.8.7-p374.org/configure ./configure
--- ../ruby-1.8.7-p374.org/configure	2013-06-27 20:57:43.000000000 +0900
+++ ./configure	2021-01-08 22:00:02.000000000 +0900
@@ -9103,6 +9103,9 @@
 /* end confdefs.h.  */
 
 #include <time.h>
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
 
 void
 check(tm, y, m, d, h, s)
@@ -9910,6 +9913,12 @@
 /* end confdefs.h.  */
 
 #include <stdio.h>
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #ifndef SEEK_SET
 #define SEEK_SET 0
 #endif
@@ -10296,6 +10305,9 @@
 /* Test for whether ELF binaries are produced */
 #include <fcntl.h>
 #include <stdlib.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 main() {
 	char buffer[4];
 	int i=open("conftest",O_RDONLY);
Only in .: configure.orig
diff -ur ../ruby-1.8.7-p374.org/eval.c ./eval.c
--- ../ruby-1.8.7-p374.org/eval.c	2012-06-29 21:31:25.000000000 +0900
+++ ./eval.c	2021-01-08 22:00:02.000000000 +0900
@@ -7264,6 +7264,8 @@
     rb_provide_feature(rb_str_new2(feature));
 }
 
+int rb_thread_join _((VALUE, double));
+
 static char *
 load_lock(ftptr)
     const char *ftptr;
@@ -11524,7 +11526,6 @@
 }
 
 static int rb_thread_join0 _((rb_thread_t, double));
-int rb_thread_join _((VALUE, double));
 
 static int
 rb_thread_join0(th, limit)
diff -ur ../ruby-1.8.7-p374.org/ext/pty/pty.c ./ext/pty/pty.c
--- ../ruby-1.8.7-p374.org/ext/pty/pty.c	2008-04-15 12:35:55.000000000 +0900
+++ ./ext/pty/pty.c	2021-01-08 22:00:02.000000000 +0900
@@ -21,6 +21,8 @@
 #define WIFSTOPPED(status)    (((status) & 0xff) == 0x7f)
 #endif
 #include <ctype.h>
+int	openpty(int *, int *, char *, struct termios *,
+		     struct winsize *);
 
 #include "ruby.h"
 #include "rubyio.h"
diff -ur ../ruby-1.8.7-p374.org/main.c ./main.c
--- ../ruby-1.8.7-p374.org/main.c	2007-02-13 08:01:19.000000000 +0900
+++ ./main.c	2021-01-08 22:03:54.000000000 +0900
@@ -26,7 +26,12 @@
 
 /* to link startup code with ObjC support */
 #if (defined(__APPLE__) || defined(__NeXT__)) && defined(__MACH__)
+#include <objc/message.h>
+#if (defined(OBJC_OLD_DISPATCH_PROTOTYPES) && !OBJC_OLD_DISPATCH_PROTOTYPES)
 static void objcdummyfunction( void ) { objc_msgSend(); }
+#else
+static void objcdummyfunction( void ) { objc_msgSend(NULL, NULL); }
+#endif
 #endif
 
 int
--- missing/finite.c.orig	2007-02-13 10:01:19.000000000 +1100
+++ missing/finite.c	2021-02-12 19:47:16.000000000 +1100
@@ -1,5 +1,7 @@
 /* public domain rewrite of finite(3) */
 
+#include <math.h>
+
 int
 finite(n)
     double n;
--- ext/tk/tcltklib.c.orig	2008-05-23 14:22:13.000000000 +0900
+++ ext/tk/tcltklib.c	2021-10-20 22:20:26.000000000 +0900
@@ -7,6 +7,7 @@
 #define TCLTKLIB_RELEASE_DATE "2008-05-23"
 
 #include "ruby.h"
+extern VALUE rb_proc_new _((VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE));
 
 #ifdef RUBY_VM
 /* #include "ruby/ruby.h" */
--- ext/tk/tkutil/tkutil.c.orig	2008-05-23 14:22:13.000000000 +0900
+++ ext/tk/tkutil/tkutil.c	2021-10-20 22:29:18.000000000 +0900
@@ -59,6 +59,10 @@
 
 /*************************************/
 
+#ifdef HAVE_RB_OBJ_INSTANCE_EXEC
+VALUE rb_obj_instance_exec(int argc, VALUE *argv, VALUE self);
+#endif
+
 static VALUE
 tk_s_new(argc, argv, klass)
     int argc;
