From 60c6ce0f365da51149e0a22a5135040f25d2f87d Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Sun, 20 Aug 2017 00:22:22 +0100
Subject: [PATCH 08/19] Darwin: Look in ${sysroot}/usr/{lib,include} if sysroot
 is set

---
 setup.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 88cff6164d..40cd9ebd01 100644
--- a/setup.py
+++ b/setup.py
@@ -643,7 +643,13 @@ class PyBuildExt(build_ext):
         # lib_dirs and inc_dirs are used to search for files;
         # if a file is found in one of those directories, it can
         # be assumed that no additional -I,-L directives are needed.
-        if not cross_compiling:
+        # If we are using a macosx sysroot then ensure we look in
+        # sysroot/usr/{lib,include} (irrespective of whether we consider
+        # this cross_compiling or not).
+        if macosx_sdk_root() != '/':
+            lib_dirs = self.compiler.library_dirs + ['/usr/lib']
+            inc_dirs = self.compiler.include_dirs + ['/usr/include']
+        elif not cross_compiling:
             lib_dirs = self.compiler.library_dirs + system_lib_dirs
             inc_dirs = self.compiler.include_dirs + system_include_dirs
         else:
-- 
2.20.1

