From 618e60b32aae5f75361c37ac910dd6e257d2556c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lawrence=20Vel=C3=A1zquez?= <larryv@macports.org>
Date: Mon, 26 Jan 2015 23:26:24 -0500
Subject: [PATCH 14/16] libvpx: Fix Clang cross-building on OS X

The configure script doesn't really deal with Clang very well. When we
cross-compile on OS X (e.g., build i386 on x86_64), it thinks we're
using GCC and tries to invoke nonexistent executables like
"i386-apple-darwin14.0.0-gcc".

The proper solution might be to add new "*-darwin*-clang" build targets,
but for now, we'll mimic the toolchain setup used by iOS builds.
---
 .../P02-darwin-fix-clang-cross-building.patch      | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 contrib/libvpx/P02-darwin-fix-clang-cross-building.patch

diff --git a/contrib/libvpx/P02-darwin-fix-clang-cross-building.patch b/contrib/libvpx/P02-darwin-fix-clang-cross-building.patch
new file mode 100644
index 0000000..158bfc3
--- /dev/null
+++ b/contrib/libvpx/P02-darwin-fix-clang-cross-building.patch
@@ -0,0 +1,32 @@
+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
+@@ -1065,9 +1065,25 @@ EOF
+             gcc*)
+                 add_cflags -m${bits}
+                 add_ldflags -m${bits}
+-                link_with_cc=gcc
+                 tune_cflags="-march="
+-                setup_gnu_toolchain
++                case ${CC} in
++                    *clang*)
++                        XCRUN_FIND="xcrun --sdk macosx --find"
++                        AR="${AR:-$(${XCRUN_FIND} ar)}"
++                        AS="${AS:-$(${XCRUN_FIND} as)}"
++                        CC="${CC:-$(${XCRUN_FIND} clang)}"
++                        CXX="${CXX:-$(${XCRUN_FIND} clang++)}"
++                        LD="${LD:-$(${XCRUN_FIND} clang)}"
++                        NM="${NM:-$(${XCRUN_FIND} nm)}"
++                        RANLIB="${RANLIB:-$(${XCRUN_FIND} ranlib)}"
++                        STRIP="${STRIP:-$(${XCRUN_FIND} strip)}"
++                        AS_SFX=.s
++                        ;;
++                    *)
++                        link_with_cc=gcc
++                        setup_gnu_toolchain
++                        ;;
++                esac
+                 #for 32 bit x86 builds, -O3 did not turn on this flag
+                 enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer
+             ;;
-- 
2.3.0

