-
Notifications
You must be signed in to change notification settings - Fork 254
/
build.sh
executable file
·551 lines (483 loc) · 14.7 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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
#!/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
# check operating system
OS=`uname`
platform="unknown"
case $OS in
'Darwin')
platform='darwin'
;;
'Linux')
platform='linux'
;;
esac
#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.15.05.tar.bz2" \
"" \
"b8985eddf3a6b08fc246c14f5889147c" \
"https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/"
download \
"OpenSSL_1_0_2o.tar.gz" \
"" \
"5b5c050f83feaa0c784070637fac3af4" \
"https://github.com/openssl/openssl/archive/"
download \
"v1.2.11.tar.gz" \
"zlib-1.2.11.tar.gz" \
"0095d2d2d1f3442ce1318336637b695f" \
"https://github.com/madler/zlib/archive/"
download \
"v1.5.3.tar.gz" \
"" \
"df8213a3669dd846ddaad0fa1e9f417b" \
"https://github.com/Haivision/srt/archive/refs/tags/"
download \
"x264-stable.tar.gz" \
"" \
"nil" \
"https://code.videolan.org/videolan/x264/-/archive/stable/"
download \
"x265_3.4.tar.gz" \
"" \
"e37b91c1c114f8815a3f46f039fe79b5" \
"http://download.openpkg.org/components/cache/x265/"
download \
"v0.1.6.tar.gz" \
"fdk-aac.tar.gz" \
"223d5f579d29fb0d019a775da4e0e061" \
"https://github.com/mstorsjo/fdk-aac/archive"
# libass dependency
download \
"harfbuzz-1.4.6.tar.bz2" \
"" \
"e246c08a3bac98e31e731b2a1bf97edf" \
"https://www.freedesktop.org/software/harfbuzz/release/"
download \
"fribidi-1.0.2.tar.bz2" \
"" \
"bd2eb2f3a01ba11a541153f505005a7b" \
"https://github.com/fribidi/fribidi/releases/download/v1.0.2/"
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.7.4.tar.gz" \
"zimg-release-2.7.4.tar.gz" \
"1757dcc11590ef3b5a56c701fd286345" \
"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 \
"v0.6.1.tar.gz" \
"libwebp-0.6.1.tar.gz" \
"1c3099cd2656d0d80d3550ee29fc0f28" \
"https://github.com/webmproject/libwebp/archive/"
download \
"v1.3.6.tar.gz" \
"vorbis-1.3.6.tar.gz" \
"03e967efb961f65a313459c5d0f4cbfb" \
"https://github.com/xiph/vorbis/archive/"
download \
"v1.3.3.tar.gz" \
"ogg-1.3.3.tar.gz" \
"b8da1fe5ed84964834d40855ba7b93c2" \
"https://github.com/xiph/ogg/archive/"
download \
"Speex-1.2.0.tar.gz" \
"Speex-1.2.0.tar.gz" \
"4bec86331abef56129f9d1c994823f03" \
"https://github.com/xiph/speex/archive/"
download \
"n6.0.tar.gz" \
"ffmpeg6.0.tar.gz" \
"586ca7cc091d26fd0a4c26308950ca51" \
"https://github.com/FFmpeg/FFmpeg/archive"
download \
"SDL2-2.0.22.tar.gz" \
"SDL2-2.0.22.tar.gz" \
"40aedb499cb2b6f106d909d9d97f869a" \
"https://github.com/libsdl-org/SDL/releases/download/release-2.0.22"
[ $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 OpenSSL ***"
cd $BUILD_DIR/openssl*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
if [ "$platform" = "darwin" ]; then
PATH="$BIN_DIR:$PATH" ./Configure darwin64-x86_64-cc --prefix=$TARGET_DIR
elif [ "$platform" = "linux" ]; then
PATH="$BIN_DIR:$PATH" ./config --prefix=$TARGET_DIR
fi
PATH="$BIN_DIR:$PATH" make -j $jval
make install
echo "*** Building zlib ***"
cd $BUILD_DIR/zlib*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
if [ "$platform" = "linux" ]; then
[ ! -f config.status ] && PATH="$BIN_DIR:$PATH" ./configure --prefix=$TARGET_DIR
elif [ "$platform" = "darwin" ]; then
[ ! -f config.status ] && PATH="$BIN_DIR:$PATH" ./configure --prefix=$TARGET_DIR
fi
PATH="$BIN_DIR:$PATH" make -j $jval
make install
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 -DSTATIC_LINK_CRT:BOOL=ON -DENABLE_CLI:BOOL=OFF ../../source
sed -i 's/-lgcc_s/-lgcc_eh/g' x265.pc
make -j $jval
make install
echo "*** Building fdk-aac ***"
cd $BUILD_DIR/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 --disable-docs
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
# there's no configure, we have to edit Makefile directly
if [ "$platform" = "linux" ]; then
sed -i "/INC=.*/d" ./Makefile # Remove INC if present from previous run.
sed -i "s/prefix=.*/prefix=${TARGET_DIR_SED}\nINC=-I\$(prefix)\/include/" ./Makefile
sed -i "s/SHARED=.*/SHARED=no/" ./Makefile
elif [ "$platform" = "darwin" ]; then
sed -i "s/prefix=./prefix=${TARGET_DIR_SED}/" ./Makefile
fi
make install_base
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
if [ "$platform" = "linux" ]; then
sed -i "s/vidstab SHARED/vidstab STATIC/" ./CMakeLists.txt
elif [ "$platform" = "darwin" ]; then
sed -i "s/vidstab SHARED/vidstab STATIC/" ./CMakeLists.txt
fi
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
sed -i 's/size_t/std::size_t/g' src/zimg/colorspace/matrix3.cpp
make -j $jval
make install
echo "*** Building libwebp ***"
cd $BUILD_DIR/libwebp*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
./autogen.sh
./configure --prefix=$TARGET_DIR --disable-shared
make -j $jval
make install
echo "*** Building libvorbis ***"
cd $BUILD_DIR/vorbis*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
./autogen.sh
./configure --prefix=$TARGET_DIR --disable-shared
make -j $jval
make install
echo "*** Building libogg ***"
cd $BUILD_DIR/ogg*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
./autogen.sh
./configure --prefix=$TARGET_DIR --disable-shared
make -j $jval
make install
echo "*** Building libspeex ***"
cd $BUILD_DIR/speex*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
./autogen.sh
./configure --prefix=$TARGET_DIR --disable-shared
make -j $jval
make install
echo "*** Building libsdl ***"
cd $BUILD_DIR/SDL*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
./autogen.sh
./configure --prefix=$TARGET_DIR --disable-shared
make -j $jval
make install
echo "*** Building RIST ***"
cd $BUILD_DIR
rm -rf librist
git clone https://code.videolan.org/rist/librist.git
cd $BUILD_DIR/librist*
git checkout v0.2.10
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
mkdir -p build
cd build
meson --default-library=static .. --prefix=$TARGET_DIR --bindir="../bin/" --libdir="$TARGET_DIR/lib"
ninja
ninja install
echo "*** Building SRT ***"
cd $BUILD_DIR/srt*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
mkdir -p build
cd build
cmake -DENABLE_APPS=OFF -DCMAKE_INSTALL_PREFIX=$TARGET_DIR -DENABLE_C_DEPS=ON -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DOPENSSL_USE_STATIC_LIBS=ON ..
sed -i 's/-lgcc_s/-lgcc_eh/g' haisrt.pc
sed -i 's/-lgcc_s/-lgcc_eh/g' srt.pc
make
make install
# FFMpeg
echo "*** Building FFmpeg ***"
cd $BUILD_DIR/FFmpeg*
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
if [ "$platform" = "linux" ]; then
[ ! -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-libs="-lpthread -lm -lz" \
--extra-ldexeflags="-static" \
--bindir="$BIN_DIR" \
--enable-pic \
--enable-ffplay \
--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 \
--enable-librist \
--enable-libsrt
elif [ "$platform" = "darwin" ]; then
[ ! -f config.status ] && PATH="$BIN_DIR:$PATH" \
PKG_CONFIG_PATH="${TARGET_DIR}/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/local/Cellar/openssl/1.0.2o_1/lib/pkgconfig" ./configure \
--cc=/usr/bin/clang \
--prefix="$TARGET_DIR" \
--pkg-config-flags="--static" \
--extra-cflags="-I$TARGET_DIR/include" \
--extra-ldflags="-L$TARGET_DIR/lib" \
--extra-ldexeflags="-Bstatic" \
--bindir="$BIN_DIR" \
--enable-pic \
--enable-ffplay \
--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-libvidstab \
--enable-libvorbis \
--enable-libvpx \
--enable-libwebp \
--enable-libx264 \
--enable-libx265 \
--enable-libxvid \
--enable-libzimg \
--enable-nonfree \
--enable-openssl \
--enable-librist \
--enable-libsrt
fi
PATH="$BIN_DIR:$PATH" make -j $jval
make install
make distclean
hash -r