-
Notifications
You must be signed in to change notification settings - Fork 334
/
build-ffmpeg
executable file
·1111 lines (956 loc) · 39.7 KB
/
build-ffmpeg
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
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# HOMEPAGE: https://github.com/markus-perl/ffmpeg-build-script
# LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE
PROGNAME=$(basename "$0")
FFMPEG_VERSION=7.0
SCRIPT_VERSION=1.52
CWD=$(pwd)
PACKAGES="$CWD/packages"
WORKSPACE="$CWD/workspace"
CFLAGS="-I$WORKSPACE/include -Wno-int-conversion"
LDFLAGS="-L$WORKSPACE/lib"
LDEXEFLAGS=""
EXTRALIBS="-ldl -lpthread -lm -lz"
MACOS_M1=false
CONFIGURE_OPTIONS=()
NONFREE_AND_GPL=false
DISABLE_LV2=false
LATEST=false
MANPAGES=1
CURRENT_PACKAGE_VERSION=0
# Check for Apple Silicon
if [[ ("$(uname -m)" == "arm64") && ("$OSTYPE" == "darwin"*) ]]; then
# If arm64 AND darwin (macOS)
export ARCH=arm64
export MACOSX_DEPLOYMENT_TARGET=11.0
MACOS_M1=true
fi
# Speed up the process
# Env Var NUMJOBS overrides automatic detection
if [[ -n "$NUMJOBS" ]]; then
MJOBS="$NUMJOBS"
elif [[ -f /proc/cpuinfo ]]; then
MJOBS=$(grep -c processor /proc/cpuinfo)
elif [[ "$OSTYPE" == "darwin"* ]]; then
MJOBS=$(sysctl -n machdep.cpu.thread_count)
CONFIGURE_OPTIONS=("--enable-videotoolbox")
MACOS_LIBTOOL="$(which libtool)" # gnu libtool is installed in this script and need to avoid name conflict
else
MJOBS=4
fi
make_dir() {
remove_dir "$1"
if ! mkdir "$1"; then
printf "\n Failed to create dir %s" "$1"
exit 1
fi
}
remove_dir() {
if [ -d "$1" ]; then
rm -r "$1"
fi
}
download() {
# download url [filename[dirname]]
DOWNLOAD_PATH="$PACKAGES"
DOWNLOAD_FILE="${2:-"${1##*/}"}"
if [[ "$DOWNLOAD_FILE" =~ tar. ]]; then
TARGETDIR="${DOWNLOAD_FILE%.*}"
TARGETDIR="${3:-"${TARGETDIR%.*}"}"
else
TARGETDIR="${3:-"${DOWNLOAD_FILE%.*}"}"
fi
if [ ! -f "$DOWNLOAD_PATH/$DOWNLOAD_FILE" ]; then
echo "Downloading $1 as $DOWNLOAD_FILE"
curl -L --silent -o "$DOWNLOAD_PATH/$DOWNLOAD_FILE" "$1"
EXITCODE=$?
if [ $EXITCODE -ne 0 ]; then
echo ""
echo "Failed to download $1. Exitcode $EXITCODE. Retrying in 10 seconds"
sleep 10
curl -L --silent -o "$DOWNLOAD_PATH/$DOWNLOAD_FILE" "$1"
fi
EXITCODE=$?
if [ $EXITCODE -ne 0 ]; then
echo ""
echo "Failed to download $1. Exitcode $EXITCODE"
exit 1
fi
echo "... Done"
else
echo "$DOWNLOAD_FILE has already downloaded."
fi
make_dir "$DOWNLOAD_PATH/$TARGETDIR"
if [[ "$DOWNLOAD_FILE" == *"patch"* ]]; then
return
fi
if [ -n "$3" ]; then
if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" 2>/dev/null >/dev/null; then
echo "Failed to extract $DOWNLOAD_FILE"
exit 1
fi
else
if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" --strip-components 1 2>/dev/null >/dev/null; then
echo "Failed to extract $DOWNLOAD_FILE"
exit 1
fi
fi
echo "Extracted $DOWNLOAD_FILE"
cd "$DOWNLOAD_PATH/$TARGETDIR" || (
echo "Error has occurred."
exit 1
)
}
execute() {
echo "$ $*"
OUTPUT=$("$@" 2>&1)
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "$OUTPUT"
echo ""
echo "Failed to Execute $*" >&2
exit 1
fi
}
build() {
echo ""
echo "building $1 - version $2"
echo "======================="
CURRENT_PACKAGE_VERSION=$2
if [ -f "$PACKAGES/$1.done" ]; then
if grep -Fx "$2" "$PACKAGES/$1.done" >/dev/null; then
echo "$1 version $2 already built. Remove $PACKAGES/$1.done lockfile to rebuild it."
return 1
elif $LATEST; then
echo "$1 is outdated and will be rebuilt with latest version $2"
return 0
else
echo "$1 is outdated, but will not be rebuilt. Pass in --latest to rebuild it or remove $PACKAGES/$1.done lockfile."
return 1
fi
fi
return 0
}
command_exists() {
if ! [[ -x $(command -v "$1") ]]; then
return 1
fi
return 0
}
library_exists() {
if ! [[ -x $(pkg-config --exists --print-errors "$1" 2>&1 >/dev/null) ]]; then
return 1
fi
return 0
}
build_done() {
echo "$2" >"$PACKAGES/$1.done"
}
verify_binary_type() {
if ! command_exists "file"; then
return
fi
BINARY_TYPE=$(file "$WORKSPACE/bin/ffmpeg" | sed -n 's/^.*\:\ \(.*$\)/\1/p')
echo ""
case $BINARY_TYPE in
"Mach-O 64-bit executable arm64")
echo "Successfully built Apple Silicon (M1) for ${OSTYPE}: ${BINARY_TYPE}"
;;
*)
echo "Successfully built binary for ${OSTYPE}: ${BINARY_TYPE}"
;;
esac
}
cleanup() {
remove_dir "$PACKAGES"
remove_dir "$WORKSPACE"
echo "Cleanup done."
echo ""
}
usage() {
echo "Usage: $PROGNAME [OPTIONS]"
echo "Options:"
echo " -h, --help Display usage information"
echo " --version Display version information"
echo " -b, --build Starts the build process"
echo " --enable-gpl-and-non-free Enable GPL and non-free codecs - https://ffmpeg.org/legal.html"
echo " --disable-lv2 Disable LV2 libraries"
echo " -c, --cleanup Remove all working dirs"
echo " --latest Build latest version of dependencies if newer available"
echo " --small Prioritize small size over speed and usability; don't build manpages"
echo " --full-static Build a full static FFmpeg binary (eg. glibc, pthreads etc...) **only Linux**"
echo " Note: Because of the NSS (Name Service Switch), glibc does not recommend static links."
echo ""
}
echo "ffmpeg-build-script v$SCRIPT_VERSION"
echo "========================="
echo ""
while (($# > 0)); do
case $1 in
-h | --help)
usage
exit 0
;;
--version)
echo "$SCRIPT_VERSION"
exit 0
;;
-*)
if [[ "$1" == "--build" || "$1" =~ '-b' ]]; then
bflag='-b'
fi
if [[ "$1" == "--enable-gpl-and-non-free" ]]; then
CONFIGURE_OPTIONS+=("--enable-nonfree")
CONFIGURE_OPTIONS+=("--enable-gpl")
NONFREE_AND_GPL=true
fi
if [[ "$1" == "--disable-lv2" ]]; then
DISABLE_LV2=true
fi
if [[ "$1" == "--cleanup" || "$1" =~ '-c' && ! "$1" =~ '--' ]]; then
cflag='-c'
cleanup
fi
if [[ "$1" == "--full-static" ]]; then
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Error: A full static binary can only be build on Linux."
exit 1
fi
LDEXEFLAGS="-static"
fi
if [[ "$1" == "--latest" ]]; then
LATEST=true
fi
if [[ "$1" == "--small" ]]; then
CONFIGURE_OPTIONS+=("--enable-small" "--disable-doc")
MANPAGES=0
fi
shift
;;
*)
usage
exit 1
;;
esac
done
if [ -z "$bflag" ]; then
if [ -z "$cflag" ]; then
usage
exit 1
fi
exit 0
fi
echo "Using $MJOBS make jobs simultaneously."
if $NONFREE_AND_GPL; then
echo "With GPL and non-free codecs"
fi
if [ -n "$LDEXEFLAGS" ]; then
echo "Start the build in full static mode."
fi
mkdir -p "$PACKAGES"
mkdir -p "$WORKSPACE"
export PATH="${WORKSPACE}/bin:$PATH"
PKG_CONFIG_PATH="$WORKSPACE/lib/pkgconfig:/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig"
PKG_CONFIG_PATH+=":/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib64/pkgconfig"
export PKG_CONFIG_PATH
if ! command_exists "make"; then
echo "make not installed."
exit 1
fi
if ! command_exists "g++"; then
echo "g++ not installed."
exit 1
fi
if ! command_exists "curl"; then
echo "curl not installed."
exit 1
fi
if ! command_exists "cargo"; then
echo "cargo not installed. rav1e encoder will not be available."
fi
if ! command_exists "python3"; then
echo "python3 command not found. Lv2 filter and dav1d decoder will not be available."
fi
##
## build tools
##
if build "giflib" "5.2.1"; then
download "https://netcologne.dl.sourceforge.net/project/giflib/giflib-$CURRENT_PACKAGE_VERSION.tar.gz"
if [[ "$OSTYPE" == "darwin"* ]]; then
download "https://sourceforge.net/p/giflib/bugs/_discuss/thread/4e811ad29b/c323/attachment/Makefile.patch"
execute patch -p0 --forward "${PACKAGES}/giflib-$CURRENT_PACKAGE_VERSION/Makefile" "${PACKAGES}/Makefile.patch" || true
fi
cd "${PACKAGES}"/giflib-$CURRENT_PACKAGE_VERSION || exit
#multicore build disabled for this library
execute make
execute make PREFIX="${WORKSPACE}" install
build_done "giflib" $CURRENT_PACKAGE_VERSION
fi
if build "pkg-config" "0.29.2"; then
download "https://pkgconfig.freedesktop.org/releases/pkg-config-$CURRENT_PACKAGE_VERSION.tar.gz"
if [[ "$OSTYPE" == "darwin"* ]]; then
export XXFLAGS="-Wno-int-conversion" # pkg-config 0.29.2 has a warning that is treated as an error
export CFLAGS="-Wno-error=int-conversion"
fi
execute ./configure --silent --prefix="${WORKSPACE}" --with-pc-path="${WORKSPACE}"/lib/pkgconfig --with-internal-glib
execute make -j $MJOBS
execute make install
build_done "pkg-config" $CURRENT_PACKAGE_VERSION
fi
if build "yasm" "1.3.0"; then
download "https://github.com/yasm/yasm/releases/download/v$CURRENT_PACKAGE_VERSION/yasm-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}"
execute make -j $MJOBS
execute make install
build_done "yasm" $CURRENT_PACKAGE_VERSION
fi
if build "nasm" "2.16.01"; then
download "https://www.nasm.us/pub/nasm/releasebuilds/$CURRENT_PACKAGE_VERSION/nasm-$CURRENT_PACKAGE_VERSION.tar.xz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "nasm" $CURRENT_PACKAGE_VERSION
fi
if build "zlib" "1.3.1"; then
download "https://github.com/madler/zlib/releases/download/v$CURRENT_PACKAGE_VERSION/zlib-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --static --prefix="${WORKSPACE}"
execute make -j $MJOBS
execute make install
build_done "zlib" $CURRENT_PACKAGE_VERSION
fi
if build "m4" "1.4.19"; then
download "https://ftp.gnu.org/gnu/m4/m4-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}"
execute make -j $MJOBS
execute make install
build_done "m4" $CURRENT_PACKAGE_VERSION
fi
if build "autoconf" "2.71"; then
download "https://ftp.gnu.org/gnu/autoconf/autoconf-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}"
execute make -j $MJOBS
execute make install
build_done "autoconf" $CURRENT_PACKAGE_VERSION
fi
if build "automake" "1.16.5"; then
download "https://ftp.gnu.org/gnu/automake/automake-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}"
execute make -j $MJOBS
execute make install
build_done "automake" $CURRENT_PACKAGE_VERSION
fi
if build "libtool" "2.4.7"; then
download "https://ftpmirror.gnu.org/libtool/libtool-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}" --enable-static --disable-shared
execute make -j $MJOBS
execute make install
build_done "libtool" $CURRENT_PACKAGE_VERSION
fi
if $NONFREE_AND_GPL; then
if build "gettext" "0.22.5"; then
download "https://ftpmirror.gnu.org/gettext/gettext-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}" --enable-static --disable-shared
execute make -j $MJOBS
execute make install
build_done "gettext" $CURRENT_PACKAGE_VERSION
fi
if build "openssl" "1.1.1w"; then
download "https://www.openssl.org/source/openssl-$CURRENT_PACKAGE_VERSION.tar.gz"
if $MACOS_M1; then
sed -n 's/\(##### GNU Hurd\)/"darwin64-arm64-cc" => { \n inherit_from => [ "darwin-common", asm("aarch64_asm") ],\n CFLAGS => add("-Wall"),\n cflags => add("-arch arm64 "),\n lib_cppflags => add("-DL_ENDIAN"),\n bn_ops => "SIXTY_FOUR_BIT_LONG", \n perlasm_scheme => "macosx", \n}, \n\1/g' Configurations/10-main.conf
execute ./Configure --prefix="${WORKSPACE}" no-shared no-asm darwin64-arm64-cc
else
execute ./config --prefix="${WORKSPACE}" --openssldir="${WORKSPACE}" --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib no-shared zlib
fi
execute make -j $MJOBS
execute make install_sw
build_done "openssl" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-openssl")
else
if build "gmp" "6.2.1"; then
download "https://ftp.gnu.org/gnu/gmp/gmp-$CURRENT_PACKAGE_VERSION.tar.xz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "gmp" $CURRENT_PACKAGE_VERSION
fi
if build "nettle" "3.9.1"; then
download "https://ftp.gnu.org/gnu/nettle/nettle-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --disable-openssl --disable-documentation --libdir="${WORKSPACE}"/lib CPPFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}"
execute make -j $MJOBS
execute make install
build_done "nettle" $CURRENT_PACKAGE_VERSION
fi
if [[ ! $ARCH == 'arm64' ]]; then
if build "gnutls" "3.7.10"; then
download "https://www.gnupg.org/ftp/gcrypt/gnutls/v3.7/gnutls-$CURRENT_PACKAGE_VERSION.tar.xz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --disable-doc --disable-tools --disable-cxx --disable-tests --disable-gtk-doc-html --disable-libdane --disable-nls --enable-local-libopts --disable-guile --with-included-libtasn1 --with-included-unistring --without-p11-kit CPPFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}"
execute make -j $MJOBS
execute make install
build_done "gnutls" $CURRENT_PACKAGE_VERSION
fi
# CONFIGURE_OPTIONS+=("--enable-gmp" "--enable-gnutls")
fi
fi
if build "cmake" "3.27.7"; then
download "https://github.com/Kitware/CMake/releases/download/v$CURRENT_PACKAGE_VERSION/cmake-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}" --parallel="${MJOBS}" -- -DCMAKE_USE_OPENSSL=OFF
execute make -j $MJOBS
execute make install
build_done "cmake" $CURRENT_PACKAGE_VERSION
fi
##
## video library
##
if command_exists "python3"; then
# dav1d needs meson and ninja along with nasm to be built
if command_exists "pip3"; then
#set variable meson and ninja installed to false
MESON_INSTALLED=false
#check if macOs and brew is available
if [[ "$OSTYPE" == "darwin"* ]]; then
if command_exists "brew"; then
brew install python-setuptools meson ninja
MESON_INSTALLED=true
fi
else
#check if meson and ninja are installed MESON_INSTALLED AND system is not MacOS
if ! $MESON_INSTALLED; then
# meson and ninja can be installed via pip3
execute pip3 install pip setuptools --quiet --upgrade --no-cache-dir --disable-pip-version-check
for r in meson ninja; do
if ! command_exists ${r}; then
execute pip3 install ${r} --quiet --upgrade --no-cache-dir --disable-pip-version-check
fi
export PATH=$PATH:~/Library/Python/3.9/bin
done
fi
fi
fi
if command_exists "meson"; then
if build "dav1d" "1.4.2"; then
download "https://code.videolan.org/videolan/dav1d/-/archive/$CURRENT_PACKAGE_VERSION/dav1d-$CURRENT_PACKAGE_VERSION.tar.gz"
make_dir build
CFLAGSBACKUP=$CFLAGS
if $MACOS_M1; then
export CFLAGS="-arch arm64"
fi
execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib
execute ninja -C build
execute ninja -C build install
if $MACOS_M1; then
export CFLAGS=$CFLAGSBACKUP
fi
build_done "dav1d" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libdav1d")
fi
fi
if build "svtav1" "2.1.0"; then
# Last known working commit which passed CI Tests from HEAD branch
download "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v$CURRENT_PACKAGE_VERSION/SVT-AV1-v$CURRENT_PACKAGE_VERSION.tar.gz" "svtav1-$CURRENT_PACKAGE_VERSION.tar.gz"
cd "${PACKAGES}"/svtav1-$CURRENT_PACKAGE_VERSION//Build/linux || exit
execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
execute make -j $MJOBS
execute make install
execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/"
execute cp SvtAv1Dec.pc "${WORKSPACE}/lib/pkgconfig/"
build_done "svtav1" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libsvtav1")
if command_exists "cargo"; then
if [[ ! "$SKIPRAV1E" == "yes" ]]; then
if build "rav1e" "0.7.1"; then
execute cargo install cargo-c
download "https://github.com/xiph/rav1e/archive/refs/tags/v$CURRENT_PACKAGE_VERSION.tar.gz"
export RUSTFLAGS="-C target-cpu=native"
execute cargo cinstall --prefix="${WORKSPACE}" --library-type=staticlib --crt-static --release
build_done "rav1e" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-librav1e")
fi
fi
if $NONFREE_AND_GPL; then
if build "x264" "be4f0200"; then
download "https://code.videolan.org/videolan/x264/-/archive/$CURRENT_PACKAGE_VERSION/x264-$CURRENT_PACKAGE_VERSION.tar.gz" "x264-$CURRENT_PACKAGE_VERSION.tar.gz"
cd "${PACKAGES}"/x264-$CURRENT_PACKAGE_VERSION || exit
if [[ "$OSTYPE" == "linux-gnu" ]]; then
execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC ${CXXFLAGS}"
else
execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic
fi
execute make -j $MJOBS
execute make install
execute make install-lib-static
build_done "x264" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libx264")
fi
if $NONFREE_AND_GPL; then
if build "x265" "3.6"; then
download "https://bitbucket.org/multicoreware/x265_git/downloads/x265_$CURRENT_PACKAGE_VERSION.tar.gz" "x265-$CURRENT_PACKAGE_VERSION.tar.gz" # This is actually 3.4 if looking at x265Version.txt
cd build/linux || exit
rm -rf 8bit 10bit 12bit 2>/dev/null
mkdir -p 8bit 10bit 12bit
cd 12bit || exit
execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF -DMAIN12=ON
execute make -j $MJOBS
cd ../10bit || exit
execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF
execute make -j $MJOBS
cd ../8bit || exit
ln -sf ../10bit/libx265.a libx265_main10.a
ln -sf ../12bit/libx265.a libx265_main12.a
execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DEXTRA_LIB="x265_main10.a;x265_main12.a;-ldl" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON
execute make -j $MJOBS
mv libx265.a libx265_main.a
if [[ "$OSTYPE" == "darwin"* ]]; then
execute "${MACOS_LIBTOOL}" -static -o libx265.a libx265_main.a libx265_main10.a libx265_main12.a 2>/dev/null
else
execute ar -M <<EOF
CREATE libx265.a
ADDLIB libx265_main.a
ADDLIB libx265_main10.a
ADDLIB libx265_main12.a
SAVE
END
EOF
fi
execute make install
if [ -n "$LDEXEFLAGS" ]; then
sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}/lib/pkgconfig/x265.pc" # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux
fi
build_done "x265" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libx265")
fi
if build "libvpx" "1.14.1"; then
download "https://github.com/webmproject/libvpx/archive/refs/tags/v$CURRENT_PACKAGE_VERSION.tar.gz" "libvpx-$CURRENT_PACKAGE_VERSION.tar.gz"
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Applying Darwin patch"
sed "s/,--version-script//g" build/make/Makefile >build/make/Makefile.patched
sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched >build/make/Makefile
fi
execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --disable-shared --disable-examples --as=yasm --enable-vp9-highbitdepth
execute make -j $MJOBS
execute make install
build_done "libvpx" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libvpx")
if $NONFREE_AND_GPL; then
if build "xvidcore" "1.3.7"; then
download "https://downloads.xvid.com/downloads/xvidcore-$CURRENT_PACKAGE_VERSION.tar.gz"
cd build/generic || exit
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
execute make -j $MJOBS
execute make install
if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then
execute rm "${WORKSPACE}/lib/libxvidcore.4.dylib"
fi
if [[ -f ${WORKSPACE}/lib/libxvidcore.so ]]; then
execute rm "${WORKSPACE}"/lib/libxvidcore.so*
fi
build_done "xvidcore" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libxvid")
fi
if $NONFREE_AND_GPL; then
if build "vid_stab" "1.1.1"; then
download "https://github.com/georgmartius/vid.stab/archive/v$CURRENT_PACKAGE_VERSION.tar.gz" "vid.stab-$CURRENT_PACKAGE_VERSION.tar.gz"
if $MACOS_M1; then
curl -L --silent -o "$PACKAGES/vid.stab-$CURRENT_PACKAGE_VERSION/fix_cmake_quoting.patch" "https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch"
patch -p1 <fix_cmake_quoting.patch
fi
execute cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DUSE_OMP=OFF -DENABLE_SHARED=off .
execute make
execute make install
build_done "vid_stab" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libvidstab")
fi
if build "av1" "42dfaa1d47022650bc157dbe20d210591d14bae4"; then
# libaom 42dfaa1d47022650bc157dbe20d210591d14bae4 == v3.9.0
download "https://aomedia.googlesource.com/aom/+archive/$CURRENT_PACKAGE_VERSION.tar.gz" "av1.tar.gz" "av1"
make_dir "$PACKAGES"/aom_build
cd "$PACKAGES"/aom_build || exit
if $MACOS_M1; then
execute cmake -DENABLE_TESTS=0 -DENABLE_EXAMPLES=0 -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCONFIG_RUNTIME_CPU_DETECT=0 "$PACKAGES"/av1
else
execute cmake -DENABLE_TESTS=0 -DENABLE_EXAMPLES=0 -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib "$PACKAGES"/av1
fi
execute make -j $MJOBS
execute make install
build_done "av1" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libaom")
if build "zimg" "3.0.5"; then
download "https://github.com/sekrit-twc/zimg/archive/refs/tags/release-$CURRENT_PACKAGE_VERSION.tar.gz" "zimg-$CURRENT_PACKAGE_VERSION.tar.gz" "zimg"
cd zimg-release-$CURRENT_PACKAGE_VERSION || exit
execute "${WORKSPACE}/bin/libtoolize" -i -f -q
execute ./autogen.sh --prefix="${WORKSPACE}"
execute ./configure --prefix="${WORKSPACE}" --enable-static --disable-shared
execute make -j $MJOBS
execute make install
build_done "zimg" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libzimg")
##
## audio library
##
if ! $DISABLE_LV2 ; then
if command_exists "python3"; then
if command_exists "meson"; then
if build "lv2" "1.18.10"; then
download "https://lv2plug.in/spec/lv2-$CURRENT_PACKAGE_VERSION.tar.xz" "lv2-$CURRENT_PACKAGE_VERSION.tar.xz"
execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib
execute ninja -C build
execute ninja -C build install
build_done "lv2" $CURRENT_PACKAGE_VERSION
fi
if build "waflib" "b600c92"; then
download "https://gitlab.com/drobilla/autowaf/-/archive/$CURRENT_PACKAGE_VERSION/autowaf-$CURRENT_PACKAGE_VERSION.tar.gz" "autowaf.tar.gz"
build_done "waflib" $CURRENT_PACKAGE_VERSION
fi
if build "serd" "0.30.16"; then
download "https://gitlab.com/drobilla/serd/-/archive/v$CURRENT_PACKAGE_VERSION/serd-v$CURRENT_PACKAGE_VERSION.tar.gz" "serd-v$CURRENT_PACKAGE_VERSION.tar.gz"
execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib
execute ninja -C build
execute ninja -C build install
build_done "serd" $CURRENT_PACKAGE_VERSION
fi
if build "pcre" "8.45"; then
download "https://altushost-swe.dl.sourceforge.net/project/pcre/pcre/$CURRENT_PACKAGE_VERSION/pcre-$CURRENT_PACKAGE_VERSION.tar.gz" "pcre-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "pcre" $CURRENT_PACKAGE_VERSION
fi
if build "sord" "0.16.14"; then
download "https://gitlab.com/drobilla/sord/-/archive/v$CURRENT_PACKAGE_VERSION/sord-v$CURRENT_PACKAGE_VERSION.tar.gz" "sord-v$CURRENT_PACKAGE_VERSION.tar.gz"
execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib
execute ninja -C build
execute ninja -C build install
build_done "sord" $CURRENT_PACKAGE_VERSION
fi
if build "sratom" "0.6.14"; then
download "https://gitlab.com/lv2/sratom/-/archive/v$CURRENT_PACKAGE_VERSION/sratom-v$CURRENT_PACKAGE_VERSION.tar.gz" "sratom-v$CURRENT_PACKAGE_VERSION.tar.gz"
execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib
execute ninja -C build
execute ninja -C build install
build_done "sratom" $CURRENT_PACKAGE_VERSION
fi
if build "lilv" "0.24.20"; then
download "https://gitlab.com/lv2/lilv/-/archive/v$CURRENT_PACKAGE_VERSION/lilv-v$CURRENT_PACKAGE_VERSION.tar.gz" "lilv-v$CURRENT_PACKAGE_VERSION.tar.gz"
execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib
execute ninja -C build
execute ninja -C build install
build_done "lilv" $CURRENT_PACKAGE_VERSION
fi
CFLAGS+=" -I$WORKSPACE/include/lilv-0"
CONFIGURE_OPTIONS+=("--enable-lv2")
fi
fi
fi
if build "opencore" "0.1.6"; then
download "https://deac-ams.dl.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-$CURRENT_PACKAGE_VERSION.tar.gz" "opencore-amr-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "opencore" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libopencore_amrnb" "--enable-libopencore_amrwb")
if build "lame" "3.100"; then
download "https://sourceforge.net/projects/lame/files/lame/$CURRENT_PACKAGE_VERSION/lame-$CURRENT_PACKAGE_VERSION.tar.gz/download?use_mirror=gigenet" "lame-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "lame" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libmp3lame")
if build "opus" "1.5.2"; then
download "https://downloads.xiph.org/releases/opus/opus-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "opus" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libopus")
if build "libogg" "1.3.5"; then
download "https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-$CURRENT_PACKAGE_VERSION.tar.xz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "libogg" $CURRENT_PACKAGE_VERSION
fi
if build "libvorbis" "1.3.7"; then
download "https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-$CURRENT_PACKAGE_VERSION.tar.gz"
sed "s/-force_cpusubtype_ALL//g" configure.ac >configure.ac.patched
rm configure.ac
mv configure.ac.patched configure.ac
execute ./autogen.sh --prefix="${WORKSPACE}"
execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --enable-static --disable-shared --disable-oggtest
execute make -j $MJOBS
execute make install
build_done "libvorbis" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libvorbis")
if build "libtheora" "1.1.1"; then
download "https://ftp.osuosl.org/pub/xiph/releases/theora/libtheora-$CURRENT_PACKAGE_VERSION.tar.gz"
sed "s/-fforce-addr//g" configure >configure.patched
chmod +x configure.patched
mv configure.patched configure
if ! $MACOS_M1; then
##BEGIN CONFIG.GUESS PATCH -- Updating config.guess file. Which allowed me to compile on aarch64 (ARMv8) [linux kernel 4.9 Ubuntu 20.04]
rm config.guess
curl -L --silent -o "config.guess" "https://raw.githubusercontent.com/gcc-mirror/gcc/master/config.guess"
chmod +x config.guess
##END OF CONFIG.GUESS PATCH
fi
execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --with-vorbis-libraries="${WORKSPACE}"/lib --with-vorbis-includes="${WORKSPACE}"/include/ --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm --disable-spec
execute make -j $MJOBS
execute make install
build_done "libtheora" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libtheora")
if $NONFREE_AND_GPL; then
if build "fdk_aac" "2.0.3"; then
download "https://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-$CURRENT_PACKAGE_VERSION.tar.gz/download?use_mirror=gigenet" "fdk-aac-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --enable-pic
execute make -j $MJOBS
execute make install
build_done "fdk_aac" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libfdk-aac")
fi
##
## image library
##
if build "libtiff" "4.6.0"; then
download "https://download.osgeo.org/libtiff/tiff-$CURRENT_PACKAGE_VERSION.tar.xz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --disable-dependency-tracking --disable-lzma --disable-webp --disable-zstd --without-x
execute make -j $MJOBS
execute make install
build_done "libtiff" $CURRENT_PACKAGE_VERSION
fi
if build "libpng" "1.6.43"; then
download "https://sourceforge.net/projects/libpng/files/libpng16/$CURRENT_PACKAGE_VERSION/libpng-$CURRENT_PACKAGE_VERSION.tar.gz" "libpng-$CURRENT_PACKAGE_VERSION.tar.gz"
export LDFLAGS="${LDFLAGS}"
export CPPFLAGS="${CFLAGS}"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "libpng" $CURRENT_PACKAGE_VERSION
fi
if build "libjxl" "0.10.3"; then
download "https://github.com/libjxl/libjxl/archive/refs/tags/v$CURRENT_PACKAGE_VERSION.tar.gz" "libjxl-$CURRENT_PACKAGE_VERSION.tar.gz"
# currently needed to fix linking of static builds in non-C++ applications
sed "s/-ljxl_threads/-ljxl_threads @JPEGXL_THREADS_PUBLIC_LIBS@/g" lib/threads/libjxl_threads.pc.in >lib/threads/libjxl_threads.pc.in.patched
rm lib/threads/libjxl_threads.pc.in
mv lib/threads/libjxl_threads.pc.in.patched lib/threads/libjxl_threads.pc.in
sed 's/set(JPEGXL_REQUIRES_TYPE "Requires")/set(JPEGXL_REQUIRES_TYPE "Requires")\'$'\n'' set(JPEGXL_THREADS_PUBLIC_LIBS "-lm ${PKGCONFIG_CXX_LIB}")/g' lib/jxl_threads.cmake >lib/jxl_threads.cmake.patched
rm lib/jxl_threads.cmake
mv lib/jxl_threads.cmake.patched lib/jxl_threads.cmake
execute ./deps.sh
execute cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=off -DENABLE_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DJPEGXL_ENABLE_BENCHMARK=OFF -DJPEGXL_ENABLE_DOXYGEN=OFF -DJPEGXL_ENABLE_MANPAGES=OFF -DJPEGXL_ENABLE_JPEGLI_LIBJPEG=OFF -DJPEGXL_ENABLE_JPEGLI=OFF -DJPEGXL_TEST_TOOLS=OFF -DJPEGXL_ENABLE_JNI=OFF -DBUILD_TESTING=OFF .
execute make -j $MJOBS
execute make install
build_done "libjxl" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libjxl")
if build "libwebp" "1.4.0"; then
# libwebp can fail to compile on Ubuntu if these flags were left set to CFLAGS
CPPFLAGS=
download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-$CURRENT_PACKAGE_VERSION.tar.gz" "libwebp-$CURRENT_PACKAGE_VERSION.tar.gz"
make_dir build
cd build || exit
execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DWEBP_BUILD_CWEBP=OFF -DWEBP_BUILD_DWEBP=OFF -DWEBP_BUILD_GIF2WEBP=OFF -DWEBP_BUILD_IMG2WEBP=OFF -DWEBP_BUILD_VWEBP=OFF ../
execute make -j $MJOBS
execute make install
build_done "libwebp" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libwebp")
##
## other library
##
if build "libsdl" "2.30.1"; then
download "https://github.com/libsdl-org/SDL/releases/download/release-$CURRENT_PACKAGE_VERSION/SDL2-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "libsdl" $CURRENT_PACKAGE_VERSION
fi
if build "FreeType2" "2.13.2"; then
download "https://downloads.sourceforge.net/freetype/freetype-$CURRENT_PACKAGE_VERSION.tar.xz"
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
execute make -j $MJOBS
execute make install
build_done "FreeType2" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libfreetype")
if $NONFREE_AND_GPL; then
if build "srt" "1.5.3"; then
download "https://github.com/Haivision/srt/archive/v$CURRENT_PACKAGE_VERSION.tar.gz" "srt-$CURRENT_PACKAGE_VERSION.tar.gz"
export OPENSSL_ROOT_DIR="${WORKSPACE}"
export OPENSSL_LIB_DIR="${WORKSPACE}"/lib
export OPENSSL_INCLUDE_DIR="${WORKSPACE}"/include/
execute cmake . -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DENABLE_APPS=OFF -DUSE_STATIC_LIBSTDCXX=ON
execute make install
if [ -n "$LDEXEFLAGS" ]; then
sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}"/lib/pkgconfig/srt.pc # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux
fi
build_done "srt" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libsrt")
if build "zvbi" "0.2.42"; then
download "https://github.com/zapping-vbi/zvbi/archive/refs/tags/v$CURRENT_PACKAGE_VERSION.tar.gz" "zvbi-$CURRENT_PACKAGE_VERSION.tar.gz"
execute ./autogen.sh --prefix="${WORKSPACE}"
execute ./configure CFLAGS="-I${WORKSPACE}/include/libpng16 ${CFLAGS}" --prefix="${WORKSPACE}" --enable-static --disable-shared
execute make -j $MJOBS
execute make install
build_done "zvbi" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libzvbi")
fi
##
## zmq library
##
if build "libzmq" "4.3.5"; then
download "https://github.com/zeromq/libzmq/releases/download/v$CURRENT_PACKAGE_VERSION/zeromq-$CURRENT_PACKAGE_VERSION.tar.gz"
if [[ "$OSTYPE" == "darwin"* ]]; then
export XML_CATALOG_FILES=/usr/local/etc/xml/catalog
fi
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
sed "s/stats_proxy stats = {0}/stats_proxy stats = {{{0, 0}, {0, 0}}, {{0, 0}, {0, 0}}}/g" src/proxy.cpp >src/proxy.cpp.patched
rm src/proxy.cpp
mv src/proxy.cpp.patched src/proxy.cpp
execute make -j $MJOBS
execute make install
build_done "libzmq" $CURRENT_PACKAGE_VERSION
CONFIGURE_OPTIONS+=("--enable-libzmq")
fi
##
## HWaccel library
##
if [[ "$OSTYPE" == "linux-gnu" ]]; then
if command_exists "nvcc"; then
if build "nv-codec" "11.1.5.3"; then
download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n$CURRENT_PACKAGE_VERSION/nv-codec-headers-$CURRENT_PACKAGE_VERSION.tar.gz"
execute make PREFIX="${WORKSPACE}"
execute make PREFIX="${WORKSPACE}" install
build_done "nv-codec" $CURRENT_PACKAGE_VERSION
fi
CFLAGS+=" -I/usr/local/cuda/include"
LDFLAGS+=" -L/usr/local/cuda/lib64"
CONFIGURE_OPTIONS+=("--enable-cuda-nvcc" "--enable-cuvid" "--enable-nvdec" "--enable-nvenc" "--enable-cuda-llvm" "--enable-ffnvcodec")
if [ -z "$LDEXEFLAGS" ]; then
CONFIGURE_OPTIONS+=("--enable-libnpp") # Only libnpp cannot be statically linked.
fi
if [ -z "$CUDA_COMPUTE_CAPABILITY" ]; then
# Set default value if no compute capability was found
# Note that multi-architecture builds are not supported in ffmpeg
# see https://patchwork.ffmpeg.org/comment/62905/
export CUDA_COMPUTE_CAPABILITY=52
fi
CONFIGURE_OPTIONS+=("--nvccflags=-gencode arch=compute_$CUDA_COMPUTE_CAPABILITY,code=sm_$CUDA_COMPUTE_CAPABILITY -O2")
else
CONFIGURE_OPTIONS+=("--disable-ffnvcodec")
fi