-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ipopov89
committed
May 28, 2014
1 parent
794e07c
commit 1062bcd
Showing
2 changed files
with
245 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
#!/bin/sh | ||
|
||
# directories | ||
SOURCE="ffmpeg-2.2.2" | ||
FAT="FFmpeg-iOS" | ||
|
||
SCRATCH="scratch" | ||
# must be an absolute path | ||
THIN=`pwd`/"thin" | ||
|
||
# absolute path to x264 library | ||
X264=`pwd`/fat-x264 | ||
|
||
CONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \ | ||
--disable-doc --enable-pic" | ||
|
||
if [ "$X264" ] | ||
then | ||
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-gpl --enable-libx264" | ||
fi | ||
|
||
# avresample | ||
#CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample" | ||
|
||
ARCHS="arm64 armv7s armv7 i386" | ||
|
||
COMPILE="y" | ||
LIPO="y" | ||
|
||
DEPLOYMENT_TARGET="6.0" | ||
|
||
if [ "$*" ] | ||
then | ||
if [ "$*" = "lipo" ] | ||
then | ||
# skip compile | ||
COMPILE= | ||
else | ||
ARCHS="$*" | ||
if [ $# -eq 1 ] | ||
then | ||
# skip lipo | ||
LIPO= | ||
fi | ||
fi | ||
fi | ||
|
||
if [ "$COMPILE" ] | ||
then | ||
if [ ! `which yasm` ] | ||
then | ||
echo 'Yasm not found' | ||
if [ ! `which brew` ] | ||
then | ||
echo 'Homebrew not found. Trying to install...' | ||
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" \ | ||
|| exit 1 | ||
fi | ||
echo 'Trying to install Yasm...' | ||
brew install yasm || exit 1 | ||
fi | ||
if [ ! `which gas-preprocessor.pl` ] | ||
then | ||
echo 'gas-preprocessor.pl not found. Trying to install...' | ||
(curl -3L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl \ | ||
-o /usr/local/bin/gas-preprocessor.pl \ | ||
&& chmod +x /usr/local/bin/gas-preprocessor.pl) \ | ||
|| exit 1 | ||
fi | ||
|
||
if [ ! -r $SOURCE ] | ||
then | ||
echo 'FFmpeg source not found. Trying to download...' | ||
curl http://www.ffmpeg.org/releases/$SOURCE.tar.bz2 | tar xj \ | ||
|| exit 1 | ||
fi | ||
|
||
CWD=`pwd` | ||
for ARCH in $ARCHS | ||
do | ||
echo "building $ARCH..." | ||
mkdir -p "$SCRATCH/$ARCH" | ||
cd "$SCRATCH/$ARCH" | ||
|
||
CFLAGS="-arch $ARCH" | ||
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ] | ||
then | ||
PLATFORM="iPhoneSimulator" | ||
CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET" | ||
else | ||
PLATFORM="iPhoneOS" | ||
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET" | ||
if [ "$ARCH" = "arm64" ] | ||
then | ||
EXPORT="GASPP_FIX_XCODE5=1" | ||
fi | ||
fi | ||
|
||
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'` | ||
CC="xcrun -sdk $XCRUN_SDK clang" | ||
CXXFLAGS="$CFLAGS" | ||
LDFLAGS="$CFLAGS" | ||
if [ "$X264" ] | ||
then | ||
CFLAGS="$CFLAGS -I$X264/include" | ||
LDFLAGS="$LDFLAGS -L$X264/lib" | ||
fi | ||
|
||
$CWD/$SOURCE/configure \ | ||
--target-os=darwin \ | ||
--arch=$ARCH \ | ||
--cc="$CC" \ | ||
$CONFIGURE_FLAGS \ | ||
--extra-cflags="$CFLAGS" \ | ||
--extra-cxxflags="$CXXFLAGS" \ | ||
--extra-ldflags="$LDFLAGS" \ | ||
--prefix="$THIN/$ARCH" \ | ||
|| exit 1 | ||
|
||
make -j3 install $EXPORT || exit 1 | ||
cd $CWD | ||
done | ||
fi | ||
|
||
if [ "$LIPO" ] | ||
then | ||
echo "building fat binaries..." | ||
mkdir -p $FAT/lib | ||
set - $ARCHS | ||
CWD=`pwd` | ||
cd $THIN/$1/lib | ||
for LIB in *.a | ||
do | ||
cd $CWD | ||
echo lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB 1>&2 | ||
lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB || exit 1 | ||
done | ||
|
||
cd $CWD | ||
cp -rf $THIN/$1/include $FAT | ||
fi | ||
|
||
echo Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/sh | ||
|
||
CONFIGURE_FLAGS="--enable-static --enable-pic --disable-cli --disable-asm" | ||
|
||
ARCHS="arm64 armv7s i386 armv7" | ||
|
||
# directories | ||
SOURCE="x264" | ||
FAT="fat-x264" | ||
|
||
SCRATCH="scratch-x264" | ||
# must be an absolute path | ||
THIN=`pwd`/"thin-x264" | ||
|
||
COMPILE="y" | ||
LIPO="y" | ||
|
||
if [ "$*" ] | ||
then | ||
if [ "$*" = "lipo" ] | ||
then | ||
# skip compile | ||
COMPILE= | ||
else | ||
ARCHS="$*" | ||
if [ $# -eq 1 ] | ||
then | ||
# skip lipo | ||
LIPO= | ||
fi | ||
fi | ||
fi | ||
|
||
if [ "$COMPILE" ] | ||
then | ||
CWD=`pwd` | ||
for ARCH in $ARCHS | ||
do | ||
echo "building $ARCH..." | ||
mkdir -p "$SCRATCH/$ARCH" | ||
cd "$SCRATCH/$ARCH" | ||
|
||
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ] | ||
then | ||
PLATFORM="iPhoneSimulator" | ||
CPU= | ||
if [ "$ARCH" = "x86_64" ] | ||
then | ||
SIMULATOR="-mios-simulator-version-min=7.0" | ||
HOST= | ||
else | ||
SIMULATOR="-mios-simulator-version-min=5.0" | ||
HOST="--host=i386-apple-darwin" | ||
fi | ||
else | ||
PLATFORM="iPhoneOS" | ||
if [ $ARCH = "armv7s" ] | ||
then | ||
CPU="--cpu=swift" | ||
else | ||
CPU= | ||
fi | ||
SIMULATOR= | ||
HOST="--host=arm-apple-darwin" | ||
fi | ||
|
||
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'` | ||
CC="xcrun -sdk $XCRUN_SDK clang -Wno-error=unused-command-line-argument-hard-error-in-future" | ||
AS="$CWD/$SOURCE/extras/gas-preprocessor.pl $CC" | ||
CFLAGS="-arch $ARCH $SIMULATOR" | ||
CXXFLAGS="$CFLAGS" | ||
LDFLAGS="$CFLAGS" | ||
|
||
CC=$CC $CWD/$SOURCE/configure \ | ||
$CONFIGURE_FLAGS \ | ||
$HOST \ | ||
$CPU \ | ||
--extra-cflags="$CFLAGS" \ | ||
--extra-ldflags="$LDFLAGS" \ | ||
--prefix="$THIN/$ARCH" | ||
|
||
make -j3 install | ||
cd $CWD | ||
done | ||
fi | ||
|
||
if [ "$LIPO" ] | ||
then | ||
echo "building fat binaries..." | ||
mkdir -p $FAT/lib | ||
set - $ARCHS | ||
CWD=`pwd` | ||
cd $THIN/$1/lib | ||
for LIB in *.a | ||
do | ||
cd $CWD | ||
lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB | ||
done | ||
|
||
cd $CWD | ||
cp -rf $THIN/$1/include $FAT | ||
fi |