# Define NO_TFO on macOS < 10.11
# See: https://github.com/folkertvanheusden/HTTPing/pull/22

--- gen.h.orig
+++ gen.h
@@ -34,6 +34,13 @@
 #define gettext(x) (x)
 #endif
 
+#ifdef __APPLE__
+#include <AvailabilityMacros.h>
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101100
+#define NO_TFO
+#endif
+#endif
+
 typedef struct
 {
 	double cur, min, avg, max, sd, med;
--- help.c.orig
+++ help.c
@@ -71,7 +71,9 @@ void version(void)
 #endif
 #endif
 
+#ifndef NO_TFO
 	fprintf(stderr, gettext(" * TFO (TCP fast open) support included (-F)\n"));
+#endif
 	fprintf(stderr, gettext("\n"));
 }
 
@@ -207,7 +209,9 @@ void usage(const char *me)
 	format_help("-r", "--resolve-once", gettext("resolve hostname only once (useful when pinging roundrobin DNS: also takes the first DNS lookup out of the loop so that the first measurement is also correct)"));
 	format_help("-W", NULL, gettext("do not abort the program if resolving failed: keep retrying"));
 	format_help("-y x", "--bind-to", gettext("bind to an ip-address (and thus interface) with an optional port"));
+#ifndef NO_TFO
 	format_help("-F", "--tcp-fast-open", gettext("\"TCP fast open\" (TFO), reduces the latency of TCP connects"));
+#endif
 #ifdef linux
 	format_help(NULL, "--priority", gettext("set priority of packets"));
 #endif
--- main.c.orig
+++ main.c
@@ -1396,7 +1396,11 @@ int main(int argc, char *argv[])
 				break;
 
 			case 'F':
+#ifdef NO_TFO
+                fprintf(stderr, gettext("Warning: TCP TFO is not supported. Disabling.\n"));
+#else
 				use_tfo = 1;
+#endif
 				break;
 
 			case 22:
@@ -2157,7 +2161,7 @@ int main(int argc, char *argv[])
 #if defined(linux) || defined(__FreeBSD__)
 			if (getsockopt(fd, IPPROTO_TCP, TCP_INFO, &info, &info_len) == 0)
 			{
-#ifdef TCPI_OPT_SYN_DATA
+#if defined(TCPI_OPT_SYN_DATA) && !defined(NO_TFO)
 				if (info.tcpi_options & TCPI_OPT_SYN_DATA)
 					tfo_success = 1;
 #endif
@@ -2345,8 +2349,10 @@ int main(int argc, char *argv[])
 #endif
 				}
 
+#ifndef NO_TFO
 				if (tfo_success)
 					str_add(&line, " F");
+#endif
 
 #if HAVE_NCURSES
 				if (ncurses_mode)
--- tcp.c.orig
+++ tcp.c
@@ -159,6 +159,12 @@ int connect_to(int fd, struct addrinfo *ai, double timeout, char *tfo, char *msg
 	to.tv_usec = (long)(timeout * 1000.0) % 1000000;
 
 	/* connect to peer */
+#ifdef NO_TFO
+	(void)tfo;
+	(void)msg;
+	(void)msg_len;
+	(void)msg_accepted;
+#else
 	if (tfo && *tfo)
 	{
 #if defined(__FreeBSD__)
@@ -182,6 +188,7 @@ int connect_to(int fd, struct addrinfo *ai, double timeout, char *tfo, char *msg
 		}
 	}
 	else
+#endif
 	{
 		int rc = -1;
 
