-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathautogen.sh
executable file
·1612 lines (1440 loc) · 71.1 KB
/
autogen.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
#!/bin/bash
ENABLE_LATEST=0 #Force using latest gstreamer build and static link. enabled using --enable-latest
ENABLE_LIBAV=0 #Enables building and linking Gstreamer libav plugin. enabled using --enable-libav
ENABLE_NVCODEC=0 #Enables building and linking Gstreamer nvidia pluging. enabled using --enable-nvcodec
ENABLE_DEBUG=1 #Disables debug build flag. disabled using --no-debug
NO_DOWNLOAD=0
WGET_CMD="wget" #Default wget command. Gets properly initialized later with parameters adequate for its version
#Save current working directory to run configure in
WORK_DIR=$(pwd)
#Get project root directory based on autogen.sh file location
SCRT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
if [[ $SCRT_DIR = *" "* ]]; then #This is an autoconf workaround to support whitespace in $PATH
printError project="onvifmgr" task="init" msg="Whitespace found in current working directory."$'\n'"please move the project to a location without whitespace in its path."
exit 1
fi
SUBPROJECT_DIR=$SCRT_DIR/subprojects
#Cache folder for downloaded sources
SRC_CACHE_DIR=$SUBPROJECT_DIR/.cache
# Define color code constants
YELLOW='\033[0;33m'
BHIGREEN='\x1b[38;5;118m'
RED='\033[0;31m'
NC='\033[0m' # No Color
CYAN='\033[0;36m'
GREEN='\033[0;32m'
#Failure marker
FAILED=0
script_start=$SECONDS
i=1;
for arg in "$@"
do
shift
if [ "$arg" == "--enable-libav=yes" ] || [ "$arg" == "--enable-libav=true" ] || [ "$arg" == "--enable-libav" ]; then
ENABLE_LIBAV=1
set -- "$@" "$arg"
elif [ "$arg" == "--enable-latest" ]; then
ENABLE_LATEST=1
set -- "$@" "$arg"
elif [ "$arg" == "--no-debug" ]; then
ENABLE_DEBUG=0
elif [ "$arg" == "--enable-nvcodec=yes" ] || [ "$arg" == "--enable-nvcodec=true" ] || [ "$arg" == "--enable-nvcodec" ]; then
ENABLE_NVCODEC=1
set -- "$@" "$arg"
elif [ "$arg" == "--no-download" ]; then
NO_DOWNLOAD=1
else
set -- "$@" "$arg"
fi
i=$((i + 1));
done
#Set debug flag on current project
[ $ENABLE_DEBUG -eq 1 ] && set -- "$@" "--enable-debug=yes"
unbufferCall(){
if [ ! -z "$UNBUFFER_COMMAND" ]; then
eval "unbuffer ${@}"
else
script -efq -c "$(printf "%s" "${@}")"
fi
}
##############################
# Function to decorate lines with project, task and color
# It handles targeted ANSI and VT codes to maintain appropriate decoration
# Codes : \r, \n, ^[[1K, ^[[2K, ^[<n>G
##############################
CSI_G_REGEX='^\[([0-9][0-9]*)G' #CSI <n> G: Cursor horizontal absolute
VT_CLEARLINE_REGEX='^\[[{1}|{2}]K' #EL1 clearbol & EL2 clearline
printline(){
local project task color padding prefix val escape_buff
local "${@}"
line="" #Reset variable before using it
escape_marker=0
escape_buff=""
carriage_returned=1
while IFS= read -rn1 data; do
if [[ "$data" == *\* ]]; then #escape codes flag
if [ ! -z "$escape_buff" ]; then #save previous parsed escape code for later flush
line="$line""$escape_buff"
escape_buff=""
fi
escape_marker=1 #Reset marker
elif [ -z "$data" ]; then #Newline, Flush buffer with newline
if [ $carriage_returned -eq 1 ]; then
printf "${GREEN}${project}${CYAN} ${task}${color}${prefix}${padding}%s%s${NC}"$'\n'$'\r' "$line" "$escape_buff" >&2
else
printf "%s%s"$'\n'$'\r' "$line" "$escape_buff" >&2
fi
escape_marker=0
escape_buff=""
line=""
carriage_returned=1
elif [ "$data" == $'\r' ]; then #Carriage return. Flush buffer
if [ $carriage_returned -eq 1 ]; then
printf "${GREEN}${project}${CYAN} ${task}${color}${prefix}${padding}%s%s${NC}"$'\r' "$line" "$escape_buff" >&2
else
printf "%s%s"$'\r' "$line" "$escape_buff" >&2
fi
escape_marker=0
escape_buff=""
line=""
carriage_returned=1
elif [ $escape_marker -gt 0 ]; then #Seperated the rest of the condition to save on performance
escape_buff+=$data
((escape_marker++))
if [ $escape_marker -eq 4 ] && [[ "$escape_buff" =~ $VT_CLEARLINE_REGEX ]]; then
printf "%s%s" "$line" "$escape_buff"
escape_marker=0
escape_buff=""
line=""
carriage_returned=1
elif [ $escape_marker -ge 4 ] && [[ $escape_buff =~ $CSI_G_REGEX ]]; then
val=${BASH_REMATCH[1]}
((val+=${#project})) #Adjust adsolute positioning after project and task label
((val+=${#task}))
((val+=${#padding}))
((val++))
escape_buff="["$val"G"
printf "%s%s" "$line" "$escape_buff" #Print without decoaration since we moved after prefix
line=""
escape_marker=0
escape_buff=""
carriage_returned=0
elif [ $escape_marker -ge 5 ]; then #No processing of any other escape code
escape_marker=0
line="$line""$escape_buff"
escape_buff=""
else
continue;
fi
elif [ ! -z "$data" ]; then #Save regular character for later flush
line="$line""$data"
fi
done;
#Flush remaining buffers
if [ ! -z "$line" ]; then
printf "%s" "$line"
fi
if [ ! -z "$escape_buff" ]; then
printf "%s" "$escape_buff"
fi
}
printlines(){
local project task msg color padding prefix
local "${@}"
#Init default color string
[[ ! -z "${color}" ]] && incolor="${color}" || incolor="${NC}"
#Init padding string
if [[ -z "${padding}" || ! "${padding}" == ?(-)+([[:digit:]]) ]]; then padding=1; fi
inpadding="" && for i in {1..$padding}; do inpadding=$inpadding" "; done
if [ ! -z "${msg}" ]; then
echo "${msg}" | printline project="${project}" task="${task}" color="${incolor}" padding="${inpadding}" prefix="${prefix}"
else
printline project="${project}" task="${task}" color="${incolor}" padding="${inpadding}" prefix="${prefix}"
fi
}
printError(){
local msg project task
local "${@}"
printlines project="${project}" task="${task}" color=${RED} msg="*****************************"
printlines project="${project}" task="${task}" color=${RED} prefix=" * " msg="${msg}"
printlines project="${project}" task="${task}" color=${RED} prefix=" * " padding=4 msg="Kernel: $(uname -r)"
printlines project="${project}" task="${task}" color=${RED} prefix=" * " padding=4 msg="Kernel: $(uname -i)"
#Doesnt exist on REHL
# printlines project="${project}" task="${task}" color=${RED} prefix=" * " padding=4 msg="$(lsb_release -a 2> /dev/null)"
printlines project="${project}" task="${task}" color=${RED} msg="*****************************"
}
printNotice(){
local msg project task color
local "${@}"
[[ ! -z "${color}" ]] && incolor="${color}" || incolor="${BHIGREEN}"
printlines project="${project}" task="${task}" color=${incolor} msg="*****************************"
printlines project="${project}" task="${task}" color=${incolor} prefix=" * " msg="${msg}"
printlines project="${project}" task="${task}" color=${incolor} msg="*****************************"
}
############################################
#
# Function to print time for human
#
############################################
function displaytime {
local time project task msg label
local "${@}"
local T=${time}
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
[[ ! -z "${msg}" ]] && output="${msg}"$'\n'$'\n'$label || output="$label"
(( $D > 0 )) && output=$output"$D days "
(( $H > 0 )) && output=$output"$H hours "
(( $M > 0 )) && output=$output"$M minutes "
(( $D > 0 || $H > 0 || $M > 0 )) && output=$output"and "
output=$output"$S seconds"
printNotice project="${project}" task="${task}" msg="$output"
}
############################################
#
# Function to download and extract tar package file
# Can optionally use a caching folder defined with SRC_CACHE_DIR
#
############################################
downloadAndExtract (){
local project path file forcedownload noexit # reset first
local "${@}"
if [ -z "${forcedownload}" ] && [ $NO_DOWNLOAD -eq 1 ]; then
printError project="${project}" task="wget" msg="download disabled. Missing dependency $file"
[[ ! -z "${noexit}" ]] && FAILED=1 && return || exit 1;
fi
[ ! -z "$SRC_CACHE_DIR" ] && pathprefix="$SRC_CACHE_DIR/" || pathprefix=""
if [ ! -f "$dest_val" ]; then
printlines project="${project}" task="wget" msg="downloading: ${path}"
cd "$pathprefix" #Changing directory so that wget logs only the filename
$WGET_CMD ${path} -O ${file} 2>&1 | printlines project="${project}" task="wget";
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="wget" msg="failed to fetch ${path}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
cd "$OLDPWD"
else
printlines project="${project}" task="wget" msg="source already downloaded"
fi
printlines project="${project}" task="wget" msg="extracting : ${file}"
if [[ "${pathprefix}${file}" == *.tar.gz ]]; then
tar xfz "${pathprefix}${file}" 2>&1 | printlines project="${project}" task="extract";
elif [[ "${pathprefix}${file}" == *.tar.xz ]]; then
tar xf "${pathprefix}${file}" 2>&1 | printlines project="${project}" task="extract";
elif [[ "${pathprefix}${file}" == *.tar.bz2 ]]; then
tar xjf "${pathprefix}${file}" 2>&1 | printlines project="${project}" task="extract";
elif [[ "${pathprefix}${file}" == *.zip ]]; then
checkUnzip
unzip -oq "${pathprefix}${file}" 2>&1 | printlines project="${project}" task="extract";
else
printError project="${project}" task="wget" msg="downloaded file not found. ${file}"
[[ ! -z "${noexit}" ]] && FAILED=1 && return || exit 1;
fi
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="extract" msg="failed to extract ${file}"
[[ ! -z "${noexit}" ]] && FAILED=1 && return || exit 1;
fi
}
############################################
#
# Function to clone a git repository or pull if it already exists locally
# Can optionally use a caching folder defined with SRC_CACHE_DIR
#
############################################
privatepullOrClone(){
local project path dest tag recurse depth # reset first
local "${@}"
tgstr=""
tgstr2=""
if [ ! -z "${tag}" ]
then
tgstr="origin tags/${tag}"
tgstr2="-b ${tag}"
fi
recursestr=""
if [ ! -z "${recurse}" ]
then
recursestr="--recurse-submodules"
fi
depthstr=""
if [ ! -z "${depth}" ]
then
depthstr="--depth ${depth}"
fi
should_clone=1
if [ -d ${dest} ]; then
unbufferCall "git -C ${dest} pull ${tgstr}" 2> /dev/null | printlines project="${project}" task="git"
should_clone=${PIPESTATUS[0]}
if [ $should_clone -ne 0 ]; then #Something failed. Remove to redownload
rm -rf ${dest}
fi
fi
if [ $should_clone -ne 0 ]; then
unbufferCall "git clone -j$(nproc) $recursestr $depthstr $tgstr2 ${path} $dest" 2>&1 | printlines project="${project}" task="git"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="git" msg="failed to fetch ${path}"
[[ ! -z "${noexit}" ]] && FAILED=1 && return || exit 1;
fi
fi
}
pullOrClone (){
local project path tag depth recurse ignorecache forcedownload noexit # reset first
local "${@}"
if [ -z "${forcedownload}" ] && [ $NO_DOWNLOAD -eq 1 ]; then
printError project="${project}" task="git" msg="Download disabled. Missing dependency $path"
[[ ! -z "${noexit}" ]] && FAILED=1 && return || exit 1
fi
printlines project="${project}" task="git" msg="clone ${tag}@${path}"
IFS='/' read -ra ADDR <<< "$path"
namedotgit=${ADDR[-1]}
IFS='.' read -ra ADDR <<< "$namedotgit"
name=${ADDR[0]}
dest_val=""
if [ ! -z "$SRC_CACHE_DIR" ] && [ -z "${ignorecache}" ]; then
dest_val="$SRC_CACHE_DIR/$name"
else
dest_val=$name
fi
if [ ! -z "${tag}" ]; then
dest_val+="-${tag}"
fi
if [ -z "$SRC_CACHE_DIR" ] || [ -z "${ignorecache}" ]; then
#TODO Check if it's the right tag
privatepullOrClone project="${project}" dest=$dest_val tag=$tag depth=$depth recurse=$recurse path=$path
elif [ -d "$dest_val" ] && [ ! -z "${tag}" ]; then #Folder exist, switch to tag
currenttag=$(git -C $dest_val tag --points-at ${tag})
printlines project="${project}" task="git" msg="TODO Check current tag \"${tag}\" == \"$currenttag\""
privatepullOrClone project="${project}" dest=$dest_val tag=$tag depth=$depth recurse=$recurse path=$path
elif [ -d "$dest_val" ] && [ -z "${tag}" ]; then #Folder exist, switch to main
currenttag=$(git -C $dest_val tag --points-at ${tag})
printlines project="${project}" task="git" msg="TODO Handle no tag \"${tag}\" == \"$currenttag\""
privatepullOrClone project="${project}" dest=$dest_val tag=$tag depth=$depth recurse=$recurse path=$path
elif [ ! -d "$dest_val" ]; then #fresh start
privatepullOrClone project="${project}" dest=$dest_val tag=$tag depth=$depth recurse=$recurse path=$path
else
if [ -d "$dest_val" ]; then
printlines project="${project}" task="git" msg="yey destval"
fi
if [ -z "${tag}" ]; then
printlines project="${project}" task="git" msg="yey tag"
fi
printlines project="${project}" task="git" msg="1 $dest_val : $(test -f \"$dest_val\")"
printlines project="${project}" task="git" msg="2 ${tag} : $(test -z \"${tag}\")"
fi
if [ $FAILED -eq 0 ] && [ ! -z "$SRC_CACHE_DIR" ] && [ -z "${ignorecache}" ]; then
printlines project="${project}" task="git" msg="copy repo from cache"$"$dest_val"
rm -rf "$name"
cp -r "$dest_val" "./$name"
fi
}
############################################
#
# Function to build a project configured with autotools
#
############################################
buildMakeProject(){
local project srcdir prefix autogen autoreconf configure make cmakedir cmakeargs cmakeclean installargs skipbootstrap bootstrap configcustom outoftree noexit
local "${@}"
build_start=$SECONDS
printlines project="${project}" task="build" msg="src: '${srcdir}'"
printlines project="${project}" task="build" msg="prefix: '${prefix}'"
if [ "${outoftree}" == "true" ]
then
mkdir -p "${srcdir}/build"
cd "${srcdir}/build"
rel_path=".."
else
cd "${srcdir}"
rel_path="."
fi
if [ -f "$rel_path/bootstrap" ] && [ -z "${skipbootstrap}" ]; then
printlines project="${project}" task="bootstrap" msg="src: ${srcdir}"
unbufferCall "$rel_path/bootstrap ${bootstrap}" 2>&1 | printlines project="${project}" task="bootstrap"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="bootstrap" msg="$rel_path/bootstrap failed ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
fi
if [ -f "$rel_path/bootstrap.sh" ]; then
printlines project="${project}" task="bootstrap.sh" msg="src: ${srcdir}"
unbufferCall "$rel_path/bootstrap.sh ${bootstrap}" 2>&1 | printlines project="${project}" task="bootstrap.sh"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="bootstrap.sh" msg="$rel_path/bootstrap.sh failed ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
fi
if [ -f "$rel_path/autogen.sh" ] && [ "${autogen}" != "skip" ]; then
printlines project="${project}" task="autogen.sh" msg="src: ${srcdir}"
unbufferCall "$rel_path/autogen.sh ${autogen}" 2>&1 | printlines project="${project}" task="autogen.sh"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="autogen.sh" msg="Autogen failed ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
fi
if [ ! -z "${autoreconf}" ]
then
printlines project="${project}" task="autoreconf" msg="src: ${srcdir}"
unbufferCall "autoreconf ${autoreconf}" 2>&1 | printlines project="${project}" task="autoreconf"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="autoreconf" msg="Autoreconf failed ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
fi
if [ ! -z "${cmakedir}" ]
then
printlines project="${project}" task="cmake" msg="src: ${srcdir}"
printlines project="${project}" task="cmake" msg="arguments: ${cmakeargs}"
if [ ! -z "${cmakeclean}" ]
then
unbufferCall "cmake --build \"${cmakedir}\" --target clean" 2>&1 | printlines project="${project}" task="cmake"
find . -iwholename '*cmake*' -not -name CMakeLists.txt -delete
fi
btype="Release"
if [ $ENABLE_DEBUG -eq 1 ]; then
btype="Debug"
fi
unbufferCall "cmake -G 'Unix Makefiles' " \
"${cmakeargs} " \
"-DCMAKE_BUILD_TYPE=$btype " \
"-DCMAKE_INSTALL_PREFIX='${prefix}' " \
"-DENABLE_TESTS=OFF " \
"-DENABLE_SHARED=on " \
"'${cmakedir}'" 2>&1 | printlines project="${project}" task="cmake"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="cmake" msg="failed ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
fi
if [ ! -z "${configcustom}" ]; then
printlines project="${project}" task="bash" msg="src: ${srcdir}"
printlines project="${project}" task="bash" msg="command: ${configcustom}"
unbufferCall "bash -c \"${configcustom}\"" 2>&1 | printlines project="${project}" task="bash"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="bash" msg="command failed: ${configcustom}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
fi
if [ -f "$rel_path/configure" ] && [ -z "${cmakedir}" ]; then
printlines project="${project}" task="configure" msg="src: ${srcdir}"
printlines project="${project}" task="configure" msg="arguments: ${configure}"
unbufferCall "$rel_path/configure " \
"--prefix='${prefix}' " \
"${configure}" 2>&1 | printlines project="${project}" task="configure"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="configure" msg="$rel_path/configure failed ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
else
printlines project="${project}" task="configure" msg="no configuration available"
fi
printlines project="${project}" task="compile" msg="src: ${srcdir}"
printlines project="${project}" task="compile" msg="arguments: '${makeargs}'"
unbufferCall "make -j$(nproc) ${make}" 2>&1 | printlines project="${project}" task="compile"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="compile" msg="make failed ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
printlines project="${project}" task="install" msg="src: ${srcdir}"
printlines project="${project}" task="install" msg="arguments: ${installargs}"
unbufferCall "make -j$(nproc) ${make} install ${installargs}" 2>&1 | printlines project="${project}" task="install"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="install" msg="failed ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
build_time=$(( SECONDS - build_start ))
displaytime project="${project}" task="build" time=$build_time label="Build runtime: "
cd "$OLDPWD"
}
############################################
#
# Function to build a project configured with meson
#
############################################
buildMesonProject() {
local project srcdir mesonargs prefix setuppatch bindir destdir builddir defaultlib clean noexit
local "${@}"
build_start=$SECONDS
printlines project="${project}" task="meson" msg="src: '${srcdir}'"
printlines project="${project}" task="meson" msg="prefix: '${prefix}'"
curr_dir=$(pwd)
build_dir=""
if [ ! -z "${builddir}" ]
then
build_dir="${builddir}"
else
build_dir="build_dir"
fi
default_lib=""
if [ ! -z "${defaultlib}" ]
then
default_lib="${defaultlib}"
else
default_lib="static"
fi
bindir_val=""
if [ ! -z "${bindir}" ]; then
bindir_val="--bindir=${bindir}"
fi
if [ ! -z "${clean}" ]; then
rm -rf "${srcdir}/$build_dir"
fi
if [ ! -d "${srcdir}/$build_dir" ]; then
mkdir -p "${srcdir}/$build_dir"
cd "${srcdir}"
if [ -d "./subprojects" ]; then
printlines project="${project}" task="meson" msg="download subprojects ${srcdir}"
# meson subprojects download
fi
if [ ! -z "${setuppatch}" ]; then
printlines project="${project}" task="bash" msg="src: ${srcdir}"
printlines project="${project}" task="bash" msg="command: ${setuppatch}"
unbufferCall "bash -c \"${setuppatch}\"" 2>&1 | printlines project="${project}" task="bash"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="bash" msg="command failed: ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
fi
btype="release"
if [ $ENABLE_DEBUG -eq 1 ]; then
btype="debug"
fi
printlines project="${project}" task="meson" msg="setup ${srcdir}"
unbufferCall "meson setup $build_dir " \
"${mesonargs} " \
"--default-library=$default_lib " \
"--prefix='${prefix}' " \
"$bindir_val " \
"--libdir=lib " \
"--includedir=include " \
"--buildtype=$btype" 2>&1 | printlines project="${project}" task="meson"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="meson" msg="setup failed ${srcdir}"
rm -rf "$build_dir"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
else
cd "${srcdir}"
if [ -d "./subprojects" ]; then
printlines project="${project}" task="meson" msg="update ${srcdir}"
# meson subprojects update
fi
if [ ! -z "${setuppatch}" ]; then
printlines project="${project}" task="bash" msg="command: ${setuppatch}"
unbufferCall "bash -c \"${setuppatch}\"" 2>&1 | printlines project="${project}" task="bash"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="bash" msg="command failed ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
fi
btype="release"
if [ $ENABLE_DEBUG -eq 1 ]; then
btype="debug"
fi
printlines project="${project}" task="meson" msg="reconfigure ${srcdir}"
unbufferCall "meson setup $build_dir " \
"${mesonargs} " \
"--default-library=$default_lib " \
"--prefix='${prefix}' " \
"$bindir_val " \
"--libdir=lib " \
"--includedir=include " \
"--buildtype=$btype " \
"--reconfigure" 2>&1 | printlines project="${project}" task="meson"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="meson" msg="setup failed ${srcdir}"
rm -rf "$build_dir"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
fi
printlines project="${project}" task="meson" msg="compile ${srcdir}"
printf '\033[?7l' #Small hack to prevent meson from cropping progress line
unbufferCall "meson compile -C $build_dir" 2>&1 | printlines project="${project}" task="compile"
status="${PIPESTATUS[0]}"
printf '\033[?7h' #Small hack to prevent meson from cropping progress line
if [ $status -ne 0 ]; then
printError project="${project}" task="meson" msg="compile failed ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
printlines project="${project}" task="meson" msg="install ${srcdir}"
DESTDIR=${destdir} unbufferCall "meson install -C $build_dir" 2>&1 | printlines project="${project}" task="install"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="${project}" task="meson" msg="install failed ${srcdir}"
[[ ! -z "${noexit}" ]] && FAILED=1 && cd "$OLDPWD" && return || exit 1;
fi
build_time=$(( SECONDS - build_start ))
displaytime project="${project}" task="build" time=$build_time label="Build runtime: "
cd "$OLDPWD"
}
pkgCheck() {
local name minver project
local "${@}"
min_ver=""
if [ ! -z ${minver} ]; then
min_ver=" >= ${minver}"
fi
output=$(pkg-config --print-errors --errors-to-stdout "${name} $min_ver");
if [ -z "$output" ]; then
printlines project="${project}" task="check" msg="found"
else
printlines project="${project}" task="check" msg="not found"
echo 1
fi
}
progVersionCheck(){
local major minor micro linenumber lineindex program paramoverride startcut length project
local "${@}"
varparam="--version"
if [ ! -z ${paramoverride} ]; then
varparam="${paramoverride}"
fi;
# echo "------------------------" 1> /dev/stdin
# echo "test ${program} ${varparam}" 1> /dev/stdin
# echo "------------------------" 1> /dev/stdin
test=$(${program} $varparam 2> /dev/null)
ret=$?
if [[ $ret -ne 0 ]]; then
printlines project="${project}" task="check" msg="not found"
echo 1
return
fi
FIRSTLINE=$(${program} ${varparam} | head -${linenumber})
firstLineArray=(${FIRSTLINE//;/ })
versionString=${firstLineArray[${lineindex}]};
[[ ! -z "${startcut}" ]] && [[ -z "${length}" ]] && versionString=${versionString:2}
[[ ! -z "${startcut}" ]] && [[ ! -z "${length}" ]] && versionString=${versionString:$startcut:$length}
[[ -z "${startcut}" ]] && [[ ! -z "${length}" ]] && versionString=${versionString:0:$length}
versionArray=(${versionString//./ })
actualmajor=${versionArray[0]}
actualminor=${versionArray[1]}
actualmicro=${versionArray[2]}
if [ -z "$major" ]; then
printlines project="${project}" task="check" msg="found"
return;
fi
if [[ -z "$actualmajor" || ! "$actualmajor" == ?(-)+([[:digit:]]) ]]; then echo "Unexpected ${program} version ouput[1] \"$FIRSTLINE\" \"$versionString\""; return; fi
if [ "$actualmajor" -gt "$major" ]; then
printlines project="${project}" task="check" msg="found"
return;
elif [ "$actualmajor" -lt "$major" ]; then
printlines project="${project}" task="check" msg="version is too old. $actualmajor.$actualminor.$actualmicro < $major.$minor.$micro"
echo 1
else
if [ -z "$minor" ]; then return; fi
if [[ -z "$actualminor" || ! "$actualminor" == ?(-)+([[:digit:]]) ]]; then echo "Unexpected ${program} version ouput[2] \"$FIRSTLINE\" \"$versionString\""; return; fi
if [ "$actualminor" -gt "$minor" ]; then
printlines project="${project}" task="check" msg="found"
return;
elif [ "$actualminor" -lt "$minor" ]; then
printlines project="${project}" task="check" msg="version is too old. $actualmajor.$actualminor.$actualmicro < $major.$minor.$micro"
echo 1
else
if [ -z "$micro" ]; then return; fi
if [[ -z "$actualmicro" || ! "$actualmicro" == ?(-)+([[:digit:]]) ]]; then echo "Unexpected ${program} version ouput[3] \"$FIRSTLINE\" \"$versionString\""; return; fi
if [ ! -z "$micro" ] && [ "$actualmicro" -lt "$micro" ]; then
printlines project="${project}" task="check" msg="version is too old. $actualmajor.$actualminor.$actualmicro < $major.$minor.$micro"
echo 1
else
printlines project="${project}" task="check" msg="found"
return
fi
fi
fi
}
function checkLibrary {
local name static project
local "${@}"
[[ ! -z "${static}" ]] && staticstr=" -static" || staticstr=""
output="$(gcc -l${name}${staticstr} 2>&1)";
if [[ "$output" == *"undefined reference to \`main'"* ]]; then
printlines project="${project}" task="check" msg="found"
else
printlines project="${project}" task="check" msg="not found"
echo 1
fi
}
export PATH="$SUBPROJECT_DIR/unzip60/build/dist/bin":$PATH
HAS_UNZIP=0
checkUnzip(){
if [ $HAS_UNZIP -eq 0 ] && [ ! -z "$(progVersionCheck project="unzip" program=unzip paramoverride="-v")" ]; then
downloadAndExtract project="unzip" file="unzip60.tar.gz" path="https://sourceforge.net/projects/infozip/files/UnZip%206.x%20%28latest%29/UnZip%206.0/unzip60.tar.gz/download"
buildMakeProject project="unzip" srcdir="unzip60" make="-f unix/Makefile generic" installargs=" prefix=$SUBPROJECT_DIR/unzip60/build/dist MANDIR=$SUBPROJECT_DIR/unzip60/build/dist/share/man/man1 -f unix/Makefile"
fi
HAS_UNZIP=1
}
export PATH="$SUBPROJECT_DIR/gettext-0.21.1/dist/bin":$PATH
HAS_GETTEXT=0
checkGetTextAndAutoPoint(){
if [ $HAS_GETTEXT -eq 0 ] && \
([ ! -z "$(progVersionCheck project="gettext" program=gettextize linenumber=1 lineindex=3 major=0 minor=9 micro=18 )" ] ||
[ ! -z "$(progVersionCheck project="autopoint" program=autopoint linenumber=1 lineindex=3 major=0 minor=9 micro=18 )" ]); then
downloadAndExtract project="gettext" file="gettext-0.21.1.tar.gz" path="https://ftp.gnu.org/pub/gnu/gettext/gettext-0.21.1.tar.gz"
buildMakeProject project="gettext" srcdir="gettext-0.21.1" prefix="$SUBPROJECT_DIR/gettext-0.21.1/dist" autogen="skip"
fi
HAS_GETTEXT=1
}
export PERL5LIB="$SUBPROJECT_DIR/perl-5.40.0/lib":$PERL5LIB
export PATH="$SUBPROJECT_DIR/perl-5.40.0/build/bin":$PATH
HAS_PERL=0
checkPerl(){
if [ $HAS_PERL -eq 0 ] && \
[ ! -z "$(progVersionCheck project="perl" program=perl linenumber=2 lineindex=8 major=5 minor=38 micro=0 startcut=2 length=6)" ]; then
downloadAndExtract project="perl" file="perl-5.40.0.tar.gz" path="https://www.cpan.org/src/5.0/perl-5.40.0.tar.gz"
buildMakeProject project="perl" srcdir="perl-5.40.0" skipbootstrap="true" configcustom="./Configure -des -Dprefix=$SUBPROJECT_DIR/perl-5.40.0/build"
fi
HAS_PERL=1
}
export PATH="$SUBPROJECT_DIR/glibc-2.40/build/dist/bin":$PATH
export LIBRARY_PATH="$SUBPROJECT_DIR/glibc-2.40/build/dist/lib":$LIBRARY_PATH
HAS_GLIBC=0
checkGlibc(){
if [ $HAS_GLIBC -eq 0 ] && \
[ ! -z "$(checkLibrary project="glibc" name=c static=true)" ]; then
downloadAndExtract project="glibc" file="glibc-2.40.tar.xz" path="https://ftp.gnu.org/gnu/glibc/glibc-2.40.tar.xz"
buildMakeProject project="glibc" srcdir="glibc-2.40" prefix="$SUBPROJECT_DIR/glibc-2.40/build/dist" skipbootstrap="true" outoftree="true"
fi
HAS_GLIBC=1
}
checkGitRepoState(){
local repo package
local "${@}"
ret=0
git -C ${repo} remote update &> /dev/null
LOCAL=$(git -C ${repo} rev-parse @ 2> /dev/null)
REMOTE=$(git -C ${repo} rev-parse @{u} 2> /dev/null)
BASE=$(git -C ${repo} merge-base @ @{u} 2> /dev/null)
if [ ! -z "$LOCAL" ] && [ $LOCAL = $REMOTE ]; then
printlines project="${package}" task="git" msg="${repo} is already up-to-date. Do nothing..."
elif [ ! -z "$LOCAL" ] && [ $LOCAL = $BASE ]; then
printlines project="${package}" task="git" msg="${repo} has new changes. Force rebuild..."
ret=1
elif [ ! -z "$LOCAL" ] && [ $REMOTE = $BASE ]; then
printlines project="${package}" task="git" msg="${repo} has local changes. Doing nothing..."
elif [ ! -z "$LOCAL" ]; then
printlines project="${package}" task="git" msg="Error ${repo} is diverged."
ret=-1
else
printlines project="${package}" task="git" msg="not found"
ret=-1
fi
if [ $ret == 0 ] && [ ! -z "${package}" ] && [ ! -z "$(pkgCheck name=${package} project=${project})" ]; then
ret=1
fi
echo $ret
}
# Hard dependency check
MISSING_DEP=0
if [ ! -z "$(progVersionCheck project="make" program='make')" ]; then
MISSING_DEP=1
fi
if [ ! -z "$(progVersionCheck project="pkg-config" program=pkg-config)" ]; then
MISSING_DEP=1
fi
if [ ! -z "$(progVersionCheck project="g++" program=g++)" ]; then
MISSING_DEP=1
fi
if [ ! -z "$(progVersionCheck project="git" program=git)" ]; then
MISSING_DEP=1
fi
if [ ! -z "$(progVersionCheck project="tar" program=tar)" ]; then
MISSING_DEP=1
fi
if [ ! -z "$(progVersionCheck project="wget" program=wget)" ]; then
MISSING_DEP=1
elif [ -z "$(progVersionCheck project="wget" program=wget linenumber=1 lineindex=2 major=2)" ]; then
WGET_CMD="wget --force-progress" #Since version 2+ show-progress ins't supported
elif [ -z "$(progVersionCheck project="wget" program=wget linenumber=1 lineindex=2 major=1 minor=16)" ]; then
WGET_CMD="wget --show-progress --progress=bar:force" #Since version 1.16 set show-progress
fi
if [ ! -z "$(pkgCheck project="gtk3" name=gtk+-3.0)" ]; then
MISSING_DEP=1
fi
if [ $MISSING_DEP -eq 1 ]; then
exit 1
fi
unbuffer echo "test" 2> /dev/null 1> /dev/null
[ $? == 0 ] && UNBUFFER_COMMAND="unbuffer" && printlines project="unbuffer" task="check" msg="found" || printlines project="unbuffer" task="check" msg="not found"
mkdir -p "$SUBPROJECT_DIR"
mkdir -p "$SRC_CACHE_DIR"
cd "$SUBPROJECT_DIR"
export ACLOCAL_PATH="$ACLOCAL_PATH:/usr/share/aclocal" #When using locally built autoconf, we need to add system path
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:"$(pkg-config --variable pc_path pkg-config)" #When using locally built pkgconf, we need to add system path
#Setup gnu tools
# export PATH="$SUBPROJECT_DIR/make-4.4.1/build/dist/bin":$PATH
# if [ ! -z "$(progVersionCheck program=make linenumber=1 lineindex=2 major=4 minor=4 micro=1 )" ]; then
# echo "building make from source..."
# downloadAndExtract file="make-4.4.1.tar.gz" path="https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz"
# if [ $FAILED -eq 1 ]; then exit 1; fi
# buildMakeProject srcdir="make-4.4.1" prefix="$SUBPROJECT_DIR/make-4.4.1/build/dist" skipbootstrap="true"
# if [ $FAILED -eq 1 ]; then exit 1; fi
# else
# echo "make already installed."
# fi
export PATH=$SUBPROJECT_DIR/m4-1.4.19/build/dist/bin:$PATH
if [ ! -z "$(progVersionCheck project="m4" program=m4 linenumber=1 lineindex=3 major=1 minor=4 micro=18 )" ]; then
downloadAndExtract project="m4" file="m4-1.4.19.tar.xz" path="https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.xz"
buildMakeProject project="m4" srcdir="m4-1.4.19" prefix="$SUBPROJECT_DIR/m4-1.4.19/build/dist" skipbootstrap="true"
fi
export PATH="$SUBPROJECT_DIR/autoconf-2.72/build/dist/bin":$PATH
export ACLOCAL_PATH="$SUBPROJECT_DIR/autoconf-2.72/build/dist/share/autoconf":$ACLOCAL_PATH
if [ ! -z "$(progVersionCheck project="autoconf" program=autoconf linenumber=1 lineindex=3 major=2 minor=70)" ]; then
checkPerl
downloadAndExtract project="autoconf" file="autoconf-2.72.tar.xz" path="https://ftp.gnu.org/gnu/autoconf/autoconf-2.72.tar.xz"
buildMakeProject project="autoconf" srcdir="autoconf-2.72" prefix="$SUBPROJECT_DIR/autoconf-2.72/build/dist" skipbootstrap="true"
fi
export PATH="$SUBPROJECT_DIR/automake-1.17/build/dist/bin":$PATH
export ACLOCAL_PATH="$SUBPROJECT_DIR/automake-1.17/build/dist/share/aclocal-1.17":$ACLOCAL_PATH
if [ ! -z "$(progVersionCheck project="automake" program=automake linenumber=1 lineindex=3 major=1 minor=16 micro=1)" ]; then
downloadAndExtract project="automake" file="automake-1.17.tar.xz" path="https://ftp.gnu.org/gnu/automake/automake-1.17.tar.xz"
buildMakeProject project="automake" srcdir="automake-1.17" prefix="$SUBPROJECT_DIR/automake-1.17/build/dist" skipbootstrap="true"
fi
export PATH="$SUBPROJECT_DIR/libtool-2.5.3/build/dist/bin":$PATH
export ACLOCAL_PATH="$SUBPROJECT_DIR/libtool-2.5.3/build/dist/share/aclocal":$ACLOCAL_PATH
if [ ! -z "$(progVersionCheck project="libtool" program=libtoolize linenumber=1 lineindex=3 major=2 minor=4 micro=6)" ]; then
downloadAndExtract project="libtool" file="libtool-2.5.3.tar.xz" path="https://ftp.gnu.org/gnu/libtool/libtool-2.5.3.tar.xz"
buildMakeProject project="libtool" srcdir="libtool-2.5.3" prefix="$SUBPROJECT_DIR/libtool-2.5.3/build/dist" skipbootstrap="true"
fi
export PATH="$SUBPROJECT_DIR/flex-2.6.4/build/dist/bin":$PATH
if [ ! -z "$(progVersionCheck project="flex" program=flex linenumber=1 lineindex=1 major=2 minor=6 micro=4 )" ]; then
checkGetTextAndAutoPoint
downloadAndExtract project="flex" file="flex-2.6.4.tar.gz" path="https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz"
buildMakeProject project="flex" srcdir="flex-2.6.4" prefix="$SUBPROJECT_DIR/flex-2.6.4/build/dist" skipbootstrap="true"
fi
export PATH="$SUBPROJECT_DIR/bison-3.8.2/build/dist/bin":$PATH
if [ ! -z "$(progVersionCheck project="bison" program=bison linenumber=1 lineindex=3 major=3 minor=5 micro=1 )" ]; then
downloadAndExtract project="bison" file="bison-3.8.2.tar.xz" path="https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz"
buildMakeProject project="bison" srcdir="bison-3.8.2" prefix="$SUBPROJECT_DIR/bison-3.8.2/build/dist" skipbootstrap="true"
fi
VENV_EXEC=""
if [ ! -z "$(progVersionCheck project="virtualenv" program=virtualenv)" ]; then
if [ $NO_DOWNLOAD -eq 0 ] && [ ! -f "virtualenv.pyz" ]; then
$WGET_CMD https://bootstrap.pypa.io/virtualenv.pyz 2>&1 | printlines project="virtualenv" task="wget"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="virtualenv" task="wget" msg="failed to fetch https://bootstrap.pypa.io/virtualenv.pyz"
exit 1;
fi
fi
VENV_EXEC="python3 virtualenv.pyz"
else
VENV_EXEC="virtualenv"
fi
#Setting up Virtual Python environment
if [ ! -f "./venvfolder/bin/activate" ]; then
$VENV_EXEC ./venvfolder 2>&1 | printlines project="virtualenv" task="setup"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="virtualenv" task="setup" msg="failed to run python3 virtualenv.pyz"
exit 1;
fi
else
printlines project="virtualenv" task="check" msg="found"
fi
#Activate virtual environment
if [[ ! -f "venvfolder/bin/activate" ]]; then
printError project="virtualenv" task="activate" msg="failed to activate python virtual environment."
exit 1;
else
source venvfolder/bin/activate
printlines project="virtualenv" task="activate" msg="activated python virtual environment."
fi
#Setup meson
if [ $NO_DOWNLOAD -eq 0 ]; then
if [ ! -z "$(progVersionCheck project="meson" program=meson linenumber=1 lineindex=0 major=1 minor=1)" ]; then
unbufferCall "python3 -m pip install --progress-bar on meson --upgrade" 2>&1 | printlines project="meson" task="pip"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="meson" task="install" msg="Failed to install meson via pip. Please try to install meson manually."
exit 1
fi
fi
if [ ! -z "$(progVersionCheck project="ninja" program=ninja)" ]; then
unbufferCall "python3 -m pip install --progress-bar on ninja --upgrade" 2>&1 | printlines project="ninja" task="pip"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
printError project="ninja" task="check" msg="Failed to install ninja via pip. Please try to install ninja manually."
exit 1
fi
fi
else
printlines project="onvifmgr" task="check" msg="Skipping pip install. NO_DOWNLOAD is set."
fi
# export PKG_CONFIG_PATH="$SUBPROJECT_DIR/gtk/dist/lib/pkgconfig":$PKG_CONFIG_PATH
# echo $SUBPROJECT_DIR/gtk/dist/lib/pkgconfig
# pkgCheck project="gtk" name=gtk+-3.0 minver=3.24.43
# if [ ! -z "$(pkgCheck project="gtk" name=gtk+-3.0 minver=3.24.43)" ]; then
# #https://download.gnome.org/sources/gtk+/3.24/gtk%2B-3.24.42.tar.xz
# pullOrClone project="gtk" path="https://gitlab.gnome.org/GNOME/gtk.git" tag="3.24.43"
# buildMesonProject project="gtk" srcdir="gtk" prefix="$SUBPROJECT_DIR/gtk/dist" mesonargs="-Dtests=false -Dintrospection=false -Ddemos=false -Dexamples=false -Dlibepoxy:tests=false"
# fi
################################################################
#
# Build Openssl for gsoap and onvifsoap
#
################################################################
export PKG_CONFIG_PATH="$SUBPROJECT_DIR/openssl/build/dist/lib/pkgconfig":$PKG_CONFIG_PATH
if [ ! -z "$(pkgCheck project="openssl" name=libcrypto minver=1.1.1f)" ]; then
checkGlibc
pullOrClone project="openssl" path="https://github.com/openssl/openssl.git" tag="OpenSSL_1_1_1w"
buildMakeProject project="openssl" srcdir="openssl" configcustom="./config --prefix='$SUBPROJECT_DIR/openssl/build/dist' --openssldir='$SUBPROJECT_DIR/openssl/build/dist/ssl' -static"
fi
export PATH="$SUBPROJECT_DIR/cmake-3.25.2/build/dist/bin":$PATH
if [ ! -z "$(progVersionCheck project="cmake" program=cmake linenumber=1 lineindex=2 major=3 minor=16 micro=3 )" ]; then
downloadAndExtract project="cmake" file="cmake-3.25.2.tar.gz" path="https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2.tar.gz"
buildMakeProject project="cmake" srcdir="cmake-3.25.2" prefix="$SUBPROJECT_DIR/cmake-3.25.2/build/dist" skipbootstrap="true" configure="--parallel=$(nproc)"
fi