forked from zimbatm/ffmpeg-static
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·345 lines (299 loc) · 8.96 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
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
#!/bin/sh
set -e
set -u
jflag=
jval=2
rebuild=0
download_only=0
uname -mpi | grep -qE 'x86|i386|i686' && is_x86=1 || is_x86=0
while getopts 'j:Bd' OPTION
do
case $OPTION in
j)
jflag=1
jval="$OPTARG"
;;
B)
rebuild=1
;;
d)
download_only=1
;;
?)
printf "Usage: %s: [-j concurrency_level] (hint: your cores + 20%%) [-B] [-d]\n" $(basename $0) >&2
exit 2
;;
esac
done
shift $(($OPTIND - 1))
if [ "$jflag" ]
then
if [ "$jval" ]
then
printf "Option -j specified (%d)\n" $jval
fi
fi
[ "$rebuild" -eq 1 ] && echo "Reconfiguring existing packages..."
[ $is_x86 -ne 1 ] && echo "Not using yasm or nasm on non-x86 platform..."
cd `dirname $0`
ENV_ROOT=`pwd`
. ./env.source
#if you want a rebuild
#rm -rf "$BUILD_DIR" "$TARGET_DIR"
mkdir -p "$BUILD_DIR" "$TARGET_DIR" "$DOWNLOAD_DIR" "$BIN_DIR"
#download and extract package
download(){
filename="$1"
if [ ! -z "$2" ];then
filename="$2"
fi
../download.pl "$DOWNLOAD_DIR" "$1" "$filename" "$3" "$4"
#disable uncompress
REPLACE="$rebuild" CACHE_DIR="$DOWNLOAD_DIR" ../fetchurl "http://cache/$filename"
}
echo "#### FFmpeg static build ####"
#this is our working directory
cd $BUILD_DIR
[ $is_x86 -eq 1 ] && download \
"yasm-1.3.0.tar.gz" \
"" \
"fc9e586751ff789b34b1f21d572d96af" \
"http://www.tortall.net/projects/yasm/releases/"
[ $is_x86 -eq 1 ] && download \
"nasm-2.13.01.tar.gz" \
"" \
"16050aa29bc0358989ef751d12b04ed2" \
"http://www.nasm.us/pub/nasm/releasebuilds/2.13.01/"
download \
"last_x264.tar.bz2" \
"" \
"nil" \
"http://download.videolan.org/pub/videolan/x264/snapshots/"
download \
"x265_2.3.tar.gz" \
"" \
"18716a7e0c6f6ebd2a1035b82cec30de" \
"https://bitbucket.org/multicoreware/x265/downloads/"
download \
"master" \
"fdk-aac.tar.gz" \
"nil" \
"https://github.com/mstorsjo/fdk-aac/tarball"
# libass dependency
download \
"harfbuzz-1.4.6.tar.bz2" \
"" \
"e246c08a3bac98e31e731b2a1bf97edf" \
"https://www.freedesktop.org/software/harfbuzz/release/"
download \
"fribidi-0.19.7.tar.bz2" \
"" \
"6c7e7cfdd39c908f7ac619351c1c5c23" \
"https://www.fribidi.org/download/"
download \
"0.13.6.tar.gz" \
"libass-0.13.6.tar.gz" \
"nil" \
"https://github.com/libass/libass/archive/"
download \
"lame-3.99.5.tar.gz" \
"" \
"84835b313d4a8b68f5349816d33e07ce" \
"http://downloads.sourceforge.net/project/lame/lame/3.99"
download \
"opus-1.1.2.tar.gz" \
"" \
"1f08a661bc72930187893a07f3741a91" \
"https://github.com/xiph/opus/releases/download/v1.1.2"
download \
"v1.6.1.tar.gz" \
"vpx-1.6.1.tar.gz" \
"b0925c8266e2859311860db5d76d1671" \
"https://github.com/webmproject/libvpx/archive"
download \
"rtmpdump-2.3.tgz" \
"" \
"eb961f31cd55f0acf5aad1a7b900ef59" \
"https://rtmpdump.mplayerhq.hu/download/"
download \
"soxr-0.1.2-Source.tar.xz" \
"" \
"0866fc4320e26f47152798ac000de1c0" \
"https://sourceforge.net/projects/soxr/files/"
download \
"release-0.98b.tar.gz" \
"vid.stab-release-0.98b.tar.gz" \
"299b2f4ccd1b94c274f6d94ed4f1c5b8" \
"https://github.com/georgmartius/vid.stab/archive/"
download \
"release-2.5.1.tar.gz" \
"zimg-release-2.5.1.tar.gz" \
"24afac41d38398bef9ee9a55c6bf1627" \
"https://github.com/sekrit-twc/zimg/archive/"
download \
"v2.1.2.tar.gz" \
"openjpeg-2.1.2.tar.gz" \
"40a7bfdcc66280b3c1402a0eb1a27624" \
"https://github.com/uclouvain/openjpeg/archive/"
download \
"n3.2.4.tar.gz" \
"ffmpeg3.2.4.tar.gz" \
"8ca58121dd042153656d89eba3daa7ab" \
"https://github.com/FFmpeg/FFmpeg/archive"
[ $download_only -eq 1 ] && exit 0
TARGET_DIR_SED=$(echo $TARGET_DIR | awk '{gsub(/\//, "\\/"); print}')
if [ $is_x86 -eq 1 ]; then
echo "*** Building yasm ***"
cd $BUILD_DIR/yasm*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
[ ! -f config.status ] && ./configure --prefix=$TARGET_DIR --bindir=$BIN_DIR
make -j $jval
make install
fi
if [ $is_x86 -eq 1 ]; then
echo "*** Building nasm ***"
cd $BUILD_DIR/nasm*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
[ ! -f config.status ] && ./configure --prefix=$TARGET_DIR --bindir=$BIN_DIR
make -j $jval
make install
fi
echo "*** Building x264 ***"
cd $BUILD_DIR/x264*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
[ ! -f config.status ] && PATH="$BIN_DIR:$PATH" ./configure --prefix=$TARGET_DIR --enable-static --disable-shared --disable-opencl --enable-pic
PATH="$BIN_DIR:$PATH" make -j $jval
make install
echo "*** Building x265 ***"
cd $BUILD_DIR/x265*
cd build/linux
[ $rebuild -eq 1 ] && find . -mindepth 1 ! -name 'make-Makefiles.bash' -and ! -name 'multilib.sh' -exec rm -r {} +
PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$TARGET_DIR" -DENABLE_SHARED:bool=off ../../source
make -j $jval
make install
echo "*** Building fdk-aac ***"
cd $BUILD_DIR/mstorsjo-fdk-aac*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
autoreconf -fiv
[ ! -f config.status ] && ./configure --prefix=$TARGET_DIR --disable-shared
make -j $jval
make install
echo "*** Building harfbuzz ***"
cd $BUILD_DIR/harfbuzz-*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
./configure --prefix=$TARGET_DIR --disable-shared --enable-static
make -j $jval
make install
echo "*** Building fribidi ***"
cd $BUILD_DIR/fribidi-*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
./configure --prefix=$TARGET_DIR --disable-shared --enable-static
make -j $jval
make install
echo "*** Building libass ***"
cd $BUILD_DIR/libass-*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
./autogen.sh
./configure --prefix=$TARGET_DIR --disable-shared
make -j $jval
make install
echo "*** Building mp3lame ***"
cd $BUILD_DIR/lame*
# The lame build script does not recognize aarch64, so need to set it manually
uname -a | grep -q 'aarch64' && lame_build_target="--build=arm-linux" || lame_build_target=''
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
[ ! -f config.status ] && ./configure --prefix=$TARGET_DIR --enable-nasm --disable-shared $lame_build_target
make
make install
echo "*** Building opus ***"
cd $BUILD_DIR/opus*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
[ ! -f config.status ] && ./configure --prefix=$TARGET_DIR --disable-shared
make
make install
echo "*** Building libvpx ***"
cd $BUILD_DIR/libvpx*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
[ ! -f config.status ] && PATH="$BIN_DIR:$PATH" ./configure --prefix=$TARGET_DIR --disable-examples --disable-unit-tests --enable-pic
PATH="$BIN_DIR:$PATH" make -j $jval
make install
echo "*** Building librtmp ***"
cd $BUILD_DIR/rtmpdump-*
cd librtmp
[ $rebuild -eq 1 ] && make distclean || true
sed -i "s/prefix=.*/prefix=${TARGET_DIR_SED}/" ./Makefile # there's no configure
make -j $jval
make install
echo "*** Building libsoxr ***"
cd $BUILD_DIR/soxr-*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$TARGET_DIR" -DBUILD_SHARED_LIBS:bool=off -DWITH_OPENMP:bool=off -DBUILD_TESTS:bool=off
make -j $jval
make install
echo "*** Building libvidstab ***"
cd $BUILD_DIR/vid.stab-release-*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
sed -i "s/vidstab SHARED/vidstab STATIC/" ./CMakeLists.txt
PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$TARGET_DIR"
make -j $jval
make install
echo "*** Building openjpeg ***"
cd $BUILD_DIR/openjpeg-*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$TARGET_DIR" -DBUILD_SHARED_LIBS:bool=off
make -j $jval
make install
echo "*** Building zimg ***"
cd $BUILD_DIR/zimg-release-*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
./autogen.sh
./configure --enable-static --prefix=$TARGET_DIR --disable-shared
make -j $jval
make install
# FFMpeg
echo "*** Building FFmpeg ***"
cd $BUILD_DIR/FFmpeg*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
[ ! -f config.status ] && PATH="$BIN_DIR:$PATH" \
PKG_CONFIG_PATH="$TARGET_DIR/lib/pkgconfig" ./configure \
--prefix="$TARGET_DIR" \
--pkg-config-flags="--static" \
--extra-cflags="-I$TARGET_DIR/include" \
--extra-ldflags="-L$TARGET_DIR/lib" \
--extra-ldexeflags="-static" \
--bindir="$BIN_DIR" \
--enable-pic \
--enable-ffplay \
--enable-ffserver \
--enable-fontconfig \
--enable-frei0r \
--enable-gpl \
--enable-version3 \
--enable-libass \
--enable-libfribidi \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-libopenjpeg \
--enable-libopus \
--enable-librtmp \
--enable-libsoxr \
--enable-libspeex \
--enable-libtheora \
--enable-libvidstab \
--enable-libvo-amrwbenc \
--enable-libvorbis \
--enable-libvpx \
--enable-libwebp \
--enable-libx264 \
--enable-libx265 \
--enable-libxvid \
--enable-libzimg \
--enable-nonfree \
--enable-openssl
PATH="$BIN_DIR:$PATH" make -j $jval
make install
make distclean
hash -r