forked from FFmpeg/FFmpeg
-
Notifications
You must be signed in to change notification settings - Fork 97
/
build_ios.sh
executable file
·273 lines (252 loc) · 7.62 KB
/
build_ios.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#!/bin/bash
echo " _ __ _ __ _ "
echo " | | / / (_) / /_ ____ _ ____ ___ (_) ___ "
echo " | | / / / / / __/ / __ \/ / __ __ \ / / / __ \ "
echo " | |/ / / / / /_ / /_/ / / / / / / / / / / /_/ / "
echo " |___/ /_/ \__/ \____/ /_/ /_/ /_/ /_/ \____/ "
[[ ! -e $HOME/build_ios_local.sh ]] && {
echo "File \"$HOME/build_ios_local.sh\" not found! Pls see 'build_ios_local.sh.sample'!!" 2>&1
exit 1;
}
source $HOME/build_ios_local.sh
pwd | grep -q '[[:blank:]]' && {
echo "Source path: $(pwd)"
echo "Out of tree builds are impossible with whitespace in source path."
exit 1;
}
selfname=$0
DEST=`pwd`/build/ios
SOURCE=`pwd`
SSL=${SOURCE}/../opensslmirror/build/ios
SSLINCLUDE=${SSL}/release/universal/include
SSLLIBS=${SSL}/release/universal/lib
RTMP=${SOURCE}/../rtmpdump/build/ios/built
RTMPINCLUDE=${RTMP}/release/universal/include
RTMPLIBS=${RTMP}/release/universal/lib
export DEVRootReal="${DEVELOPER}/Platforms/iPhoneOS.platform/Developer"
export SDKRootReal="${DEVRootReal}/SDKs/iPhoneOS${SDKVERSION}.sdk"
export DEVRootSimulator="${DEVELOPER}/Platforms/iPhoneSimulator.platform/Developer"
export SDKRootSimulator="${DEVRootSimulator}/SDKs/iPhoneSimulator${SDKVERSION}.sdk"
export PATH=$HOME/bin:$PATH
export CCACHE=; type ccache >/dev/null 2>&1 && export CCACHE=ccache
export PKG_CONFIG_LIBDIR=${SSLLIBS}/pkgconfig:${RTMPLIBS}/pkgconfig
function die()
{
kill $$
exit 1; exit 1; exit 1; exit 1;
}
function doConfigureOnline()
{
./configure \
--prefix=${DIST} \
\
--enable-version3 \
\
--disable-shared \
--disable-small \
--disable-runtime-cpudetect \
\
--disable-programs \
--disable-doc \
--enable-swscale \
--disable-avresample \
--enable-network \
\
--disable-everything \
--disable-muxers \
--enable-muxer=mp4 \
--enable-filters \
--enable-parsers \
--disable-parser=hevc \
--enable-protocol=file \
--enable-protocol=http \
--enable-protocol=rtmp \
--enable-protocol=rtp \
--enable-demuxer=hls \
--enable-demuxer=mpegts \
--enable-demuxer=mpegtsraw \
--enable-demuxer=mpegvideo \
--enable-demuxer=concat \
--enable-demuxer=mov \
--enable-demuxer=flv \
--enable-demuxer=rtsp \
--enable-demuxer=mp3 \
--enable-demuxer=matroska \
--enable-decoder=mpeg4 \
--enable-decoder=mpegvideo \
--enable-decoder=mpeg1video \
--enable-decoder=mpeg2video \
--enable-decoder=h264 \
--enable-decoder=h263 \
--enable-decoder=flv \
--enable-decoder=aac \
--enable-decoder=ac3 \
--enable-decoder=mp3 \
--enable-decoder=nellymoser \
\
--enable-openssl \
\
--enable-cross-compile \
--sysroot=${SDKRoot} \
--target-os=darwin \
--cc="${CC}" \
--extra-cflags="-DVPLAYER_IOS -arch ${ARCH} -pipe -I${SSLINCLUDE} ${EXCFLAGS} -miphoneos-version-min=${SDKVERSIONMIN}" \
--extra-ldflags="-arch ${ARCH} -isysroot ${SDKRoot} -L${SSLLIBS} ${EXCLDFLAGS} -miphoneos-version-min=${SDKVERSIONMIN}" \
${ADVANCED} \
--enable-pic \
--enable-thumb \
--disable-symver \
--enable-hardcoded-tables \
--disable-memalign-hack \
\
${OPTZFLAGS} \
\
${DEBUGS}
}
function doConfigureAll()
{
# *NEED* gas-preprocessor.pl file in $PATH , use for asm compile.
# wget --no-check-certificate https://raw.github.com/libav/gas-preprocessor/master/gas-preprocessor.pl
# wget --no-check-certificate https://raw.github.com/yuvi/gas-preprocessor/master/gas-preprocessor.pl
./configure \
--prefix=${DIST} \
\
--enable-version3 \
\
--disable-shared \
--disable-small \
--disable-runtime-cpudetect \
\
--disable-programs \
--disable-doc \
\
--disable-avdevice \
--disable-postproc \
--enable-network \
\
--enable-vda \
\
--disable-muxers \
--enable-muxer=mp4 \
--enable-demuxers \
--disable-demuxer=sbg \
--disable-demuxer=dts \
--disable-encoders \
--enable-decoders \
--disable-decoder=dca \
--disable-decoder=svq3 \
--disable-parser=dca \
--disable-devices \
\
--enable-bzlib \
--enable-zlib \
--enable-iconv \
--disable-librtmp \
--enable-openssl \
\
--enable-cross-compile \
--sysroot=${SDKRoot} \
--target-os=darwin \
--cc="${CC}" \
--extra-cflags="-DVPLAYER_IOS -arch ${ARCH} -pipe -I${SSLINCLUDE} ${EXCFLAGS} -miphoneos-version-min=${SDKVERSIONMIN}" \
--extra-ldflags="-arch ${ARCH} -isysroot ${SDKRoot} -L${SSLLIBS} ${EXCLDFLAGS} -miphoneos-version-min=${SDKVERSIONMIN}" \
${ADVANCED} \
--enable-pic \
--enable-thumb \
--disable-symver \
--enable-hardcoded-tables \
--disable-memalign-hack \
\
${OPTZFLAGS} \
\
${DEBUGS}
}
# $1 version
function doConfigure()
{
ver="$1";
if [[ $ver == "online" ]]; then
doConfigureOnline
else
doConfigureAll
fi
ret=$?;
perl -i -pe "s|^#define HAVE_GETADDRINFO 1|#define HAVE_GETADDRINFO 0|" config.h # getaddrinfo() has some issues in iOS
cp -f ./config.log ./config.h ${DIST}/; [[ $ret != 0 ]] && die
}
function doMake()
{
rm -f ./-.d
(make clean && make) || die
## MMS stream failed by optimizations flag "-O1/-O2/-O3", so ...
sed -e '/^CFLAGS=/s/ -O[123s]/ -O0/' config.mak > config.O0.mak
mv -f config.O0.mak config.mak
cd libavformat && rm -f mms.o mmst.o mmsh.o mmsu.o && cd ..
make && make install || die
}
path_old=$PATH
build_date=`date "+%Y%m%dT%H%M%S"`
#build_versions="release debug online"
build_versions="online release"
build_archs="arm64 x86_64 armv7 armv7s i386"
for iver in $build_versions; do
case $iver in
release|online) export DEBUGS="--disable-debug --disable-optimizations --optflags=-O3" ;; # -O3 failed to open mms stream!
debug) export DEBUGS="--enable-debug=3 --disable-optimizations" ;;
esac
lipo_archs=
for iarch in $build_archs; do
[[ $iver == debug && ($iarch == armv7s || $iarch == x86_64) ]] && continue
export ARCH=$iarch
export SDKVERSIONMIN=4.3
export DIST=${DEST}/$build_date/$iver/$iarch && mkdir -p ${DIST}
export PATH=${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin:$path_old
export CC="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
libdir=${DIST}/lib && mkdir -p $libdir
confInfo=${DIST}/configure_out.log
makeInfo=${DIST}/make_out.log
case $iarch in
arm*)
export SDKRoot="$SDKRootReal"
export OPTZFLAGS="--enable-asm --disable-armv5te --disable-armv6 --disable-armv6t2"
case $iarch in
armv7)
export EXCFLAGS="-mfpu=neon -mfloat-abi=hard -fembed-bitcode" # "-mcpu= or -march=" set by "--cpu="
export ADVANCED="--arch=arm --cpu=cortex-a8"
;;
armv7s)
export EXCFLAGS="-mfpu=neon -mfloat-abi=hard -fembed-bitcode"
export ADVANCED="--arch=arm --cpu=cortex-a9"
;;
arm64)
export OPTZFLAGS="--disable-asm"
export EXCFLAGS="-mfpu=vfpv4 -mfloat-abi=hard -fembed-bitcode"
export ADVANCED="--arch=arm"
export SDKVERSIONMIN=7.0.0
;;
esac
;;
i386|x86_64)
export SDKRoot="$SDKRootSimulator"
export OPTZFLAGS="--disable-asm"
export EXCFLAGS="-fembed-bitcode"
export ADVANCED="--arch=$iarch --cpu=$iarch"
;;
esac
cd $SOURCE && cp -f $selfname $DIST
doConfigure "$iver" 2>&1 | tee -a $confInfo
objs=$(make -n -B | sed -n -e '/printf "AR.*; ar rc /p' | sed -e 's/^printf .* ar rc .*\.a//')
doMake 2>&1 | tee -a $makeInfo
ar rc $libdir/libffmpeg.a $objs
lipo_archs="$lipo_archs $libdir/libffmpeg.a"
done
export PATH=${DEVRootReal}/usr/bin:$path_old
univs=${DEST}/$build_date/$iver/universal
univslib=$univs/lib && mkdir -p $univslib
lipo $lipo_archs -create -output $univslib/libffmpeg.a
ranlib $univslib/libffmpeg.a
[[ $iver != "debug" ]] && strip -S $univslib/libffmpeg.a
done
[[ $build_date != built ]] && cd ${DEST} && rm -f built && ln -s $build_date built
printf "\nFFmpeg build successfully!!\n\n"
exit 0