From 349395bce34781a06b7560e3aa136e9736804c45 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 10/15] 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 33cecc6875..94396bf324 100644
--- a/setup.py
+++ b/setup.py
@@ -517,7 +517,13 @@ class PyBuildExt(build_ext):
         # be assumed that no additional -I,-L directives are needed.
         inc_dirs = self.compiler.include_dirs[:]
         lib_dirs = self.compiler.library_dirs[:]
-        if not cross_compiling:
+        # If we are using a macosx sysroot then ensure we look in
+        # sysroot/usr/{lib,include} (irrespective of whether we condider
+        # this cross_compiling or not).
+        if macosx_sdk_root() != '/':
+            add_dir_to_list(lib_dirs, '/usr/lib')
+            add_dir_to_list(inc_dirs, '/usr/include')
+        elif not cross_compiling:
             for d in (
                 '/usr/include',
                 ):
-- 
2.19.1

