forked from rdp/ffmpeg-windows-build-helpers
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cross_compile_ffmpeg.sh
executable file
·2625 lines (2410 loc) · 113 KB
/
cross_compile_ffmpeg.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
# ffmpeg windows cross compile helper/download script, see github repo README
# Copyright (C) 2012 Roger Pack, the script is under the GPLv3, but output FFmpeg's executables aren't
# set -x
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]')
}
set_box_memory_size_bytes() {
if [[ $OSTYPE == darwin* ]]; then
box_memory_size_bytes=20000000000 # 20G fake it out for now :|
else
local ram_kilobytes=`grep MemTotal /proc/meminfo | awk '{print $2}'`
local swap_kilobytes=`grep SwapTotal /proc/meminfo | awk '{print $2}'`
box_memory_size_bytes=$[ram_kilobytes * 1024 + swap_kilobytes * 1024]
fi
}
function sortable_version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
at_least_required_version() { # params: required actual
local sortable_required=$(sortable_version $1)
sortable_required=$(echo $sortable_required | sed 's/^0*//') # remove preceding zeroes, which bash later interprets as octal or screwy
local sortable_actual=$(sortable_version $2)
sortable_actual=$(echo $sortable_actual | sed 's/^0*//')
[[ "$sortable_actual" -ge "$sortable_required" ]]
}
check_missing_packages () {
# We will need this later if we don't want to just constantly be grepping the /etc/os-release file
if [ -z "${VENDOR}" ] && grep -E '(centos|rhel)' /etc/os-release &> /dev/null; then
# In RHEL this should always be set anyway. But not so sure about CentOS
VENDOR="redhat"
fi
# zeranoe's build scripts use wget, though we don't here...
local check_packages=('ragel' 'curl' 'pkg-config' 'make' 'git' 'svn' 'gcc' 'autoconf' 'automake' 'yasm' 'cvs' 'flex' 'bison' 'makeinfo' 'g++' 'ed' 'hg' 'pax' 'unzip' 'patch' 'wget' 'xz' 'nasm' 'gperf' 'autogen' 'bzip2' 'realpath' 'meson')
# autoconf-archive is just for leptonica FWIW
# I'm not actually sure if VENDOR being set to centos is a thing or not. On all the centos boxes I can test on it's not been set at all.
# that being said, if it where set I would imagine it would be set to centos... And this contition will satisfy the "Is not initially set"
# case because the above code will assign "redhat" all the time.
if [ -z "${VENDOR}" ] || [ "${VENDOR}" != "redhat" ] && [ "${VENDOR}" != "centos" ]; then
check_packages+=('cmake')
fi
# libtool check is wonky...
if [[ $OSTYPE == darwin* ]]; then
check_packages+=('glibtoolize') # homebrew special :|
else
check_packages+=('libtoolize') # the rest of the world
fi
# Use hash to check if the packages exist or not. Type is a bash builtin which I'm told behaves differently between different versions of bash.
for package in "${check_packages[@]}"; do
hash "$package" &> /dev/null || missing_packages=("$package" "${missing_packages[@]}")
done
if [ "${VENDOR}" = "redhat" ] || [ "${VENDOR}" = "centos" ]; then
if [ -n "$(hash cmake 2>&1)" ] && [ -n "$(hash cmake3 2>&1)" ]; then missing_packages=('cmake' "${missing_packages[@]}"); fi
fi
if [[ -n "${missing_packages[@]}" ]]; then
clear
echo "Could not find the following execs (svn is actually package subversion, makeinfo is actually package texinfo, hg is actually package mercurial if you're missing them): ${missing_packages[*]}"
echo 'Install the missing packages before running this script.'
determine_distro
if [[ $DISTRO == "Ubuntu" ]]; then
echo "for ubuntu:"
echo "$ sudo apt-get update"
echo -n " $ sudo apt-get install subversion ragel curl texinfo g++ bison flex cvs yasm automake libtool autoconf gcc cmake git make pkg-config zlib1g-dev mercurial unzip pax nasm gperf autogen bzip2 autoconf-archive p7zip-full meson"
if at_least_required_version "18.04" "$(lsb_release -rs)"; then
echo -n " python3-distutils" # guess it's no longer built-in, lensfun requires it...
fi
echo " -y"
else
echo "for OS X (homebrew): brew install ragel wget cvs hg yasm autogen automake autoconf cmake libtool xz pkg-config nasm bzip2 autoconf-archive p7zip coreutils meson" # if edit this edit docker/Dockerfile also :|
echo "for debian: same as ubuntu, but also add libtool-bin, ed"
echo "for RHEL/CentOS: First ensure you have epel repo available, then run $ sudo yum install ragel subversion texinfo mercurial libtool autogen gperf nasm patch unzip pax ed gcc-c++ bison flex yasm automake autoconf gcc zlib-devel cvs bzip2 cmake3 -y"
echo "for fedora: if your distribution comes with a modern version of cmake then use the same as RHEL/CentOS but replace cmake3 with cmake."
echo "for linux native compiler option: same as <your OS> above, also add libva-dev"
fi
exit 1
fi
export REQUIRED_CMAKE_VERSION="3.0.0"
for cmake_binary in 'cmake' 'cmake3'; do
# We need to check both binaries the same way because the check for installed packages will work if *only* cmake3 is installed or
# if *only* cmake is installed.
# On top of that we ideally would handle the case where someone may have patched their version of cmake themselves, locally, but if
# the version of cmake required move up to, say, 3.1.0 and the cmake3 package still only pulls in 3.0.0 flat, then the user having manually
# installed cmake at a higher version wouldn't be detected.
if hash "${cmake_binary}" &> /dev/null; then
cmake_version="$( "${cmake_binary}" --version | sed -e "s#${cmake_binary}##g" | head -n 1 | tr -cd '[0-9.\n]' )"
if at_least_required_version "${REQUIRED_CMAKE_VERSION}" "${cmake_version}"; then
export cmake_command="${cmake_binary}"
break
else
echo "your ${cmake_binary} version is too old ${cmake_version} wanted ${REQUIRED_CMAKE_VERSION}"
fi
fi
done
# If cmake_command never got assigned then there where no versions found which where sufficient.
if [ -z "${cmake_command}" ]; then
echo "there where no appropriate versions of cmake found on your machine."
exit 1
else
# If cmake_command is set then either one of the cmake's is adequate.
echo "cmake binary for this build will be ${cmake_command}"
fi
if [[ ! -f /usr/include/zlib.h ]]; then
echo "warning: you may need to install zlib development headers first if you want to build mp4-box [on ubuntu: $ apt-get install zlib1g-dev] [on redhat/fedora distros: $ yum install zlib-devel]" # XXX do like configure does and attempt to compile and include zlib.h instead?
sleep 1
fi
# TODO nasm version :|
# doing the cut thing with an assigned variable dies on the version of yasm I have installed (which I'm pretty sure is the RHEL default)
# because of all the trailing lines of stuff
export REQUIRED_YASM_VERSION="1.2.0" # export ???
local yasm_binary=yasm
local yasm_version="$( "${yasm_binary}" --version |sed -e "s#${yasm_binary}##g" | head -n 1 | tr -dc '[0-9.\n]' )"
if ! at_least_required_version "${REQUIRED_YASM_VERSION}" "${yasm_version}"; then
echo "your yasm version is too old $yasm_version wanted ${REQUIRED_YASM_VERSION}"
exit 1
fi
local meson_version=`meson --version`
if ! at_least_required_version "0.47" "${meson_version}"; then
echo "your meson version is too old $meson_version wanted 0.47"
exit 1
fi
}
determine_distro() {
# Determine OS platform from https://askubuntu.com/a/459425/20972
UNAME=$(uname | tr "[:upper:]" "[:lower:]")
# If Linux, try to determine specific distribution
if [ "$UNAME" == "linux" ]; then
# If available, use LSB to identify distribution
if [ -f /etc/lsb-release -o -d /etc/lsb-release.d ]; then
export DISTRO=$(lsb_release -i | cut -d: -f2 | sed s/'^\t'//)
# Otherwise, use release info file
else
export DISTRO=$(ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v "lsb" | cut -d'/' -f3 | cut -d'-' -f1 | cut -d'_' -f1)
fi
fi
# For everything else (or if above failed), just use generic identifier
[ "$DISTRO" == "" ] && export DISTRO=$UNAME
unset UNAME
}
intro() {
echo `date`
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
echo
echo "Building in $PWD/sandbox, will use ~ 4GB space!"
echo
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 [libfdk_aac,decklink -- note that the internal AAC encoder is ruled almost as high a quality as fdk-aac these days]
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
echo "sit back, this may take awhile..."
}
pick_compiler_flavors() {
while [[ "$compiler_flavors" != [1-5] ]]; 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. Local native
5. Exit
EOF
echo -n 'Input your choice [1-5]: '
read compiler_flavors
done
case "$compiler_flavors" in
1 ) compiler_flavors=multi ;;
2 ) compiler_flavors=win32 ;;
3 ) compiler_flavors=win64 ;;
4 ) compiler_flavors=native ;;
5 ) echo "exiting"; exit 0 ;;
* ) clear; echo 'Your choice was not valid, please try again.'; echo ;;
esac
}
# made into a method so I don't/don't have to download this script every time if only doing just 32 or just6 64 bit builds...
download_gcc_build_script() {
local zeranoe_script_name=$1
rm -f $zeranoe_script_name || exit 1
curl -4 file://$patch_dir/$zeranoe_script_name -O --fail || exit 1
chmod u+x $zeranoe_script_name
}
install_cross_compiler() {
local win32_gcc="cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-gcc"
local win64_gcc="cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc"
if [[ -f $win32_gcc && -f $win64_gcc ]]; then
echo "MinGW-w64 compilers both already installed, not re-installing..."
if [[ -z $compiler_flavors ]]; then
echo "selecting multi build (both win32 and win64)...since both cross compilers are present assuming you want both..."
compiler_flavors=multi
fi
return # early exit they've selected at least some kind by this point...
fi
if [[ -z $compiler_flavors ]]; then
pick_compiler_flavors
fi
if [[ $compiler_flavors == "native" ]]; then
echo "native build, not building any cross compilers..."
return
fi
mkdir -p cross_compilers
cd cross_compilers
unset CFLAGS # don't want these "windows target" settings used the compiler itself since it creates executables to run on the local box (we have a parameter allowing them to set them for the script "all builds" basically)
# pthreads version to avoid having to use cvs for it
echo "Starting to download and build cross compile version of gcc [requires working internet access] with thread count $gcc_cpu_count..."
echo ""
# --disable-shared allows c++ to be distributed at all...which seemed necessary for some random dependency which happens to use/require c++...
local zeranoe_script_name=mingw-w64-build-r22.local
local zeranoe_script_options="--gcc-ver=8.3.0 --default-configure --cpu-count=$gcc_cpu_count --pthreads-w32-ver=2-9-1 --disable-shared --clean-build --verbose --allow-overwrite" # allow-overwrite to avoid some crufty prompts if I do rebuilds [or maybe should just nuke everything...]
if [[ ($compiler_flavors == "win32" || $compiler_flavors == "multi") && ! -f ../$win32_gcc ]]; then
echo "Building win32 cross compiler..."
download_gcc_build_script $zeranoe_script_name
if [[ `uname` =~ "5.1" ]]; then # Avoid using secure API functions for compatibility with msvcrt.dll on Windows XP.
sed -i "s/ --enable-secure-api//" $zeranoe_script_name
fi
nice ./$zeranoe_script_name $zeranoe_script_options --build-type=win32 || exit 1
if [[ ! -f ../$win32_gcc ]]; then
echo "Failure building 32 bit gcc? Recommend nuke sandbox (rm -rf sandbox) and start over..."
exit 1
fi
fi
if [[ ($compiler_flavors == "win64" || $compiler_flavors == "multi") && ! -f ../$win64_gcc ]]; then
echo "Building win64 x86_64 cross compiler..."
download_gcc_build_script $zeranoe_script_name
nice ./$zeranoe_script_name $zeranoe_script_options --build-type=win64 || exit 1
if [[ ! -f ../$win64_gcc ]]; then
echo "Failure building 64 bit gcc? Recommend nuke sandbox (rm -rf sandbox) and start over..."
exit 1
fi
fi
# rm -f build.log # leave resultant build log...sometimes useful...
reset_cflags
cd ..
echo "Done building (or already built) MinGW-w64 cross-compiler(s) successfully..."
echo `date` # so they can see how long it took :)
}
# helper methods for downloading and building projects that can take generic input
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 --non-interactive --trust-server-cert || 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
}
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/) # http://y/abc.git -> abc_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 || 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" # too slow'ish...
fi
fi
# reset will be useless if they didn't git_get_latest but pretty fast so who cares...plus what if they changed branches? :)
old_git_version=`git rev-parse HEAD`
if [[ -z $desired_branch ]]; then
desired_branch="origin/master"
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 # can't just use merge -f because might "think" patch files already applied when their changes have been lost, etc...
# vmaf on 16.04 needed that weird reset --hard? huh?
if git show-ref --verify --quiet "refs/remotes/origin/$desired_branch"; then # $desired_branch is actually a branch, not a tag or commit
git merge "origin/$desired_branch" || exit 1 # get incoming changes to a branch
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 # throw away results of patch files
git clean -f # throw away local changes; 'already_*' and bak-files for instance.
}
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 $LDFLAGS | /usr/bin/env md5sum)" # md5sum to make it smaller, cflags to force rebuild if changes
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"
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")
if [ ! -f "$touch_name" ]; then
# make uninstall # does weird things when run under ffmpeg src so disabled for now...
echo "configuring $english_name ($PWD) as $ PKG_CONFIG_PATH=$PKG_CONFIG_PATH PATH=$mingw_bin_path:\$PATH $configure_name $configure_options" # say it now in case bootstrap fails etc.
echo "all touch files" already_configured* touchname= "$touch_name"
echo "config options "$configure_options $configure_name""
if [ -f bootstrap ]; then
./bootstrap # some need this to create ./configure :|
fi
if [[ ! -f $configure_name && -f bootstrap.sh ]]; then # fftw wants to only run this if no configure :|
./bootstrap.sh
fi
if [[ ! -f $configure_name ]]; then
autoreconf -fiv # a handful of them require this to create ./configure :|
fi
rm -f already_* # reset
nice -n 5 "$configure_name" $configure_options || exit 1 # less nice (since single thread, and what if you're running another ffmpeg nice build elsewhere?)
touch -- "$touch_name"
echo "doing preventative make clean"
nice make clean -j $cpu_count # sometimes useful when files change, etc.
#else
# echo "already configured $(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=$mingw_bin_path:\$PATH make $extra_make_options"
echo
if [ ! -f configure ]; then
nice make clean -j $cpu_count # just in case helpful if old junk left around and this is a 're make' and wasn't cleaned at reconfigure time
fi
nice make $extra_make_options || exit 1
touch $touch_name || exit 1 # only touch if the build was OK
else
echo "Already made $(basename "$cur_dir2") ..."
fi
}
do_make_and_make_install() {
local extra_make_options="$1"
do_make "$extra_make_options"
do_make_install "$extra_make_options"
}
do_make_install() {
local extra_make_install_options="$1"
local override_make_install_options="$2" # startingly, some need/use something different than just 'make install'
if [[ -z $override_make_install_options ]]; then
local make_install_options="install $extra_make_install_options"
else
local make_install_options="$override_make_install_options $extra_make_install_options"
fi
local touch_name=$(get_small_touchfile_name already_ran_make_install "$make_install_options")
if [ ! -f $touch_name ]; then
echo "make installing $(pwd) as $ PATH=$mingw_bin_path:\$PATH make $make_install_options"
nice make $make_install_options || exit 1
touch $touch_name || exit 1
fi
}
do_cmake() {
extra_args="$1"
local build_from_dir="$2"
if [[ -z $build_from_dir ]]; then
build_from_dir="."
fi
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=$mingw_bin_path:\$PATH with extra_args=$extra_args like this:
if [[ $compiler_flavors != "native" ]]; then
local command="${build_from_dir} -DENABLE_STATIC_RUNTIME=1 -DBUILD_SHARED_LIBS=0 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_FIND_ROOT_PATH=$mingw_w64_x86_64_prefix -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -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 $extra_args"
else
local command="${build_from_dir} -DENABLE_STATIC_RUNTIME=1 -DBUILD_SHARED_LIBS=0 -DCMAKE_INSTALL_PREFIX=$mingw_w64_x86_64_prefix $extra_args"
fi
echo "doing ${cmake_command} -G\"Unix Makefiles\" $command"
nice -n 5 ${cmake_command} -G"Unix Makefiles" $command || exit 1
touch $touch_name || exit 1
fi
}
do_cmake_from_build_dir() { # some sources don't allow it, weird XXX combine with the above :)
source_dir="$1"
extra_args="$2"
do_cmake "$extra_args" "$source_dir"
}
do_cmake_and_install() {
do_cmake "$1"
do_make_and_make_install
}
do_meson() {
local configure_options="$1 --unity=off"
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_name" $configure_options || exit 1
touch -- "$touch_name"
make clean # just in case
else
echo "Already used meson $(basename $cur_dir2)"
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=static --cross-file=${top_dir}/meson-cross.mingw.txt $extra_configure_options . build"
}
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 -C build install $extra_make_options"
ninja -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 -C build "${extra_make_options}"
echo
ninja -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
}
apply_patch() {
local url=$1 # if you want it to use a local file instead of a url one [i.e. local file with local modifications] specify it like file://localhost/full/path/to/filename.patch
local patch_type=$2
if [[ -z $patch_type ]]; then
patch_type="-p0" # some are -p1 unfortunately, git's default
fi
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 # remove old version in case it has been since updated on the server...
fi
curl -4 --retry 5 $url -O --fail || echo_and_exit "unable to download patch file $url"
echo "applying patch $patch_name"
patch $patch_type < "$patch_name" || exit 1
touch $patch_done_name || exit 1
# too crazy, you can't do do_configure then apply a patch?
# rm -f 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" # too chatty
fi
}
echo_and_exit() {
echo "failure, exiting: $1"
exit 1
}
# takes a url, output_dir as params, output_dir optional
download_and_unpack_file() {
url="$1"
output_name=$(basename $url)
output_dir="$2"
if [[ -z $output_dir ]]; then
output_dir=$(basename $url | sed s/\.tar\.*//) # remove .tar.xx
fi
if [ ! -f "$output_dir/unpacked.successfully" ]; then
echo "downloading $url" # redownload in case failed...
if [[ -f $output_name ]]; then
rm $output_name || exit 1
fi
# From man curl
# -4, --ipv4
# If curl is capable of resolving an address to multiple IP versions (which it is if it is IPv6-capable),
# this option tells curl to resolve names to IPv4 addresses only.
# avoid a "network unreachable" error in certain [broken Ubuntu] configurations a user ran into once
# -L means "allow redirection" or some odd :|
curl -4 "$url" --retry 50 -O -L --fail || echo_and_exit "unable to download $url"
echo "unzipping $output_name ..."
tar -xf "$output_name" || unzip "$output_name" || exit 1
touch "$output_dir/unpacked.successfully" || exit 1
rm "$output_name" || exit 1
fi
}
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"
}
# params: url, optional "english name it will unpack to"
generic_download_and_make_and_install() {
local url="$1"
local english_name="$2"
if [[ -z $english_name ]]; then
english_name=$(basename $url | sed s/\.tar\.*//) # remove .tar.xx, take last part of url
fi
local extra_configure_options="$3"
download_and_unpack_file $url $english_name
cd $english_name || exit "unable to cd, may need to specify dir it will unpack to as parameter"
generic_configure "$extra_configure_options"
do_make_and_make_install
cd ..
}
do_git_checkout_and_make_install() {
local url=$1
local git_checkout_name=$(basename $url | sed s/\.git/_git/) # http://y/abc.git -> abc_git
do_git_checkout $url $git_checkout_name
cd $git_checkout_name
generic_configure_make_install
cd ..
}
generic_configure_make_install() {
if [ $# -gt 0 ]; then
echo "cant pass parameters to this method today, they'd be a bit ambiguous"
echo "The following arguments where passed: ${@}"
exit 1
fi
generic_configure # no parameters, force myself to break it up if needed
do_make_and_make_install
}
gen_ld_script() {
lib=$mingw_w64_x86_64_prefix/lib/$1
lib_s="$2"
if [[ ! -f $mingw_w64_x86_64_prefix/lib/lib$lib_s.a ]]; then
echo "Generating linker script $lib: $2 $3"
mv -f $lib $mingw_w64_x86_64_prefix/lib/lib$lib_s.a
echo "GROUP ( -l$lib_s $3 )" > $lib
fi
}
build_dlfcn() {
do_git_checkout https://github.com/dlfcn-win32/dlfcn-win32.git
cd dlfcn-win32_git
if [[ ! -f Makefile.bak ]]; then # Change CFLAGS.
sed -i.bak "s/-O3/-O2/" Makefile
fi
do_configure "--prefix=$mingw_w64_x86_64_prefix --cross-prefix=$cross_prefix" # rejects some normal cross compile options so custom here
do_make_and_make_install
gen_ld_script libdl.a dl_s -lpsapi # dlfcn-win32's 'README.md': "If you are linking to the static 'dl.lib' or 'libdl.a', then you would need to explicitly add 'psapi.lib' or '-lpsapi' to your linking command, depending on if MinGW is used."
cd ..
}
build_bzip2() {
download_and_unpack_file http://anduin.linuxfromscratch.org/LFS/bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
apply_patch file://$patch_dir/bzip2-1.0.6_brokenstuff.diff
if [[ ! -f $mingw_w64_x86_64_prefix/lib/libbz2.a ]]; then # Library only.
do_make "$make_prefix_options libbz2.a"
install -m644 bzlib.h $mingw_w64_x86_64_prefix/include/bzlib.h
install -m644 libbz2.a $mingw_w64_x86_64_prefix/lib/libbz2.a
else
echo "already made bzip2-1.0.6"
fi
cd ..
}
build_liblzma() {
download_and_unpack_file https://sourceforge.net/projects/lzmautils/files/xz-5.2.3.tar.xz
cd xz-5.2.3
generic_configure "--disable-xz --disable-xzdec --disable-lzmadec --disable-lzmainfo --disable-scripts --disable-doc --disable-nls"
do_make_and_make_install
cd ..
}
build_zlib() {
download_and_unpack_file https://github.com/madler/zlib/archive/v1.2.11.tar.gz zlib-1.2.11
cd zlib-1.2.11
do_configure "--prefix=$mingw_w64_x86_64_prefix --static"
if [[ $compiler_flavors == "native" ]]; then
do_make_and_make_install "$make_prefix_options" # can't take ARFLAGS...
else
do_make_and_make_install "$make_prefix_options ARFLAGS=rcs" # https://stackoverflow.com/questions/21396988/zlib-build-not-configuring-properly-with-cross-compiler-ignores-ar
fi
cd ..
}
build_iconv() {
download_and_unpack_file https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
cd libiconv-1.15
generic_configure "--disable-nls"
do_make "install-lib" # No need for 'do_make_install', because 'install-lib' already has install-instructions.
cd ..
}
build_sdl2() {
download_and_unpack_file http://libsdl.org/release/SDL2-2.0.5.tar.gz
cd SDL2-2.0.5
apply_patch file://$patch_dir/SDL2-2.0.5_lib-only.diff
#apply_patch file://$patch_dir/sdl2.xinput.diff # mingw-w64 master needs it?
if [[ ! -f configure.bak ]]; then
sed -i.bak "s/ -mwindows//" configure # Allow ffmpeg to output anything to console.
fi
export CFLAGS=-DDECLSPEC= # avoid SDL trac tickets 939 and 282 [broken shared builds], and not worried about optimizing yet...
generic_configure "--bindir=$mingw_bin_path"
do_make_and_make_install
if [[ ! -f $mingw_bin_path/$host_target-sdl2-config ]]; then
mv "$mingw_bin_path/sdl2-config" "$mingw_bin_path/$host_target-sdl2-config" # At the moment FFmpeg's 'configure' doesn't use 'sdl2-config', because it gives priority to 'sdl2.pc', but when it does, it expects 'i686-w64-mingw32-sdl2-config' in 'cross_compilers/mingw-w64-i686/bin'.
fi
reset_cflags
cd ..
}
build_amd_amf_headers() {
# was https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git too big
# or https://github.com/DeadSix27/AMF smaller
# but even smaller!
do_git_checkout https://github.com/rdp/amf_headers.git amf_headers_git
cd amf_headers_git
if [ ! -f "already_installed" ]; then
#rm -rf "./Thirdparty" # ?? plus too chatty...
if [ ! -d "$mingw_w64_x86_64_prefix/include/AMF" ]; then
mkdir -p "$mingw_w64_x86_64_prefix/include/AMF"
fi
cp -av "amf/public/include/." "$mingw_w64_x86_64_prefix/include/AMF"
touch "already_installed"
fi
cd ..
}
build_nv_headers() {
do_git_checkout https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers_git
do_make_install "PREFIX=$mingw_w64_x86_64_prefix" # just copies in headers
cd ..
}
build_intel_quicksync_mfx() { # i.e. qsv, disableable via command line switch...
do_git_checkout https://github.com/lu-zero/mfx_dispatch.git # lu-zero?? oh well seems somewhat supported...
cd mfx_dispatch_git
if [[ ! -f "configure" ]]; then
autoreconf -fiv || exit 1
automake --add-missing || exit 1
fi
if [[ $compiler_flavors == "native" && $OSTYPE != darwin* ]]; then
unset PKG_CONFIG_LIBDIR # allow mfx_dispatch to use libva-dev or some odd...not sure for OS X so just disable it :)
generic_configure_make_install
export PKG_CONFIG_LIBDIR=
else
generic_configure_make_install
fi
cd ..
}
build_libleptonica() {
build_libjpeg_turbo
do_git_checkout https://github.com/DanBloomberg/leptonica.git
cd leptonica_git
generic_configure "--without-libopenjpeg" # never could quite figure out how to get it to work with jp2 stuffs...I think OPJ_STATIC or something, see issue for tesseract
do_make_and_make_install
cd ..
}
build_libtiff() {
build_libjpeg_turbo # auto uses it?
generic_download_and_make_and_install http://download.osgeo.org/libtiff/tiff-4.0.9.tar.gz
sed -i.bak 's/-ltiff.*$/-ltiff -llzma -ljpeg -lz/' $PKG_CONFIG_PATH/libtiff-4.pc # static deps
}
build_libtensorflow() {
do_git_checkout_and_make_install https://github.com/tensorflow/tensorflow.git
}
build_glib() {
export CPPFLAGS='-DLIBXML_STATIC' # gettext build...
generic_download_and_make_and_install https://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.xz
unset CPPFLAGS
generic_download_and_make_and_install http://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz # also dep
download_and_unpack_file https://ftp.gnome.org/pub/gnome/sources/glib/2.56/glib-2.56.3.tar.xz # there's a 2.58 but guess I'd need to use meson for that, too complicated...also didn't yet contain the DllMain patch I believe, so no huge win...
cd glib-2.56.3
export CPPFLAGS='-liconv -pthread' # I think gettext wanted this but has no .pc file??
if [[ $compiler_flavors != "native" ]]; then # seemingly unneeded for OS X
apply_patch file://$patch_dir/glib_msg_fmt.patch # needed for configure
apply_patch file://$patch_dir/glib-prefer-constructors-over-DllMain.patch # needed for static. weird.
fi
generic_configure "--with-pcre=internal" # too lazy for pcre :) XXX
unset CPPFLAGS
do_make_and_make_install
cd ..
}
build_lensfun() {
build_glib
download_and_unpack_file https://sourceforge.net/projects/lensfun/files/0.3.95/lensfun-0.3.95.tar.gz
cd lensfun-0.3.95
export CMAKE_STATIC_LINKER_FLAGS='-lws2_32 -pthread'
do_cmake "-DBUILD_STATIC=on -DCMAKE_INSTALL_DATAROOTDIR=$mingw_w64_x86_64_prefix"
do_make
do_make_install
sed -i.bak 's/-llensfun/-llensfun -lstdc++/' "$PKG_CONFIG_PATH/lensfun.pc"
unset CMAKE_STATIC_LINKER_FLAGS
cd ..
}
build_libtesseract() {
build_libleptonica
build_libtiff # no disable configure option for this in tesseract? odd...
do_git_checkout https://github.com/tesseract-ocr/tesseract.git tesseract_git a2e72f258a3bd6811cae226a01802d # #315
cd tesseract_git
generic_configure_make_install
if [[ $compiler_flavors != "native" ]]; then
sed -i.bak 's/-ltesseract.*$/-ltesseract -lstdc++ -lws2_32 -llept -ltiff -llzma -ljpeg -lz/' $PKG_CONFIG_PATH/tesseract.pc # why does it needs winsock? LOL plus all of libtiff's <sigh>
else
sed -i.bak 's/-ltesseract.*$/-ltesseract -lstdc++ -llept -ltiff -llzma -ljpeg -lz -lgomp/' $PKG_CONFIG_PATH/tesseract.pc # see above, gomp for linux native
fi
cd ..
}
build_libzimg() {
do_git_checkout https://github.com/sekrit-twc/zimg.git zimg_git 8e87f5a4b88e16ccafb2e7ade8ef45
cd zimg_git
generic_configure_make_install
cd ..
}
build_libopenjpeg() {
do_git_checkout https://github.com/uclouvain/openjpeg.git # basically v2.3+
cd openjpeg_git
do_cmake_and_install "-DBUILD_CODEC=0"
cd ..
}
build_libpng() {
do_git_checkout https://github.com/glennrp/libpng.git
cd libpng_git
generic_configure
do_make_and_make_install
cd ..
}
build_libwebp() {
do_git_checkout https://chromium.googlesource.com/webm/libwebp.git
cd libwebp_git
export LIBPNG_CONFIG="$mingw_w64_x86_64_prefix/bin/libpng-config --static" # LibPNG somehow doesn't get autodetected.
generic_configure "--disable-wic"
do_make_and_make_install
unset LIBPNG_CONFIG
cd ..
}
build_harfbuzz() {
# basically gleaned from https://gist.github.com/roxlu/0108d45308a0434e27d4320396399153
if [ ! -f harfbuzz_git/already_done_harf ]; then # TODO make freetype into separate dirs so I don't need this weird double hack file...
build_freetype "--without-harfbuzz"
do_git_checkout https://github.com/harfbuzz/harfbuzz.git harfbuzz_git 8b6eb6cf465032d0ca747f4b75f6e9155082bc45
# cmake no .pc file :|
cd harfbuzz_git
if [ ! -f configure ]; then
./autogen.sh # :|
fi
generic_configure "--with-freetype=yes --with-fontconfig=no --with-icu=no" # no fontconfig, don't want another circular what? icu is #372
do_make_and_make_install
cd ..
build_freetype "--with-harfbuzz" # with harfbuzz now...
touch harfbuzz_git/already_done_harf
echo "done harfbuzz"
fi
sed -i.bak 's/-lfreetype.*/-lfreetype -lharfbuzz/' "$PKG_CONFIG_PATH/freetype2.pc"
sed -i.bak 's/-lharfbuzz.*/-lharfbuzz -lfreetype/' "$PKG_CONFIG_PATH/harfbuzz.pc"
sed -i.bak 's/libfreetype.la -lbz2/libfreetype.la -lharfbuzz -lbz2/' "${mingw_w64_x86_64_prefix}/lib/libfreetype.la" # XXX what the..needed?
sed -i.bak 's/libfreetype.la -lbz2/libfreetype.la -lharfbuzz -lbz2/' "${mingw_w64_x86_64_prefix}/lib/libharfbuzz.la"
}
build_freetype() {
download_and_unpack_file https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2
cd freetype-2.8
# harfbuzz autodetect :|
generic_configure "--with-bzip2 $1"
do_make_and_make_install
cd ..
}
build_libxml2() {
download_and_unpack_file http://xmlsoft.org/sources/libxml2-2.9.4.tar.gz libxml2-2.9.4
cd libxml2-2.9.4
if [[ ! -f libxml.h.bak ]]; then # Otherwise you'll get "libxml.h:...: warning: "LIBXML_STATIC" redefined". Not an error, but still.
sed -i.bak "/NOLIBTOOL/s/.*/& \&\& !defined(LIBXML_STATIC)/" libxml.h
fi
generic_configure "--with-ftp=no --with-http=no --with-python=no"
do_make_and_make_install
cd ..
}
build_libvmaf() {
do_git_checkout https://github.com/Netflix/vmaf.git vmaf_git 2ded988de0356a09b65bbb8e14bd625aff29c332 # before "reorg" killed our patch
cd vmaf_git
apply_patch file://$patch_dir/libvmaf.various.patch -p1
do_make_and_make_install "$make_prefix_options INSTALL_PREFIX=$mingw_w64_x86_64_prefix"
# .pc seems broke
sed -i.bak "s:/usr/local:$mingw_w64_x86_64_prefix:" "$PKG_CONFIG_PATH/libvmaf.pc"
cd ..
}
build_fontconfig() {
download_and_unpack_file https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.4.tar.gz
cd fontconfig-2.12.4
#export CFLAGS= # compile fails with -march=sandybridge ... with mingw 4.0.6 at least ...
generic_configure "--enable-iconv --enable-libxml2 --disable-docs --with-libiconv" # Use Libxml2 instead of Expat.
do_make_and_make_install
#reset_cflags
cd ..
}
build_gmp() {
download_and_unpack_file https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz
cd gmp-6.1.2
#export CC_FOR_BUILD=/usr/bin/gcc # Are these needed?
#export CPP_FOR_BUILD=usr/bin/cpp
generic_configure "ABI=$bits_target"
#unset CC_FOR_BUILD
#unset CPP_FOR_BUILD
do_make_and_make_install
cd ..
}
build_librtmfp() {
# needs some version of openssl...
# build_openssl-1.0.2 # fails OS X
build_openssl-1.1.1
do_git_checkout https://github.com/MonaSolutions/librtmfp.git
cd librtmfp_git/include/Base
do_git_checkout https://github.com/meganz/mingw-std-threads.git mingw-std-threads # our g++ apparently doesn't have std::mutex baked in...weird...this replaces it...
cd ../../..
cd librtmfp_git
if [[ $compiler_flavors != "native" ]]; then
apply_patch file://$patch_dir/rtmfp.static.cross.patch -p1 # works e48efb4f
apply_patch file://$patch_dir/rtmfp_capitalization.diff -p1 # cross for windows needs it if on linux...
apply_patch file://$patch_dir/librtmfp_xp.diff.diff -p1 # cross for windows needs it if on linux...
else
apply_patch file://$patch_dir/rtfmp.static.make.patch -p1
fi
do_make "$make_prefix_options GPP=${cross_prefix}g++"
do_make_install "prefix=$mingw_w64_x86_64_prefix PKGCONFIGPATH=$PKG_CONFIG_PATH"
if [[ $compiler_flavors == "native" ]]; then
sed -i.bak 's/-lrtmfp.*/-lrtmfp -lstdc++/' "$PKG_CONFIG_PATH/librtmfp.pc"
else
sed -i.bak 's/-lrtmfp.*/-lrtmfp -lstdc++ -lws2_32 -liphlpapi/' "$PKG_CONFIG_PATH/librtmfp.pc"
fi
cd ..
}
build_libnettle() {
download_and_unpack_file https://ftp.gnu.org/gnu/nettle/nettle-3.4.tar.gz
cd nettle-3.4
generic_configure "--disable-openssl --disable-documentation" # in case we have both gnutls and openssl, just use gnutls [except that gnutls uses this so...huh? https://github.com/rdp/ffmpeg-windows-build-helpers/issues/25#issuecomment-28158515
do_make_and_make_install # What's up with "Configured with: ... --with-gmp=/cygdrive/d/ffmpeg-windows-build-helpers-master/native_build/windows/ffmpeg_local_builds/sandbox/cross_compilers/pkgs/gmp/gmp-6.1.2-i686" in 'config.log'? Isn't the 'gmp-6.1.2' above being used?
cd ..
}
build_libidn() {
generic_download_and_make_and_install https://ftp.gnu.org/gnu/libidn/libidn-1.35.tar.gz
}
build_gnutls() {
download_and_unpack_file https://www.gnupg.org/ftp/gcrypt/gnutls/v3.5/gnutls-3.5.19.tar.xz
cd gnutls-3.5.19
# --disable-cxx don't need the c++ version, in an effort to cut down on size... XXXX test size difference...
# --enable-local-libopts to allow building with local autogen installed,
# --disable-guile is so that if it finds guile installed (cygwin did/does) it won't try and link/build to it and fail...
# libtasn1 is some dependency, appears provided is an option [see also build_libnettle]
# pks #11 hopefully we don't need kit
generic_configure "--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"
do_make_and_make_install
if [[ $compiler_flavors != "native" ]]; then
# libsrt doesn't know how to use its pkg deps :| https://github.com/Haivision/srt/issues/565
sed -i.bak 's/-lgnutls.*/-lgnutls -lcrypt32 -lnettle -lhogweed -lgmp -lidn -liconv/' "$PKG_CONFIG_PATH/gnutls.pc"
else
if [[ $OSTYPE == darwin* ]]; then
sed -i.bak 's/-lgnutls.*/-lgnutls -framework Security -framework Foundation/' "$PKG_CONFIG_PATH/gnutls.pc"
fi # else linux needs nothing...
fi