[vlc-devel] [PATCH] contrib: libvpx: allow compiling on android

Vittorio Giovara vittorio.giovara at gmail.com
Fri Jun 13 21:08:28 CEST 2014


---
Here is the amended patch with the requested changes/comments.
Vittorio

 contrib/src/vpx/libvpx-mac.patch     |  6 ++++--
 contrib/src/vpx/libvpx-sysroot.patch | 31 +++++++++++++++++++++++++++++++
 contrib/src/vpx/rules.mak            | 12 +++++++++++-
 3 files changed, 46 insertions(+), 3 deletions(-)
 create mode 100644 contrib/src/vpx/libvpx-sysroot.patch

diff --git a/contrib/src/vpx/libvpx-mac.patch b/contrib/src/vpx/libvpx-mac.patch
index 9c1033c..ebb868a 100644
--- a/contrib/src/vpx/libvpx-mac.patch
+++ b/contrib/src/vpx/libvpx-mac.patch
@@ -4,12 +4,14 @@ VLC's contrib system is clever enough to detect this, but libvpx fails miserably
 diff -ru libvpx/build/make/configure.sh libvpx/build/make/configure.sh
 --- libvpx/build/make/configure.sh	2012-06-08 10:26:47.000000000 +0200
 +++ libvpx-fixed/build/make/configure.sh	2012-06-08 10:26:07.000000000 +0200
-@@ -628,6 +628,9 @@
+@@ -628,6 +628,11 @@
      if [ -d "/Developer/SDKs/MacOSX10.7.sdk" ]; then
          osx_sdk_dir="/Developer/SDKs/MacOSX10.7.sdk"
      fi
 +    if [ -d "${sdk_path}" ]; then
-+        osx_sdk_dir=${sdk_path}
++        case "${sdk_path}" in
++           darwin*) osx_sdk_dir=${sdk_path} ;;
++        esac
 +    fi
  
      case ${toolchain} in
diff --git a/contrib/src/vpx/libvpx-sysroot.patch b/contrib/src/vpx/libvpx-sysroot.patch
new file mode 100644
index 0000000..9b84338
--- /dev/null
+++ b/contrib/src/vpx/libvpx-sysroot.patch
@@ -0,0 +1,31 @@
+Our contrib system already passes the correct sysroot to the compiler, so there
+is no need to set an alternate libc path. If that path is empty the script will
+try to look for it in some fashion, but since the SDKROOT may be in a
+non standard location the look up may fail.
+
+This patch avoids that case and relies on the user configuration for the
+correct sysroot.
+
+See also https://code.google.com/p/webm/issues/detail?id=809
+
+diff --git a/build/make/configure.sh b/build/make/configure.sh
+index d4124c7..c420d25 100755
+--- a/build/make/configure.sh
++++ b/build/make/configure.sh
+@@ -939,8 +939,11 @@ EOF
+                           awk '{ print $1 }' | tail -1`
+             fi
+ 
+-            add_cflags "--sysroot=${alt_libc}"
+-            add_ldflags "--sysroot=${alt_libc}"
++            # this may happen if toolchain binaries are outside the ndk dir
++            if [ "${alt_libc}" ]; then
++                add_cflags "--sysroot=${alt_libc}"
++                add_ldflags "--sysroot=${alt_libc}"
++            fi
+ 
+             # linker flag that routes around a CPU bug in some
+             # Cortex-A8 implementations (NDK Dev Guide)
+-- 
+1.8.3.2
+
diff --git a/contrib/src/vpx/rules.mak b/contrib/src/vpx/rules.mak
index e9b0651..1d5cd1e 100644
--- a/contrib/src/vpx/rules.mak
+++ b/contrib/src/vpx/rules.mak
@@ -10,6 +10,7 @@ $(TARBALLS)/libvpx-$(VPX_VERSION).tar.bz2:
 
 libvpx: libvpx-$(VPX_VERSION).tar.bz2 .sum-vpx
 	$(UNPACK)
+	$(APPLY) $(SRC)/vpx/libvpx-sysroot.patch
 	$(APPLY) $(SRC)/vpx/libvpx-no-cross.patch
 	$(APPLY) $(SRC)/vpx/libvpx-mac.patch
 	$(MOVE)
@@ -38,7 +39,9 @@ else ifeq ($(ARCH),x86_64)
 VPX_ARCH := x86_64
 endif
 
-ifdef HAVE_LINUX
+ifdef HAVE_ANDROID
+VPX_OS := android
+else ifdef HAVE_LINUX
 VPX_OS := linux
 else ifdef HAVE_DARWIN_OS
 ifeq ($(ARCH),arm)
@@ -83,6 +86,13 @@ endif
 ifdef HAVE_IOS
 VPX_CONF += --sdk-path=$(SDKROOT)
 endif
+ifdef HAVE_ANDROID
+# vpx configure.sh overrides our sysroot and it looks for it itself, and
+# uses that path to look for the compiler (which we already know)
+VPX_CONF += --sdk-path=$(shell dirname $(shell which $(HOST)-gcc))
+# needed for cpu-features.h
+VPX_CONF += --extra-cflags="-I $(ANDROID_NDK)/sources/cpufeatures/"
+endif
 
 .vpx: libvpx
 	cd $< && CROSS=$(VPX_CROSS) ./configure --target=$(VPX_TARGET) \
-- 
1.8.3.2




More information about the vlc-devel mailing list