[vlc-devel] [PATCH] contrib: libvpx: allow compiling on android
Vittorio Giovara
vittorio.giovara at gmail.com
Thu Jun 12 21:10:06 CEST 2014
---
I was able to compile libvpx on android using the gcc toolchain directly with
the following modifications:
- apply the mac patch only on mac
- set the sdk as android sysroot because vpx configure.sh overrides it otherwise
- add on missing include path that the configure script is not able to find
Comments and improvement suggestions are welcome.
Cheers,
Vittorio
contrib/src/vpx/libvpx-mac.patch | 2 +-
contrib/src/vpx/libvpx-sysroot.patch | 21 +++++++++++++++++++++
contrib/src/vpx/rules.mak | 10 +++++++++-
3 files changed, 31 insertions(+), 2 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..b7b6c1d 100644
--- a/contrib/src/vpx/libvpx-mac.patch
+++ b/contrib/src/vpx/libvpx-mac.patch
@@ -8,7 +8,7 @@ diff -ru libvpx/build/make/configure.sh libvpx/build/make/configure.sh
if [ -d "/Developer/SDKs/MacOSX10.7.sdk" ]; then
osx_sdk_dir="/Developer/SDKs/MacOSX10.7.sdk"
fi
-+ if [ -d "${sdk_path}" ]; then
++ if [ -d "${sdk_path}" ] && [[ "${gcctarget}" = darwin* ]]; then
+ osx_sdk_dir=${sdk_path}
+ fi
diff --git a/contrib/src/vpx/libvpx-sysroot.patch b/contrib/src/vpx/libvpx-sysroot.patch
new file mode 100644
index 0000000..0da738e
--- /dev/null
+++ b/contrib/src/vpx/libvpx-sysroot.patch
@@ -0,0 +1,21 @@
+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..76cd59a 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,11 @@ endif
ifdef HAVE_IOS
VPX_CONF += --sdk-path=$(SDKROOT)
endif
+ifdef HAVE_ANDROID
+# vpx configure.sh overrides our sysroot
+VPX_CONF += --sdk-path=$(shell dirname $(shell which $(HOST)-gcc)) \
+ --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