From ebe2db65e27291595e2ef2f9a5ab444bcc212f23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lawrence=20Vel=C3=A1zquez?= <larryv@macports.org>
Date: Fri, 23 Jan 2015 22:54:00 -0500
Subject: [PATCH 13/16] libvpx: Fix discovery of Darwin SDKs

Adapted from upstream:
https://chromium.googlesource.com/webm/libvpx/+/ad314c1%5E%21/
---
 contrib/libvpx/P01-darwin-fix-sdk-detection.patch | 51 +++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 contrib/libvpx/P01-darwin-fix-sdk-detection.patch

diff --git a/contrib/libvpx/P01-darwin-fix-sdk-detection.patch b/contrib/libvpx/P01-darwin-fix-sdk-detection.patch
new file mode 100644
index 0000000..2f3b62f
--- /dev/null
+++ b/contrib/libvpx/P01-darwin-fix-sdk-detection.patch
@@ -0,0 +1,51 @@
+Index: libvpx-v1.3.0/build/make/configure.sh
+===================================================================
+--- libvpx-v1.3.0.orig/build/make/configure.sh
++++ libvpx-v1.3.0/build/make/configure.sh
+@@ -595,6 +595,13 @@ setup_gnu_toolchain() {
+         EXE_SFX=
+ }
+ 
++# Reliably find the newest available Darwin SDKs. (Older versions of
++# xcrun don't support --show-sdk-path.)
++show_darwin_sdk_path() {
++    xcrun --sdk $1 --show-sdk-path 2>/dev/null ||
++        xcodebuild -sdk $1 -version Path 2>/dev/null
++}
++
+ process_common_toolchain() {
+     if [ -z "$toolchain" ]; then
+         gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
+@@ -717,28 +724,14 @@ process_common_toolchain() {
+     # platforms, so find the newest SDK available.
+     case ${toolchain} in
+         *-darwin*)
+-            if [ -z "${DEVELOPER_DIR}" ]; then
+-                DEVELOPER_DIR=`xcode-select -print-path 2> /dev/null`
+-                [ $? -ne 0 ] && OSX_SKIP_DIR_CHECK=1
+-            fi
+-            if [ -z "${OSX_SKIP_DIR_CHECK}" ]; then
+-                OSX_SDK_ROOTS="${DEVELOPER_DIR}/SDKs"
+-                OSX_SDK_VERSIONS="MacOSX10.4u.sdk MacOSX10.5.sdk MacOSX10.6.sdk"
+-                OSX_SDK_VERSIONS="${OSX_SDK_VERSIONS} MacOSX10.7.sdk"
+-                for v in ${OSX_SDK_VERSIONS}; do
+-                    if [ -d "${OSX_SDK_ROOTS}/${v}" ]; then
+-                        osx_sdk_dir="${OSX_SDK_ROOTS}/${v}"
+-                    fi
+-                done
++            osx_sdk_dir="$(show_darwin_sdk_path macosx)"
++            if [ -d "${osx_sdk_dir}" ]; then
++                add_cflags  "-isysroot ${osx_sdk_dir}"
++                add_ldflags "-isysroot ${osx_sdk_dir}"
+             fi
+             ;;
+     esac
+ 
+-    if [ -d "${osx_sdk_dir}" ]; then
+-        add_cflags  "-isysroot ${osx_sdk_dir}"
+-        add_ldflags "-isysroot ${osx_sdk_dir}"
+-    fi
+-
+     case ${toolchain} in
+         *-darwin8-*)
+             add_cflags  "-mmacosx-version-min=10.4"
-- 
2.3.0

