首先,
创建文件夹build-patches,添加两个文件libvpx-configure.sh.patch和libvpx-gen_asm_deps.sh.patch,文件内容如下:
libvpx-configure.sh.patch文件内容
--- build/src/libvpx-v1.1.0/build/make/configure.sh.orig 2012-05-08 16:14:00.000000000 -0700
+++ build/src/libvpx-v1.1.0/build/make/configure.sh 2012-10-29 13:40:35.000000000 -0700
@@ -844,7 +844,7 @@
add_ldflags -arch_only ${tgt_isa}
if [ -z "${alt_libc}" ]; then
- alt_libc=${SDK_PATH}/SDKs/iPhoneOS5.1.sdk
+ alt_libc=${SDK_PATH}/SDKs/iPhoneOS6.1.sdk
fi
add_cflags "-isysroot ${alt_libc}"
libvpx-gen_asm_deps.sh.patch文件内容
--- build/src/libvpx-v1.1.0/build/make/gen_asm_deps.sh.orig 2012-05-08 16:14:00.000000000 -0700
+++ build/src/libvpx-v1.1.0/build/make/gen_asm_deps.sh 2012-10-29 13:25:25.000000000 -0700
@@ -42,7 +42,7 @@
[ -n "$srcfile" ] || show_help
sfx=${sfx:-asm}
-includes=$(LC_ALL=C egrep -i "include +\"?+[a-z0-9_/]+\.${sfx}" $srcfile |
+includes=$(LC_ALL=C egrep -i "include +\"+[a-z0-9_/]+\.${sfx}" $srcfile |
perl -p -e "s;.*?([a-z0-9_/]+.${sfx}).*;\1;")
#" restore editor state
for inc in ${includes}; do
创建脚本build-libvpx.sh,脚本如下:
#!/bin/bash
# Builds libvpx for iPhone targets: iPhoneSimulator-i386,
# iPhoneOS-armv7.
#
# Copyright 2012 Mike Tigas <mike@tig.as>
#
# Based on work by Felix Schulze on 16.12.10.
# Copyright 2010 Felix Schulze. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
# Choose your libvpx version and your currently-installed iOS SDK version:
#
VERSION="1.1.0"
SDKVERSION="6.1"
#
#
###########################################################################
#
# Don't change anything under this line!
#
###########################################################################
# No need to change this since xcode build will only compile in the
# necessary bits from the libraries we create
ARCHS="i386 armv7"
DEVELOPER=`xcode-select -print-path`
cd "`dirname \"$0\"`"
REPOROOT=$(pwd)
# Where we'll end up storing things in the end
OUTPUTDIR="${REPOROOT}/dependencies"
mkdir -p ${OUTPUTDIR}/include
mkdir -p ${OUTPUTDIR}/lib
mkdir -p ${OUTPUTDIR}/bin
BUILDDIR="${REPOROOT}/build"
# where we will keep our sources and build from.
SRCDIR="${BUILDDIR}/src"
mkdir -p $SRCDIR
# where we will store intermediary builds
INTERDIR="${BUILDDIR}/built"
mkdir -p $INTERDIR
########################################
cd $SRCDIR
# Exit the script if an error happens
set -e
if [ ! -e "${SRCDIR}/libvpx-v${VERSION}.tar.bz2" ]; then
echo "Downloading libvpx-v${VERSION}.tar.bz2"
curl -LO http://webm.googlecode.com/files/libvpx-v${VERSION}.tar.bz2
else
echo "Using libvpx-v${VERSION}.tar.bz2"
fi
tar zxf libvpx-v${VERSION}.tar.bz2 -C $SRCDIR
cd "${SRCDIR}/libvpx-v${VERSION}"
patch -p3 < ../../../build-patches/libvpx-configure.sh.patch
patch -p3 < ../../../build-patches/libvpx-gen_asm_deps.sh.patch
set +e # don't bail out of bash script if ccache doesn't exist
CCACHE=`which ccache`
if [ $? == "0" ]; then
echo "Building with ccache: $CCACHE"
CCACHE="${CCACHE} "
else
echo "Building without ccache"
CCACHE=""
fi
set -e # back to regular "bail out on error" mode
for ARCH in ${ARCHS}
do
if [ "${ARCH}" == "i386" ];
then
PLATFORM="iPhoneSimulator"
EXTRA_CONFIG="--target=x86-darwin12-gcc"
else
PLATFORM="iPhoneOS"
EXTRA_CONFIG="--target=armv7-darwin-gcc"
fi
mkdir -p "${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
./configure --disable-shared --enable-static --enable-pic ${EXTRA_CONFIG} \
--prefix="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" \
--sdk-path="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" \
# Build the application and install it to the fake SDK intermediary dir
# we have set up. Make sure to clean up afterward because we will re-use
# this source tree to cross-compile other targets.
make -j2
make install
make clean
done
########################################
echo "Build library..."
# These are the libs that comprise libvpx.
OUTPUT_LIBS="libvpx.a"
for OUTPUT_LIB in ${OUTPUT_LIBS}; do
INPUT_LIBS=""
for ARCH in ${ARCHS}; do
if [ "${ARCH}" == "i386" ];
then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
fi
INPUT_ARCH_LIB="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/lib/${OUTPUT_LIB}"
if [ -e $INPUT_ARCH_LIB ]; then
INPUT_LIBS="${INPUT_LIBS} ${INPUT_ARCH_LIB}"
fi
done
# Combine the three architectures into a universal library.
if [ -n "$INPUT_LIBS" ]; then
lipo -create $INPUT_LIBS \
-output "${OUTPUTDIR}/lib/${OUTPUT_LIB}"
else
echo "$OUTPUT_LIB does not exist, skipping (are the dependencies installed?)"
fi
done
for ARCH in ${ARCHS}; do
if [ "${ARCH}" == "i386" ];
then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
fi
cp -R ${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/include/* ${OUTPUTDIR}/include/
if [ $? == "0" ]; then
# We only need to copy the headers over once. (So break out of forloop
# once we get first success.)
break
fi
done
for ARCH in ${ARCHS}; do
if [ "${ARCH}" == "i386" ];
then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
fi
cp -R ${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/bin/* ${OUTPUTDIR}/bin/
if [ $? == "0" ]; then
# We only need to copy the binaries over once. (So break out of forloop
# once we get first success.)
break
fi
done
####################
echo "Building done."
echo "Cleaning up..."
rm -fr ${INTERDIR}
rm -fr "${SRCDIR}/libvpx-v${VERSION}"
echo "Done."
运行脚本即可编译成功,注意libvpx版本和xcodeSDK版本。