/
cross_compile_ffmpeg_shared.sh
executable file
·8136 lines (7350 loc) · 359 KB
/
cross_compile_ffmpeg_shared.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
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
#!/usr/bin/env bash
# set -x
# ffmpeg windows cross compile helper/download script
# Copyright (C) 2014 Roger Pack, the script is under the GPLv3, but output FFmpeg's aren't necessarily
# with modifications by John Warburton john@johnwarburton.com
#Gnulib
# 1. Check it out separately
# 2.
#Gnu Coreutils
# 1. Remove configure test for mounted file system list
# 2. Set -Werror inactive
yes_no_sel () {
unset user_input
local question="$1"
shift
local default_answer="$1"
while [[ "$user_input" != [YyNn] ]]; do
echo -n "$question"
read user_input
if [[ -z "$user_input" ]]; then
echo "using default $default_answer"
user_input=$default_answer
fi
if [[ "$user_input" != [YyNn] ]]; then
clear; echo 'Your selection was not vaild, please try again.'; echo
fi
done
# downcase it
user_input=$(echo $user_input | tr '[A-Z]' '[a-z]')
}
check_missing_packages () {
# local check_packages=('cmp' 'bzip2' 'nvcc' 'rsync' 'sshpass' 'curl' 'pkg-config' 'make' 'gettext' 'git' 'svn' 'cmake' 'gcc' 'autoconf' 'libtool' 'automake' 'yasm' 'cvs' 'flex' 'bison' 'makeinfo' 'g++' 'ed' 'hg' 'patch' 'pax' 'gperf' 'ruby' 'doxygen' 'xsltproc' 'autogen' 'rake' 'autopoint' 'wget' 'zip' 'gtkdocize' 'python-config' 'ant' 'sdl-config' 'sdl2-config' 'gyp' 'mm-common-prepare' 'sassc' 'nasm' 'ragel' 'gengetopt' 'asn1Parser' 'ronn' 'docbook2x-man' 'intltool-update' 'gtk-update-icon-cache' 'gdk-pixbuf-csource' 'interdiff' 'orcc' 'luac' 'makensis' 'swig' 'meson' 'scons' 'lzip' 'sqlite3' 'zsh')
# for package in "${check_packages[@]}"; do
# type -P "$package" >/dev/null || missing_packages=("$package" "${missing_packages[@]}")
# done
# if [[ -n "${missing_packages[@]}" ]]; then
# clear
# echo "Could not find the following execs (svn is actually package subversion, autopoint is gettext or gettext-devel, sassc is libsass, makeinfo is actually package texinfo if you're missing them): ${missing_packages[@]}"
# echo 'Install the missing packages before running this script.'
# echo "for ubuntu: $ sudo apt-get install subversion curl texinfo g++ bison flex cvs yasm automake libtool autoconf gcc cmake git make pkg-config zlib1g-dev mercurial"
# echo "for gentoo (a non ubuntu distro): same as above, but no g++, no gcc, git is dev-vcs/git, zlib1g-dev is zlib, pkg-config is dev-util/pkgconfig, add ed..."
# exit 1
# fi
# local out=`cmake --version` # like cmake version 2.8.7
# local version_have=`echo "$out" | cut -d " " -f 3`
# function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
# if [[ $(version $version_have) < $(version '2.8.10') ]]; then
# echo "your cmake version is too old $version_have wanted 2.8.10"
# exit 1
# fi
# if [[ ! -f /usr/include/zlib.h ]]; then
# echo "warning: you may need to install zlib development headers first if you want to build mp4box [on ubuntu: $ apt-get install zlib1g-dev]" # XXX do like configure does and attempt to compile and include zlib.h instead?
# sleep 1
# fi
# out=`yasm --version`
# yasm_version=`echo "$out" | cut -d " " -f 2` # like 1.1.0.112
# if [[ $(version $yasm_version) < $(version '1.2.0') ]]; then
# echo "your yasm version is too old $yasm_version wanted 1.2.0"
# exit 1
# fi
if uname -a | grep -q -- "\-microsoft" ; then
if cat /proc/sys/fs/binfmt_misc/WSLInterop | grep -q enabled ; then
echo "windows WSL detected: you must first disable 'binfmt' by running this
sudo bash -c 'echo 0 > /proc/sys/fs/binfmt_misc/WSLInterop'
then try again"
exit 1
fi
fi
}
intro() {
cat <<EOL
##################### Welcome ######################
Welcome to the ffmpeg cross-compile builder-helper script.
Downloads and builds will be installed to directories within $cur_dir
If this is not ok, then exit now, and cd to the directory where you'd
like them installed, then run this script again from there.
NB that once you build your compilers, you can no longer rename/move
the sandbox directory, since it will have some hard coded paths in there.
You can, of course, rebuild ffmpeg from within it, etc.
EOL
if [[ $sandbox_ok != 'y' && ! -d sandbox ]]; then
yes_no_sel "Is ./sandbox ok (requires ~ 5GB space) [Y/n]?" "y"
if [[ "$user_input" = "n" ]]; then
exit 1
fi
fi
mkdir -p "$cur_dir"
cd "$cur_dir"
if [[ $disable_nonfree = "y" ]]; then
non_free="n"
else
if [[ $disable_nonfree = "n" ]]; then
non_free="y"
else
yes_no_sel "Would you like to include non-free (non GPL compatible) libraries, like many high quality aac encoders [libfdk_aac]
The resultant binary may not be distributable, but can be useful for in-house use. Include these non-free-license libraries [y/N]?" "n"
non_free="$user_input" # save it away
fi
fi
}
pick_compiler_flavors() {
while [[ "$build_choice" != [1-4] ]]; do
if [[ -n "${unknown_opts[@]}" ]]; then
echo -n 'Unknown option(s)'
for unknown_opt in "${unknown_opts[@]}"; do
echo -n " '$unknown_opt'"
done
echo ', ignored.'; echo
fi
cat <<'EOF'
What version of MinGW-w64 would you like to build or update?
1. Both Win32 and Win64
2. Win32 (32-bit only)
3. Win64 (64-bit only)
4. Exit
EOF
echo -n 'Input your choice [1-5]: '
read build_choice
done
case "$build_choice" in
1 ) build_choice=multi ;;
2 ) build_choice=win32 ;;
3 ) build_choice=win64 ;;
4 ) echo "exiting"; exit 0 ;;
* ) clear; echo 'Your choice was not valid, please try again.'; echo ;;
esac
}
install_cross_compiler() {
if [[ -f "mingw-w64-i686/compiler.done" || -f "x86_64-w64-mingw32/compiler.done" ]]; then
echo "MinGW-w64 compiler of some type or other already installed, not re-installing..."
if [[ $rebuild_compilers != "y" ]]; then
return # early exit, they already have some type of cross compiler built.
fi
fi
if [[ -z $build_choice ]]; then
pick_compiler_flavors
fi
if [[ -f mingw-w64-build ]]; then
rm mingw-w64-build || exit 1
fi
# curl https://raw.githubusercontent.com/Zeranoe/mingw-w64-build/master/mingw-w64-build -O || exit 1
# chmod u+x mingw-w64-build
# apply_patch file://${top_dir}/build-mingw-updates.patch
unset CFLAGS # don't want these for the compiler itself since it creates executables to run on the local box
# pthreads version to avoid having to use cvs for it
echo "building cross compile gcc [requires internet access]"
# Quick patch to update mingw to 4.0.4
# sed -i.bak "s/mingw_w64_release_ver='3.3.0'/mingw_w64_release_ver='4.0.4'/" mingw-w64-build-3.6.6
# sed -i.bak "s/gcc_release_ver='4.9.2'/gcc_release_ver='7.2.0'/" mingw-w64-build-3.6.6
# sed -i.bak "s/mpfr_release_ver='3.1.2'/mpfr_release_ver='3.1.5'/" mingw-w64-build-3.6.6
# sed -i.bak "s/binutils_release_ver='2.25'/binutils_release_ver='2.29'/" mingw-w64-build-3.6.6
# sed -i.bak "s/cloog_release_ver='0.18.1'/cloog_release_ver='0.18.1'/" mingw-w64-build-3.6.6
# sed -i.bak "s/isl_release_ver='0.12.2'/isl_release_ver='0.18'/" mingw-w64-build-3.6.6
# sed -i.bak "s/gmp_release_ver='6.0.0a'/gmp_release_ver='6.1.2'/" mingw-w64-build-3.6.6
# sed -i.bak "s/gmp-6\.0\.0/gmp-6.1.2/" mingw-w64-build-3.6.6
# sed -i.bak "s/--enable-lto/--enable-lto --enable-libgomp/" mingw-w64-build-3.6.6
# sed -i.bak "s!//gcc\.gnu\.org/svn/gcc/trunk!//gcc.gnu.org/svn/gcc/branches/gcc-7-branch!" mingw-w64-build-3.6.6
# apply_patch file://${top_dir}/mingw-w64-build-isl_fix.patch
# apply_patch file://${top_dir}/mingw-w64-build-gcc.patch
# sed -i.bak "s|ln -s '../include' './include'|mkdir include|" mingw-w64-build-3.6.6
# sed -i.bak "s|ln -s '../lib' './lib'|mkdir lib|" mingw-w64-build-3.6.6
# sed -i.bak "s/--enable-threads=win32/--enable-threads=posix/" mingw-w64-build-3.6.6
# Gendef compilation throws a char-as-array-index error when invoked with "--target=" : "--host" avoids this.
# sed -i.bak 's#gendef/configure" --build="$system_type" --prefix="$mingw_w64_prefix" --target#gendef/configure" --build="$system_type" --prefix="$mingw_w64_prefix" --host#' mingw-w64-build-3.6.6
# ./mingw-w64-build-3.6.6 --gcc-langs=c,c++,fortran --default-configure --mingw-w64-ver=git --gcc-ver=svn --pthreads-w32-ver=2-9-1 --cpu-count=$gcc_cpu_count --build-type=$build_choice --enable-gendef --enable-widl --binutils-ver=2.29 --verbose || exit 1 # --disable-shared allows c++ to be distributed at all...which seemed necessary for some random dependency...
# ./mingw-w64-build x86_64
${top_dir}/toolchain.sh || exit 1
#mv bld ${top_dir}/sandbox/x86_64-w64-mingw32
export CFLAGS=$original_cflags # reset it
# We need to move the plain cross-compiling versions of bintools out of the way
# because exactly the same binaries exist with the host triplet prefix
# rm ${mingw_w64_x86_64_prefix}/bin/objdump ${mingw_w64_x86_64_prefix}/bin/ar ${mingw_w64_x86_64_prefix}/bin/ranlib ${mingw_w64_x86_64_prefix}/bin/objcopy ${mingw_w64_x86_64_prefix}/bin/dlltool ${mingw_w64_x86_64_prefix}/bin/nm ${mingw_w64_x86_64_prefix}/bin/strip ${mingw_w64_x86_64_prefix}/bin/as ${mingw_w64_x86_64_prefix}/bin/ld.bfd ${mingw_w64_x86_64_prefix}/bin/ld
# A couple of multimedia-related files need cases changing because of QT5 includes
cd x86_64-w64-mingw32/x86_64-w64-mingw32/include
ln -s evr9.h Evr9.h
ln -s mferror.h Mferror.h
# cp -v ${top_dir}/dxgi*.h .
# apply_patch file://${top_dir}/d3d11.h.patch
apply_patch file://${top_dir}/cfgmgr32.h.patch
# apply_patch file://${top_dir}/devpkey.h.patch
# apply_patch file://${top_dir}/sal.h.patch
# apply_patch file://${top_dir}/dxgitype-missing.patch
# cp -v ${top_dir}/dxgi1_3.h .
# apply_patch file://${top_dir}/dxgi1_3.h.patch
# cp -v ${top_dir}/dxgi1_6.h .
# cp -v ${top_dir}/dxgi1_4.h .
# This is needed for vlc, and is still missing in trunk mingw-w64
# apply_patch file://${top_dir}/mingw-w64-headers-processor_format.patch
cd ../../..
if [ -d x86_64-w64-mingw32 ]; then
touch x86_64-w64-mingw32/compiler.done
fi
if [ -d mingw-w64-i686 ]; then
touch mingw-w64-i686/compiler.done
fi
# clear
echo "Ok, done building MinGW-w64 cross-compiler..."
}
# helper methods for downloading and building projects that can take generic input
do_svn_checkout() {
local repo_url="$1"
local to_dir="$2"
if [[ -z $to_dir ]]; then
to_dir=$(basename "$repo_url" | sed s/\.svn/_svn/)
fi
local desired_revision="$3"
if [ ! -d "$to_dir" ]; then
echo "Checking out (via svn checkout) $to_dir from $repo_url"
rm -rf "$to_dir.tmp" # just in case it was interrupted previously...
svn checkout "$repo_url" "$to_dir.tmp" || {
echo "svn checkout failed!"
exit 1
}
# Prevent incomplete checkouts
mv "$to_dir.tmp" "$to_dir"
echo "done svn checkout to $to_dir"
fi
cd "$to_dir"
# Handle desired revision
if [[ -n $desired_revision ]]; then
echo "Updating to revision $desired_revision"
svn update -r "$desired_revision" || {
echo "svn update to revision failed!"
exit 1
}
fi
cd ..
}
NO_do_svn_checkout() {
repo_url="$1"
to_dir="$2"
desired_revision="$3"
if [ ! -d $to_dir ]; then
echo "svn checking out to $to_dir"
if [[ -z "$desired_revision" ]]; then
svn checkout $repo_url $to_dir.tmp || exit 1
else
svn checkout -r $desired_revision $repo_url $to_dir.tmp || exit 1
fi
mv $to_dir.tmp $to_dir
else
cd $to_dir
echo "not svn Updating $to_dir since usually svn repo's aren't updated frequently enough..."
# XXX accomodate for desired revision here if I ever uncomment the next line...
# svn up
cd ..
fi
}
update_to_desired_git_branch_or_revision() {
local to_dir="$1"
local desired_branch="$2" # or tag or whatever...
if [ -n "$desired_branch" ]; then
pushd $to_dir
cd $to_dir
echo "git checkout $desired_branch"
git checkout "$desired_branch" || exit 1 # if this fails, nuke the directory first...
git merge "$desired_branch" || exit 1 # this would be if they want to checkout a revision number, not a branch...
popd # in case it's a cd to ., don't want to cd to .. here...since sometimes we call it with a '.'
fi
}
do_git_checkout() {
local repo_url="$1"
local to_dir="$2"
if [[ -z $to_dir ]]; then
to_dir=$(basename "$repo_url" | sed s/\.git/_git/)
fi
local desired_branch="$3"
if [ ! -d "$to_dir" ]; then
echo "Downloading (via git clone) $to_dir from $repo_url"
rm -rf "$to_dir.tmp" # just in case it was interrupted previously...
git clone "$repo_url" "$to_dir.tmp" || {
echo "git clone failed!"
exit 1
}
# prevent partial checkouts by renaming it only after success
mv "$to_dir.tmp" "$to_dir"
echo "done git cloning to $to_dir"
cd "$to_dir"
else
cd "$to_dir"
if [[ $git_get_latest = "y" ]]; then
git fetch # want this for later...
else
echo "not doing git get latest pull for latest code $to_dir"
fi
fi
old_git_version=`git rev-parse HEAD`
if [[ -z $desired_branch ]]; then
# Check for master first, then main as fallback
if git show-ref --verify --quiet "refs/heads/master"; then
desired_branch="master"
elif git show-ref --verify --quiet "refs/heads/main"; then
desired_branch="main"
echo "Branch 'master' not found, using 'main' instead."
else
echo "No default branch found (master or main)"
exit 1
fi
fi
echo "doing git checkout $desired_branch"
git checkout "$desired_branch" || (git_hard_reset && git checkout "$desired_branch") || (git reset --hard "$desired_branch") || exit 1
if git show-ref --verify --quiet "refs/remotes/origin/$desired_branch"; then
git merge "origin/$desired_branch" || exit 1
fi
new_git_version=`git rev-parse HEAD`
if [[ "$old_git_version" != "$new_git_version" ]]; then
echo "got upstream changes, forcing re-configure. Doing git clean -f"
git_hard_reset
else
echo "fetched no code changes, not forcing reconfigure for that..."
fi
cd ..
}
git_hard_reset() {
git reset --hard # delete results of any patches
git clean -f # remove local changes and monitoring files
}
download_config_files() {
curl -o config.guess "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD"
curl -o config.sub "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD"
chmod +x config.guess config.sub
}
get_small_touchfile_name() { # have to call with assignment like a=$(get_small...)
local beginning="$1"
local extra_stuff="$2"
local touch_name="${beginning}_$(echo -- $extra_stuff $CFLAGS | /usr/bin/env md5sum | head --bytes 10)" # make it smaller
touch_name=$(echo $touch_name | sed "s/ //g") # md5sum introduces spaces, remove them
echo $touch_name # bash cruddy return system LOL
}
do_configure() {
local configure_options="$1"
local configure_name="$2"
local configure_env="$3"
local configure_noclean=""
if [[ "$configure_name" = "" ]]; then
configure_name="./configure"
fi
local cur_dir2=$(pwd)
local english_name=$(basename $cur_dir2)
local touch_name=$(get_small_touchfile_name already_configured "$configure_options $configure_name $LDFLAGS $CFLAGS")
if [ ! -f "$touch_name" ]; then
if [ "$configure_noclean" != "noclean" ]; then
make clean # just in case
fi
#make uninstall # does weird things when run under ffmpeg src
if [ ! -f ${configure_name} ]; then
if [ -f bootstrap.sh ]; then
./bootstrap.sh
elif [ -f bootstrap ]; then
./bootstrap
elif [ -f autogen.sh ]; then
./autogen.sh
elif [ -f autogen ]; then
./autogen
else
autoreconf -fvi
fi
fi
rm -f already_* # reset
echo "configuring $english_name ($PWD) as $ PATH=$PATH ${configure_env} $configure_name $configure_options"
"$configure_name" $configure_options || exit 1
touch -- "$touch_name"
make clean # just in case
else
echo "already configured $(basename $cur_dir2)"
fi
}
do_meson() {
local configure_options="$1"
local configure_name="$2"
local configure_env="$3"
local configure_noclean=""
if [[ "$configure_name" = "" ]]; then
configure_name="meson"
fi
local cur_dir2=$(pwd)
local english_name=$(basename $cur_dir2)
local touch_name=$(get_small_touchfile_name already_built "$configure_options $configure_name $LDFLAGS $CFLAGS")
if [ ! -f "$touch_name" ]; then
if [ "$configure_noclean" != "noclean" ]; then
make clean # just in case
fi
rm -f already_* # reset
echo "Using meson: $english_name ($PWD) as $ PATH=$PATH ${configure_env} $configure_name $configure_options"
#env
${configure_env} "$configure_name" setup $configure_options || exit 1
touch -- "$touch_name"
make clean # just in case
else
echo "Already used meson $(basename $cur_dir2)"
fi
}
do_make() {
local extra_make_options="$1 -j $cpu_count"
local cur_dir2=$(pwd)
local touch_name=$(get_small_touchfile_name already_ran_make "$extra_make_options")
if [ ! -f $touch_name ]; then
echo
echo "making $cur_dir2 as $ PATH=$PATH make $extra_make_options"
echo
make $extra_make_options || exit 1
touch $touch_name || exit 1 # only touch if the build was OK
else
echo "already did make $(basename "$cur_dir2")"
fi
}
do_make_clean() {
local extra_make_options="$1 -j $cpu_count"
local cur_dir2=$(pwd)
local touch_name=$(get_small_touchfile_name already_ran_make_clean "$extra_make_options")
if [ ! -f $touch_name ]; then
echo
echo "making clean $cur_dir2 as $ PATH=$PATH make clean $extra_make_options"
echo
make $extra_make_options clean || exit 1
touch $touch_name || exit 1
else
echo "already did make clean $(basename "$cur_dir2")"
fi
}
do_rake() {
local extra_make_options="$1 -j $cpu_count"
local cur_dir2=$(pwd)
local touch_name=$(get_small_touchfile_name already_ran_rake "$extra_make_options")
if [ ! -f $touch_name ]; then
echo
echo "raking $cur_dir2 as $ PATH=$PATH rake $extra_make_options"
echo
rake $extra_make_options || exit 1
touch $touch_name || exit 1 # only touch if the build was OK
else
echo "already did make $(basename "$cur_dir2")"
fi
}
do_drake() {
local extra_make_options="$1 -j $cpu_count"
local cur_dir2=$(pwd)
local touch_name=$(get_small_touchfile_name already_ran_drake "$extra_make_options")
if [ ! -f $touch_name ]; then
echo
echo "draking $cur_dir2 as $ PATH=$PATH drake $extra_make_options"
echo
drake $extra_make_options || exit 1
touch $touch_name || exit 1 # only touch if the build was OK
else
echo "already did drake $(basename "$cur_dir2")"
fi
}
do_smake() {
local extra_make_options="$1"
local cur_dir2=$(pwd)
local touch_name=$(get_small_touchfile_name already_ran_make "$extra_make_options")
if [ ! -f $touch_name ]; then
echo
echo "smaking $cur_dir2 as $ PATH=$PATH smake $extra_make_options"
echo
${mingw_w64_x86_64_prefix}/../bin/smake $extra_make_options || exit 1
touch $touch_name || exit 1 # only touch if the build was OK
else
echo "already did smake $(basename "$cur_dir2")"
fi
}
do_make_install() {
local extra_make_options="$1"
do_make "$extra_make_options"
local touch_name=$(get_small_touchfile_name already_ran_make_install "$extra_make_options")
if [ ! -f $touch_name ]; then
echo "make installing $cur_dir2 as $ PATH=$PATH make install $extra_make_options"
make install $extra_make_options || exit 1
touch $touch_name || exit 1
fi
}
do_smake_install() {
local extra_make_options="$1"
do_smake "$extra_make_options"
local touch_name=$(get_small_touchfile_name already_ran_make_install "$extra_make_options")
if [ ! -f $touch_name ]; then
echo "smake installing $cur_dir2 as $ PATH=$PATH smake install $extra_make_options"
${mingw_w64_x86_64_prefix}/../bin/smake install $extra_make_options || exit 1
touch $touch_name || exit 1
fi
}
do_cmake() {
extra_args=$1
source_dir=$2
local touch_name=$(get_small_touchfile_name already_ran_cmake "$extra_args")
if [ ! -f $touch_name ]; then
local cur_dir2=$(pwd)
export CMAKE_INCLUDE_PATH="$mingw_w64_x86_64_prefix/include"
export CMAKE_PREFIX_PATH="$mingw_w64_x86_64_prefix"
orig_PKG_CONFIG_PATH="${PKG_CONFIG_PATH}"
export PKG_CONFIG_PATH="${mingw_w64_x86_64_prefix}/lib/pkgconfig"
export PKG_CONFIG_LIBDIR="${mingw_w64_x86_64_prefix}/lib/pkgconfig"
echo doing cmake in $cur_dir2 with PATH=$PATH with extra_args=$extra_args like this:
echo cmake $source_dir $extra_args -DBUILD_SHARED_LIBS=1 -DBUILD_STATIC_LIBS=0 -DENABLE_STATIC_RUNTIME=0 -DENABLE_SHARED_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=${cross_prefix}ranlib -DCMAKE_C_COMPILER=${cross_prefix}gcc -DCMAKE_CXX_COMPILER=${cross_prefix}g++ -DCMAKE_Fortran_COMPILER=${cross_prefix}gfortran -DCMAKE_RC_COMPILER=${cross_prefix}windres -DCMAKE_INSTALL_PREFIX=$mingw_w64_x86_64_prefix -DCMAKE_BUILD_TYPE=Release || exit 1
cmake $source_dir $extra_args -DBUILD_SHARED_LIBS=1 -DBUILD_STATIC_LIBS=0 -DENABLE_STATIC_RUNTIME=0 -DENABLE_SHARED_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=${cross_prefix}ranlib -DCMAKE_C_COMPILER=${cross_prefix}gcc -DCMAKE_CXX_COMPILER=${cross_prefix}g++ -DCMAKE_Fortran_COMPILER=${cross_prefix}gfortran -DCMAKE_RC_COMPILER=${cross_prefix}windres -DCMAKE_INSTALL_PREFIX=$mingw_w64_x86_64_prefix -DCMAKE_BUILD_TYPE=Release || exit 1
touch $touch_name || exit 1
unset CMAKE_INCLUDE_PATH
unset CMAKE_PREFIX_PATH
fi
}
do_cmake_static() {
extra_args=$1
source_dir=$2
local touch_name=$(get_small_touchfile_name already_ran_cmake "$extra_args")
if [ ! -f $touch_name ]; then
local cur_dir2=$(pwd)
export CMAKE_INCLUDE_PATH="$mingw_w64_x86_64_prefix/include"
export CMAKE_PREFIX_PATH="$mingw_w64_x86_64_prefix"
echo doing cmake in $cur_dir2 with PATH=$PATH with extra_args=$extra_args like this:
echo cmake $source_dir $extra_args -DBUILD_SHARED_LIBS=0 -DBUILD_STATIC_LIBS=1 -DENABLE_STATIC_RUNTIME=0 -DENABLE_SHARED_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=${cross_prefix}ranlib -DCMAKE_C_COMPILER=${cross_prefix}gcc -DCMAKE_CXX_COMPILER=${cross_prefix}g++ -DCMAKE_Fortran_COMPILER:FILEPATH=${cross_prefix}gfortran -DCMAKE_RC_COMPILER=${cross_prefix}windres -DCMAKE_INSTALL_PREFIX=$mingw_w64_x86_64_prefix || exit 1
cmake $source_dir $extra_args -DBUILD_SHARED_LIBS=0 -DBUILD_STATIC_LIBS=1 -DENABLE_STATIC_RUNTIME=1 -DENABLE_SHARED_RUNTIME=0 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=${cross_prefix}ranlib -DCMAKE_C_COMPILER=${cross_prefix}gcc -DCMAKE_CXX_COMPILER=${cross_prefix}g++ -DCMAKE_RC_COMPILER=${cross_prefix}windres -DCMAKE_INSTALL_PREFIX=$mingw_w64_x86_64_prefix || exit 1
touch $touch_name || exit 1
fi
}
apply_patch() {
local url=$1
local patch_name=$(basename $url)
local patch_reverted_name="$patch_name.reverted"
local patch_done_name="$patch_name.done"
if [[ ! -e $patch_done_name ]]; then
if [[ -f $patch_name ]]; then
rm $patch_name || exit 1
fi
curl $url -O || exit 1
echo "applying patch $patch_name"
cat $patch_name
patch -p0 < "$patch_name" || exit 1
touch $patch_done_name || exit 1
rm -v $patch_reverted_name
rm already_ran* # if it's a new patch, reset everything too, in case it's really really really new
else
echo "patch $patch_name already applied"
fi
}
revert_patch() {
local url=$1
local patch_name=$(basename $url)
local patch_reverted_name="$patch_name.reverted"
local patch_done_name="$patch_name.done"
if [[ ! -e $patch_reverted_name ]]; then
if [[ -f $patch_name ]]; then
rm $patch_name || exit 1
fi
curl $url -O || exit 1
echo "reverting patch $patch_name"
cat $patch_name
patch -p0 -R < "$patch_name" || exit 1
touch $patch_reverted_name || exit 1
rm -v $patch_done_name || exit 1
rm already_ran* # if it's a new patch, reset everything too, in case it's really really really new
else
echo "patch $patch_name already reverted"
fi
}
apply_patch_p1() {
local url=$1
local patch_name=$(basename $url)
local patch_done_name="$patch_name.done"
if [[ ! -e $patch_done_name ]]; then
if [[ -f $patch_name ]]; then
rm $patch_name || exit 1
fi
curl $url -O || exit 1
echo "applying patch $patch_name"
patch -p1 --ignore-whitespace < "$patch_name" || exit 1
touch $patch_done_name || exit 1
rm already_ran* # if it's a new patch, reset everything too, in case it's really really really new
else
echo "patch $patch_name already applied"
fi
}
download_and_unpack_file() {
url="$1"
output_name=$(basename $url)
output_dir="$2"
if [ ! -f "$output_dir/unpacked.successfully" ]; then
echo "downloading $url"
if [[ -f $output_name ]]; then
rm "$output_name" || exit 1
fi
# echo "About to call curl ${url} and output_name is ${output_name} and output_dir is ${output_dir}"
curl -k -O -L "${url}" || exit 1
tar --keep-directory-symlink -xvf "$output_name" || unzip "$output_name" || exit 1
touch "$output_dir/unpacked.successfully" || exit 1
rm "$output_name" || exit 1
fi
}
download_and_unpack_bz2file() {
url="$1"
output_name=$(basename $url)
output_dir="$2"
if [ ! -f "$output_dir/unpacked.successfully" ]; then
echo "downloading $url"
if [[ -f $output_name ]]; then
rm "$output_name" || exit 1
fi
curl "$url" -O -L || exit 1
mkdir $output_dir
tar ixvf "$output_name" -C $output_dir --strip-components=1 || exit 1
touch "$output_dir/unpacked.successfully" || exit 1
rm "$output_name" || exit 1
fi
}
generic_meson() {
local extra_configure_options="$1"
mkdir -pv build
do_meson "--prefix=${mingw_w64_x86_64_prefix} --libdir=${mingw_w64_x86_64_prefix}/lib --buildtype release --strip --default-library shared --cross-file ${top_dir}/meson-cross.mingw.txt ${extra_configure_options} . build"
}
generic_configure() {
local extra_configure_options="$1"
# do_configure "--host=$host_target --prefix=$mingw_w64_x86_64_prefix --disable-shared --enable-static $extra_configure_options"
do_configure "--host=$host_target --prefix=$mingw_w64_x86_64_prefix --enable-shared --disable-static $extra_configure_options"
}
# needs 2 parameters currently [url, name it will be unpacked to]
generic_download_and_install() {
local url="$1"
local english_name="$2"
local extra_configure_options="$3"
download_and_unpack_file $url $english_name
cd $english_name || exit "needs 2 parameters"
generic_configure_make_install "$extra_configure_options"
cd ..
}
generic_configure_make_install() {
generic_configure "$1"
do_make_and_make_install
}
generic_configure_rake_install() {
generic_configure "$1"
do_rake_and_rake_install
}
generic_configure_drake_install() {
generic_configure "$1"
do_drake_and_drake_install
}
generic_meson_ninja_install() {
generic_meson "$1"
do_ninja_and_ninja_install
}
do_ninja_and_ninja_install() {
local extra_ninja_options="$1"
do_ninja "$extra_ninja_options"
local touch_name=$(get_small_touchfile_name already_ran_make_install "$extra_ninja_options")
if [ ! -f $touch_name ]; then
echo "ninja installing $(pwd) as $ PATH=$PATH ninja --verbose -C build install $extra_make_options"
ninja --verbose -C build install || exit 1
touch $touch_name || exit 1
fi
}
do_ninja() {
local extra_make_options=" -j $cpu_count"
local cur_dir2=$(pwd)
local touch_name=$(get_small_touchfile_name already_ran_make "${extra_make_options}")
if [ ! -f $touch_name ]; then
echo
echo "ninja-ing $cur_dir2 as $ PATH=$PATH ninja --verbose -C build "${extra_make_options}"
echo
ninja --verbose -C build "${extra_make_options} || exit 1
touch $touch_name || exit 1 # only touch if the build was OK
else
echo "already did ninja $(basename "$cur_dir2")"
fi
}
do_make_and_make_install() {
local extra_make_options="$1"
do_make "$extra_make_options"
local touch_name=$(get_small_touchfile_name already_ran_make_install "$extra_make_options")
if [ ! -f $touch_name ]; then
echo "make installing $(pwd) as $ PATH=$PATH make install $extra_make_options"
make install $extra_make_options || exit 1
touch $touch_name || exit 1
fi
}
do_rake_and_rake_install() {
local extra_make_options="$1"
do_rake "$extra_make_options"
local touch_name=$(get_small_touchfile_name already_ran_make_install "$extra_make_options")
if [ ! -f $touch_name ]; then
echo "rake installing $(pwd) as $ PATH=$PATH rake install $extra_make_options"
rake install $extra_make_options || exit 1
touch $touch_name || exit 1
fi
}
do_drake_and_drake_install() {
local extra_make_options="$1"
do_drake "$extra_make_options"
local touch_name=$(get_small_touchfile_name already_ran_drake_install "$extra_make_options")
if [ ! -f $touch_name ]; then
echo "drake installing $(pwd) as $ PATH=$PATH drake install $extra_make_options"
drake install $extra_make_options || exit 1
touch $touch_name || exit 1
fi
}
do_cmake_and_install() {
extra_args="$1"
local touch_name=$(get_small_touchfile_name already_ran_cmake "$extra_args")
if [ ! -f $touch_name ]; then
rm -f already_* # reset so that make will run again if option just changed
local cur_dir2=$(pwd)
echo doing cmake in $cur_dir2 with PATH=$PATH with extra_args=$extra_args like this:
echo cmake $source_dir $extra_args -DBUILD_SHARED_LIBS=1 -DBUILD_STATIC_LIBS=0 -DENABLE_STATIC_RUNTIME=0 -DENABLE_SHARED_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=${cross_prefix}ranlib -DCMAKE_C_COMPILER=${cross_prefix}gcc -DCMAKE_CXX_COMPILER=${cross_prefix}g++ -DCMAKE_Fortran_COMPILER=${cross_prefix}gfortran -DCMAKE_RC_COMPILER=${cross_prefix}windres -DCMAKE_INSTALL_PREFIX=$mingw_w64_x86_64_prefix -DCMAKE_BUILD_TYPE=Release || exit 1
cmake $source_dir $extra_args -DBUILD_SHARED_LIBS=1 -DBUILD_STATIC_LIBS=0 -DENABLE_STATIC_RUNTIME=0 -DENABLE_SHARED_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=${cross_prefix}ranlib -DCMAKE_C_COMPILER=${cross_prefix}gcc -DCMAKE_CXX_COMPILER=${cross_prefix}g++ -DCMAKE_Fortran_COMPILER=${cross_prefix}gfortran -DCMAKE_RC_COMPILER=${cross_prefix}windres -DCMAKE_INSTALL_PREFIX=$mingw_w64_x86_64_prefix -DCMAKE_BUILD_TYPE=Release || exit 1
touch $touch_name || exit 1
fi
do_make_and_make_install
}
do_cleanup() {
# Removes all files in, and under, directory except those which
# prevent re-making
echo "Running do_cleanup in $(pwd)..."
find . ! \( -name 'already_*' -o -name 'unpacked.successfully' -o -name '*patch.done' \) -type f -exec rm -rf {} +
}
build_libsvthevc() {
do_git_checkout https://github.com/OpenVisualCloud/SVT-HEVC.git SVT-HEVC
cd SVT-HEVC
do_cmake
do_make
do_make_install
cd ..
}
build_libx265() {
if [ ! -f libx265.built ]; then
do_git_checkout https://bitbucket.org/multicoreware/x265_git.git x265 c8905a745633543a1a0df6044a09386057a95be2
cd x265
apply_patch file://${top_dir}/x265-CMakeVersion.patch
# apply_patch file://${top_dir}/x265-headers-revert.patch
cd ..
cd x265
cd source
mkdir -p 12bit 10bit 8bit
cd 12bit
local cmake_params="-DENABLE_STATIC=ON -DENABLE_SHARED=OFF -DENABLE_ASSEMBLY=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=1 -DEXPORT_C_API=0 -DENABLE_CLI=0 -DCMAKE_ASM_NASM_FLAGS=-w-macro-params-legacy"
do_cmake .. "$cmake_params"
do_make "V=1"
cp -vf libx265.a ../8bit/libx265_main12.a
cd ..
cd 10bit
local cmake_params="-DENABLE_STATIC=ON -DENABLE_SHARED=OFF -DENABLE_ASSEMBLY=ON -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=1 -DENABLE_CLI=0 -DEXPORT_C_API=0 -DCMAKE_ASM_NASM_FLAGS=-w-macro-params-legacy"
do_cmake .. "$cmake_params"
do_make "V=1"
cp -vf libx265.a ../8bit/libx265_main10.a
cd ..
cd 8bit
local cmake_params="-DENABLE_STATIC=ON -DENABLE_SHARED=OFF -DENABLE_ASSEMBLY=ON -DENABLE_CLI=1 -DEXTRA_LINK_FLAGS=-L -DLINKED_10BIT=1 -DLINKED_12BIT=1 -DCMAKE_ASM_NASM_FLAGS=-w-macro-params-legacy -DEXTRA_LIB='$(pwd)/libx265_main10.a;$(pwd)/libx265_main12.a'"
do_cmake .. "$cmake_params"
do_make "V=1"
mv -vf libx265.a libx265_main.a
${cross_prefix}ar -M <<EOF
CREATE libx265.a
ADDLIB libx265_main.a
ADDLIB libx265_main10.a
ADDLIB libx265_main12.a
SAVE
END
EOF
do_make_install
rm -vf libx265.dll.a libx265.dll
# Now we must make a shared DLL and install that.
${cross_prefix}g++ -v -shared -o libx265.dll -Wl,--whole-archive ./libx265.a -Wl,--whole-archive -Wl,--out-implib,libx265.dll.a -Wl,--no-whole-archive
cp -vf libx265.dll ${mingw_w64_x86_64_prefix}/bin
cp -vf libx265.dll.a ${mingw_w64_x86_64_prefix}/lib
cd ../..
cd ..
touch libx265.built
# local cmake_params="-DENABLE_SHARED=ON -DENABLE_STATIC=OFF -DENABLE_HDR10_PLUS=OFF -DENABLE_ASSEMBLY=ON -DHIGH_BIT_DEPTH=OFF -DCMAKE_C_FLAGS=-fpermissive -DCMAKE_CXX_FLAGS=-fpermissive -DLINKED_8BIT=OFF -DLINKED_10BIT=OFF -DENABLE_CLI=ON"
# local cmake_params="-DENABLE_SHARED=ON -DENABLE_STATIC=OFF -DENABLE_HDR10_PLUS=ON -DENABLE_ASSEMBLY=ON -DHIGH_BIT_DEPTH=ON -DCMAKE_C_FLAGS=-fpermissive -DCMAKE_CXX_FLAGS=-fpermissive -DLINKED_8BIT=ON -DLINKED_10BIT=ON -DENABLE_CLI=ON"
#if [[ $high_bitdepth == "y" ]]; then
# cmake_params="$cmake_params -DHIGH_BIT_DEPTH=ON -DMAIN12=ON" # Enable 10 bits (main10) and 12 bits (???) per pixels profiles.
# if grep "DHIGH_BIT_DEPTH=0" CMakeFiles/cli.dir/flags.make; then
# rm already_ran_cmake_* #Last build was not high bitdepth. Forcing rebuild.
# fi
#else
# if grep "DHIGH_BIT_DEPTH=1" CMakeFiles/cli.dir/flags.make; then
# rm already_ran_cmake_* #Last build was high bitdepth. Forcing rebuild.
# fi
#fi
# apply_patch_p1 file://${top_dir}/x265-missing-bool.patch
# Fixed by x265 developers now
# do_cmake "$cmake_params"
# x265 seems to fail on parallel builds
# export cpu_count=1
# do_make_install
# export cpu_count=$original_cpu_count
# cd ../..
# We must remove the x265.exe executable because FFmpeg gets linked against it. I do not understand this.
# Furthermore, this makes x265.exe as an executable completely unuseable.
# cp -v ${mingw_w64_x86_64_prefix}/bin/libx265.dll ${mingw_w64_x86_64_prefix}/bin/x265.exe
else
echo "libx265 already built."
fi
}
#x264_profile_guided=y
build_libx264() {
do_git_checkout https://github.com/mirror/x264.git x264
cd x264
local configure_flags="--host=$host_target --disable-static --enable-shared --cross-prefix=$cross_prefix --prefix=$mingw_w64_x86_64_prefix --disable-avs --disable-swscale --disable-lavf --disable-ffms --disable-gpac --bit-depths=all --chroma-format=all" # --enable-win32thread --enable-debug shouldn't hurt us since ffmpeg strips it anyway I think
# if [[ $high_bitdepth == "y" ]]; then
# configure_flags="$configure_flags --bit-depth=10" # Enable 10 bits (main10) per pixels profile.
# if grep -q "HIGH_BIT_DEPTH 0" config.h; then
# rm already_configured_* #Last build was not high bitdepth. Forcing reconfigure.
# fi
# else
# if grep -q "HIGH_BIT_DEPTH 1" config.h; then
# rm already_configured_* #Last build was high bitdepth. Forcing reconfigure.
# fi
# fi
# if [[ $x264_profile_guided = y ]]; then
# TODO more march=native here?
# TODO profile guided here option, with wine?
# do_configure "$configure_flags"
# curl http://samples.mplayerhq.hu/yuv4mpeg2/example.y4m.bz2 -O || exit 1
# rm example.y4m # in case it exists already...
# bunzip2 example.y4m.bz2 || exit 1
# XXX does this kill git updates? maybe a more general fix, since vid.stab does also?
# sed -i.bak "s_\\, ./x264_, wine ./x264_" Makefile # in case they have wine auto-run disabled http://askubuntu.com/questions/344088/how-to-ensure-wine-does-not-auto-run-exe-files
# do_make_install "fprofiled VIDS=example.y4m" # guess it has its own make fprofiled, so we don't need to manually add -fprofile-generate here...
# else
do_configure "$configure_flags"
do_make_install
# fi
cd ..
}
build_librtmp() {
# download_and_unpack_file http://rtmpdump.mplayerhq.hu/download/rtmpdump-2.3.tgz rtmpdump-2.3 # has some odd configure failure
# cd rtmpdump-2.3/librtmp
if [ ! -f rtmp_built ]; then
do_git_checkout git://git.ffmpeg.org/rtmpdump rtmpdump # 883c33489403ed360a01d1a47ec76d476525b49e # trunk didn't build once...this one i sstable
cd rtmpdump
sed -i.bak 's/SYS=posix/SYS=mingw/' Makefile
sed -i.bak 's/SYS=posix/SYS=mingw/' librtmp/Makefile
cd librtmp
do_make_install "CRYPTO=GNUTLS OPT=-O2 CROSS_COMPILE=$cross_prefix SHARED=yes prefix=$mingw_w64_x86_64_prefix SYS=mingw"
#make install CRYPTO=GNUTLS OPT='-O2 -g' "CROSS_COMPILE=$cross_prefix" SHARED=no "prefix=$mingw_w64_x86_64_prefix" || exit 1
sed -i.bak 's/-lrtmp -lz/-lrtmp -lwinmm -lz -lnettle -lgmp/' "$PKG_CONFIG_PATH/librtmp.pc"
cd ..
# TODO do_make here instead...
make SYS=mingw CRYPTO=GNUTLS OPT=-O2 CROSS_COMPILE=$cross_prefix SHARED=yes LIB_GNUTLS="`pkg-config --libs gnutls` -lz" || exit 1
# The makefile doesn't install
cp -fv rtmpdump.exe rtmpgw.exe rtmpsrv.exe rtmpsuck.exe "${mingw_w64_x86_64_prefix}/bin"
cd ..
touch rtmp_built
fi
}
build_pthread_stubs() {
do_git_checkout git://anongit.freedesktop.org/xcb/pthread-stubs pthread-stubs
cd pthread-stubs
generic_configure_make_install
cd ..
}
build_drm() {
do_git_checkout git://anongit.freedesktop.org/mesa/drm drm
cd drm
generic_configure_make_install
cd ..
}
build_qt6() {
download_and_unpack_file https://download.qt.io/official_releases/qt/6.6/6.6.2/submodules/qtbase-everywhere-src-6.6.2.tar.xz qtbase-everywhere-src-6.6.2
cd qtbase-everywhere-src-6.6.2
# cd qtbase
apply_patch_p1 https://src.fedoraproject.org/rpms/mingw-qt6-qtbase/raw/f40/f/qtbase-import-lib-suffix.patch
apply_patch_p1 https://src.fedoraproject.org/rpms/mingw-qt6-qtbase/raw/f40/f/qtbase-include-toolchain.patch
apply_patch_p1 https://src.fedoraproject.org/rpms/mingw-qt6-qtbase/raw/f40/f/qtbase-mingw.patch
apply_patch_p1 https://src.fedoraproject.org/rpms/mingw-qt6-qtbase/raw/f40/f/qtbase-qmakeconf.patch
apply_patch_p1 https://src.fedoraproject.org/rpms/mingw-qt6-qtbase/raw/f40/f/qtbase-readlink.patch
# cd ..
mkdir build
cd build
export MAKEFLAGS="-j8"
export PKG_CONFIG=${mingw_w64_x86_64_prefix}/../bin/x86_64-w64-mingw32-pkg-config
export PKG_CONFIG_LIBDIR=${mingw_w64_x86_64_prefix}/lib/pkgconfig
export PKG_CONFIG_SYSROOT_DIR=${mingw_w64_x86_64_prefix}
do_cmake ".. -G Ninja -B build -DQT_QMAKE_TARGET_MKSPEC=win32-g++ -DQT_BUILD_EXAMPLES=FALSE -DQT_BUILD_TESTS=FALSE -DQT_QMAKE_DEVICE_OPTIONS=CROSS_COMPILE=x86_64-w64-mingw32- -DCMAKE_BUILD_TYPE=Release -DFEATURE_pkg_config=ON -DQT_FEATURE_egl=OFF -DQT_FEATURE_fontconfig=ON -DQT_FEATURE_icu=ON -DQT_FEATURE_openssl_linked=ON -DQT_FEATURE_system_harfbuzz=OFF -DQT_FEATURE_system_sqlite=OFF -DQT_HOST_PATH=/usr/ -DQt6HostInfo_DIR=/usr/lib/x86_64-linux-gnu/cmake/Qt6HostInfo/ -DQt6CoreTools_DIR=/usr/lib/qt6/libexec/ -DQT_NO_PACKAGE_VERSION_CHECK=TRUE" # -DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=FALSE
# cmake --build build-x86_64-w64-mingw32
do_ninja_and_ninja_install
cd ..
cd ..
download_and_unpack_file https://download.qt.io/official_releases/qt/6.6/6.6.2/submodules/qtsvg-everywhere-src-6.6.2.tar.xz qtsvg-everywhere-src-6.6.2
cd qtsvg-everywhere-src-6.6.2
mkdir build
cd build
do_cmake ".. -G Ninja -B build -DQT_QMAKE_TARGET_MKSPEC=win32-g++ -DQT_NO_PACKAGE_VERSION_CHECK=TRUE -DQT_BUILD_EXAMPLES=FALSE -DQT_BUILD_TESTS=FALSE -DQT_QMAKE_DEVICE_OPTIONS=CROSS_COMPILE=x86_64-w64-mingw32"
do_ninja_and_ninja_install
cd ..
cd ..
download_and_unpack_file https://download.qt.io/official_releases/qt/6.6/6.6.2/submodules/qtshadertools-everywhere-src-6.6.2.tar.xz qtshadertools-everywhere-src-6.6.2
cd qtshadertools-everywhere-src-6.6.2
mkdir build
cd build
do_cmake ".. -G Ninja -B build -DQT_QMAKE_TARGET_MKSPEC=win32-g++ -DQT_NO_PACKAGE_VERSION_CHECK=TRUE -DQT_BUILD_EXAMPLES=FALSE -DQT_BUILD_TESTS=FALSE -DQT_QMAKE_DEVICE_OPTIONS=CROSS_COMPILE=x86_64-w64-mingw32"
do_ninja_and_ninja_install
cd ..