diff --git a/tools/os_support.c b/tools/os_support.c
index 1ed89e6c85c4fde975c28a2bebedfcbbc8741a69..319c0fe2a23ed39324293fd3243feb21d1b0ccd3 100644
--- a/tools/os_support.c
+++ b/tools/os_support.c
@@ -23,6 +23,6 @@
 #ifdef __MINGW32__
 #include "mingw_support.c"
 #endif
-#ifdef __APPLE__
+#if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L
 #include "getline.c"
 #endif
diff --git a/tools/os_support.h b/tools/os_support.h
index 7dcbee4b3e508ecf8c6d50c6143f4f2ecffe0e15..5bf7add39cc5d4fdfcfa20cd4528d596c855b75e 100644
--- a/tools/os_support.h
+++ b/tools/os_support.h
@@ -28,7 +28,7 @@
 #include "mingw_support.h"
 #endif
 
-#ifdef __APPLE__
+#if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L
 #include "getline.h"
 #endif