-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·144 lines (121 loc) · 3.86 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
PLATFORMBASE="/Applications/Xcode.app/Contents/Developer/Platforms"
IOSSDKVERSION=6.1
PREFIX="`pwd`/build"
ARCHS=${ARCHS:-"armv7 i386"}
#ARCHS=i386
ARCHFAT="fat"
set -e
SCRIPT_DIR=$( (cd -P $(dirname $0) && pwd) )
DIST_DIR_BASE="$PREFIX/$IOSSDKVERSION"
if [ ! -d $SCRIPT_DIR/dist/ffmpeg ]
then
echo "ffmpeg source directory does not exist, run sync.sh"
exit 1
fi
export DEVROOT="$PLATFORMBASE/iPhoneOS.platform/Developer"
export SDKROOT="$DEVROOT/SDKs/iPhoneOS$IOSSDKVERSION.sdk"
for ARCH in $ARCHS
do
export PFX=$PREFIX/$IOSSDKVERSION/$ARCH
export pkg_config=/opt/local/bin/pkg-config
export PKG_CONFIG_PATH=$SDKROOT/usr/lib/pkgconfig:$DEVROOT/usr/lib/pkgconfig:$PFX/lib/pkgconfig
FFMPEG_DIR=$SCRIPT_DIR/dist/ffmpeg-$ARCH
if [ ! -d $FFMPEG_DIR ]
then
echo "Directory $FFMPEG_DIR does not exist, run sync.sh"
exit 1
fi
echo "Compiling source for $ARCH in directory $FFMPEG_DIR"
cd $FFMPEG_DIR
DIST_DIR="$DIST_DIR_BASE/$ARCH"
case $ARCH in
armv6)
EXTRA_FLAGS="--cpu=arm1176jzf-s"
EXTRA_CFLAGS=""
PLATFORM="${PLATFORMBASE}/iPhoneOS.platform"
IOSSDK=iPhoneOS${IOSSDKVERSION}
;;
armv7)
EXTRA_FLAGS="--cpu=cortex-a8 --enable-pic --enable-neon --enable-asm --enable-yasm"
EXTRA_CFLAGS="-mfpu=neon -I$DIST_DIR/include"
PLATFORM="${PLATFORMBASE}/iPhoneOS.platform"
IOSSDK=iPhoneOS${IOSSDKVERSION}
;;
i386)
EXTRA_FLAGS="--enable-pic"
EXTRA_CFLAGS=""
PLATFORM="${PLATFORMBASE}/iPhoneSimulator.platform"
IOSSDK=iPhoneSimulator${IOSSDKVERSION}
;;
*)
echo "Unsupported architecture ${ARCH}"
exit 1
;;
esac
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$PREFIX/$IOSSDKVERSION/$ARCH/include -L$PREFIX/$IOSSDKVERSION/$ARCH/lib -I$PREFIX/$IOSSDKVERSION/$ARCH/include -L$PREFIX/$IOSSDKVERSION/$ARCH/lib"
echo "Configuring ffmpeg for $ARCH (using $PREFIX/$IOSSDKVERSION/$ARCH path for external libraries)..."
./configure \
--enable-zlib \
--enable-version3 \
--enable-nonfree \
--enable-gpl \
--enable-libmp3lame \
--enable-libspeex \
--enable-libtheora \
--enable-libfaac \
--enable-libvorbis \
--enable-libaacplus \
--enable-libflite \
--enable-libfreetype \
--enable-libopus \
--disable-libx264 \
--enable-openssl \
--prefix=$DIST_DIR \
--enable-cross-compile --target-os=darwin --arch=$ARCH \
--extra-ldflags="-L${PLATFORM}/Developer/SDKs/${IOSSDK}.sdk/usr/lib/system -L$PREFIX/$IOSSDKVERSION/$ARCH/lib" \
--cross-prefix="${PLATFORM}/Developer/usr/bin/" \
--sysroot="${PLATFORM}/Developer/SDKs/${IOSSDK}.sdk" \
--disable-doc \
--disable-debug \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffserver \
--disable-ffprobe \
--disable-htmlpages \
--disable-manpages \
--disable-podpages \
--disable-txtpages \
--disable-programs \
--disable-decoder=h264,h264chroma,svq3 \
--disable-parser=h264,h264chroma \
--as="/usr/bin/gas-preprocessor.pl ${PLATFORM}/Applications/Xcode.app/Contents/Developer/usr/bin/as" \
--extra-ldflags="-arch $ARCH -L$PREFIX/$IOSSDKVERSION/$ARCH/lib" \
--extra-cflags="-arch $ARCH $EXTRA_CFLAGS" \
--extra-cxxflags="-arch $ARCH" \
$EXTRA_FLAGS
echo "Installing ffmpeg for $ARCH..."
make clean
make -j8 V=1
make install
cd $SCRIPT_DIR
if [ -d $DIST_DIR/bin ]
then
rm -rf $DIST_DIR/bin
fi
if [ -d $DIST_DIR/share ]
then
rm -rf $DIST_DIR/share
fi
done
# combine all
#echo "Combining architectures..."
#cd "$SCRIPT_DIR"
#$SCRIPT_DIR/combine.sh
#[ $? -eq 0 ] || {
# echo "Error while combining archs"
# exit 6
#}
# output the end result
#lipo -info $SHAREDLIBS/$IOSSDKVERSION/fat/lib/*
exit 0