This repository was archived by the owner on Jan 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateDependencies.sh
More file actions
3353 lines (3271 loc) · 160 KB
/
UpdateDependencies.sh
File metadata and controls
3353 lines (3271 loc) · 160 KB
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
# Section for defining the upstream branches to use
BZIPTAG="bzip2-1.0.8" # Uses tags to represent final versions.
ENCATAG="1.19" # Uses tags to represent final versions.
EXPATVER="2.1.0" # Uses archive releases (2.1.0 = 24-March-2012).
FDKTAG="v2.0.3" # Uses tags to represent final versions.
FONTCONFIGTAG="2.16.2" # Uses tags to represent final versions.
FREETYPETAG="VER-2-13-3" # Uses tags to represent final versions.
FRIBIDITAG="v1.0.16" # Uses tags to represent final versions.
GMETAG="0.6.3" # Uses svn tags to represent final versions.
GMPTAG="gmp-6.2.1" # Uses different repos for different versions. Currently 6.2 repo, newer version will need to change upstream.
GNUTLSTAG="3.8.9" # Uses tags to represent final versions.
HARFBUZZTAG="11.2.1" # Uses tags to represent final versions.
LIBAACSTAG="0.11.1" # Uses tags to represent final versions.
LIBARCHIVETAG="v3.4.0" # Uses tags to represent final versions.
LIBASSTAG="0.17.4" # Uses tags to represent final versions.
LIBBDPLUSTAG="0.2.0" # Uses tags to represent final versions.
LIBBLURAYTAG="1.3.4" # Uses tags to represent final versions.
LIBCDIOTAG="2.2.0" # Uses tags to represent final versions.
LIBCDIOPARANOIATAG="release-10.2+2.0.2" # Uses tags to represent final versions.
LIBDVDCSSTAG="1.4.3" # Uses tags to represent final versions.
LIBDVDNAVTAG="6.1.1" # Uses tags to represent final versions.
LIBDVDREADTAG="6.1.3" # Uses tags to represent final versions.
LIBICONVTAG="v1.18" # Uses tags to represent final versions.
LIBILBCTAG="v3.0.3" # Uses tags to represent final versions.
LIBLZMATAG="v5.8.1" # Uses tags to represent final versions.
LIBGCRYPTTAG="libgcrypt-1.11.0" # Uses tags to represent final versions.
LIBGPGERRORTAG="libgpg-error-1.52" # Uses tags to represent final versions. (1.53-1.54-1.55)
LIBSSHTAG="libssh-0.11.1" # Uses tags to represent final versions.
LIBVPXTAG="v1.15.1" # Uses tags to represent final versions.
LIBXML2TAG="v2.14.3" # Uses tags to represent final versions.
MFXDISPATCHBRANCH="master" # Only has one possible branch.
MODPLUGBRANCH="master" # Only has one possible branch.
MP3LAMETAG="RELEASE__3_100" # Uses tags to represent final versions.
MPVTAG="v0.28.2" # Uses tags to represent final versions.
NETTLETAG="nettle_3.10.1_release_20241230" # Uses tags to represent final.
OGGTAG="v1.3.5" # Uses tags to represent final.
OPENSSLTAG="OpenSSL_1_1_0i" # Uses tags to represent final.
OPUSTAG="v1.4" # Uses tags to represent final.
RTMPDUMPBRANCH="master" # Only has one possible branch.
SDLTAG="release-2.30.9" # Uses tags to represent final.
SOXRTAG="0.1.3" # Uses tags to represent final.
SPEEXTAG="Speex-1.2.1" # Uses tags to represent final.
THEORATAG="v1.2.0" # Uses tags to represent final.
VORBISTAG="v1.3.7" # Uses tags to represent final.
X264BRANCH="master" # Options are stable and master.
X265TAG="4.1" # Uses tags to represent final versions.
XVIDTAG="release-1_3_7" # Uses svn tags to represent final versions.
ZLIBTAG="v1.3.1" # Uses tags to represent final versions.
FFMPEGTAG="7.1" # Uses tags to represent final versions.
#Change into the directory for this bash file
CURRDIR=$(pwd)
cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null
# Move into the source directory
if [ ! -d source ]; then
mkdir source
fi
cd source
SOURCEDIR=$(pwd)
#Ensure ssh agent is running
eval $(ssh-agent -s)
ssh-add ~/.ssh/github_rsa
echo "Updating local content..."
echo ""
#Function to wrap git calls in WSL2 instances to improve performance
function git() {
if [[ $(pwd -P) = /mnt/* ]]; then
git.exe "$@"
else
command git "$@"
fi
}
UPDATEDTAGS=()
#Function to clone a repository
# doUpstreamSource RepoName RepoAddress
# RepoName = Name of the repository (used for error reporting)
# RepoAddress = Address of the repository
doCloneRepo() {
local REPONAME="$1"
local REPOADDRESS="$2"
if ! [ -d $REPONAME ]; then
# Clone the repository
echo "$REPONAME: Source directory does not exist. Downloading..."
git clone $REPOADDRESS --quiet
fi
}
#Function to add the upstream source
# doUpstreamSource RepoName UpstreamRepo
# RepoName = Name of the repository (used for error reporting)
# UpstreamRepo = Address of the upstream repo
doUpstreamSource() {
local REPONAME="$1"
local UPSTREAMREPO="$2"
local FOUND=false
for t in `git remote -v`
do
if [ "$t" == "upstream" ]; then
FOUND=true
break
fi
done
if ! $FOUND; then
echo "$REPONAME: Upstream remote does not exist. Adding..."
git remote add upstream $UPSTREAMREPO
# Prevent downloading unwanted tags
git config remote.upstream.tagopt --no-tags
git fetch upstream --quiet
fi
}
#Function to add an upstream SVN source
# doUpstreamSVNSource RepoName UpstreamRepo
# RepoName = Name of the repository (used for error reporting)
# UpstreamRepo = Address of the upstream repo
doUpstreamSVNSource() {
local REPONAME="$1"
local UPSTREAMREPO="$2"
local HASUPSTREAM=$(git for-each-ref refs/remotes/upstream --format='%(refname:short)' --count=1)
if [ "$HASUPSTREAM" == "" ]; then
echo "$REPONAME: Upstream remote does not exist. Adding..."
git svn init $UPSTREAMREPO --stdlayout --prefix=upstream/ --tags tags --branches branches --trunk trunk
fi
}
#Function to handle getting and merging the upstream source
# doUpstreamMerge RepoName UpstreamBranch
# RepoName = Name of the repository (used for error reporting)
# UpstreamBranch = The branch from the upstream repository to merge into local
doUpstreamMerge() {
local REPONAME="$1"
local UPSTREAMBRANCH="$2"
local FOUND=false
local RET=$(git fetch upstream --quiet 2>&1)
if [[ "$RET" == "fatal"* ]]; then
echo "$REPONAME: Failed to retrieve data from repo."
git fetch upstream --quiet
return 0
fi
local UPSTREAMID=$(git rev-parse upstream/$UPSTREAMBRANCH)
if [ "$UPSTREAMID" == "" ];then
echo "$REPONAME: Failed to retrieve branch from repo."
return 0
fi
for OUTPUT in $(git rev-list HEAD --max-count=100)
do
if [ "$UPSTREAMID" == "$OUTPUT" ];then
FOUND=true
break
fi
done
if $FOUND; then
local LATESTBRANCH=$(git for-each-ref --sort=-committerdate refs/remotes/upstream --format='%(refname:short)' --count=1)
echo "$REPONAME: Repository up to date."
if [ "$LATESTBRANCH" != "upstream/$UPSTREAMBRANCH" ]; then
local ISFIRST=true
for OUTPUT in $(git for-each-ref --sort=-committerdate refs/remotes/upstream --format='%(refname:short)' --count=10)
do
if [ "upstream/$UPSTREAMBRANCH" == "$OUTPUT" ];then
break
elif [ "upstream/master" != "$OUTPUT" ];then
if $ISFIRST; then
echo "$REPONAME: New branches available! Newer:"
ISFIRST=false
fi
echo "$OUTPUT"
fi
done
fi
return 0
else
git clean -fX --quiet
git checkout master --quiet
git stash --quiet
echo "$REPONAME: Merging upstream commits from $UPSTREAMBRANCH branch..."
if ! git merge -s recursive -Xtheirs --ff --quiet --no-edit upstream/$UPSTREAMBRANCH > /dev/null 2>&1; then
echo "$REPONAME: Merging had conflicts, correcting..."
# Get any remaining conflicts and correct
for FILE in $(git diff --name-only)
do
if [[ $FILE != "SMP/"* ]] && [[ $FILE != ".github/"* ]] && [[ $FILE != "README.markdown" ]]; then
if git rev-parse --verify --quiet upstream/$UPSTREAMBRANCH:$FILE > /dev/null; then
git checkout -f $REV $FILE --quiet > /dev/null
git add $FILE > /dev/null
else
git rm -f $FILE --quiet > /dev/null
fi
fi
done
if ! git commit --quiet --no-edit > /dev/null 2>&1; then
#Merge may have aborted
if ! git merge -s recursive -Xtheirs --ff --quiet --no-edit upstream/$UPSTREAMBRANCH > /dev/null 2>&1; then
echo "$REPONAME: Failed to correct merge conflicts."
doExit
fi
fi
fi
echo "$REPONAME: Git garbage collect..."
git gc --aggressive --quiet
return 1
fi
}
#Function to handle getting and merging the upstream SVN source
# doUpstreamSVNMerge RepoName UpstreamBranch
# RepoName = Name of the repository (used for error reporting)
# UpstreamBranch = The branch from the upstream repository to merge into local
doUpstreamSVNMerge() {
local REPONAME="$1"
local UPSTREAMBRANCH="$2"
local RET=$(git svn fetch svn --quiet 2>&1)
if [ "$RET" != "" ]; then
echo "$REPONAME: Failed to retrieve data from repo."
git svn fetch svn --quiet
return 0
fi
local UPSTREAMID=$(git rev-parse upstream/$UPSTREAMBRANCH)
if [ "$UPSTREAMID" == "" ];then
echo "$REPONAME: Failed to retrieve branch from repo."
return 0
fi
local FOUND=false
for OUTPUT in $(git rev-list HEAD --max-count=100)
do
if [ "$UPSTREAMID" == "$OUTPUT" ];then
FOUND=true
break
fi
done
if $FOUND; then
local LATESTBRANCH=$(git for-each-ref --sort=-committerdate refs/remotes/upstream --format='%(refname:short)' --count=1)
echo "$REPONAME: Repository up to date."
if [ "$LATESTBRANCH" != upstream/"$UPSTREAMBRANCH" ]; then
local ISFIRST=true
for OUTPUT in $(git for-each-ref --sort=-committerdate refs/remotes/upstream --format='%(refname:short)' --count=10)
do
if [ "$UPSTREAMBRANCH" == "$OUTPUT" ];then
break
elif [ upstream/master != "$OUTPUT" ];then
if $ISFIRST; then
echo "$REPONAME: New branches available! Newer:"
ISFIRST=false
fi
echo "$OUTPUT"
fi
done
fi
return 0
else
git clean -fX --quiet
git checkout master --quiet
git stash --quiet
echo "$REPONAME: Merging upstream svn commits from $UPSTREAMBRANCH branch..."
if ! git merge -s recursive -Xtheirs --ff --quiet --no-edit upstream/$UPSTREAMBRANCH > /dev/null 2>&1; then
echo "$REPONAME: Merging had conflicts, correcting..."
# Get any remaining conflicts and correct
for FILE in $(git diff --name-only)
do
if [[ $FILE != "SMP/"* ]] && [[ $FILE != ".github/"* ]] && [[ $FILE != "README.markdown" ]]; then
if git rev-parse --verify --quiet upstream/$UPSTREAMBRANCH:$FILE > /dev/null; then
git checkout -f $REV $FILE --quiet > /dev/null
git add $FILE > /dev/null
else
git rm -f $FILE --quiet > /dev/null
fi
fi
done
if ! git commit --quiet --no-edit > /dev/null 2>&1; then
#Merge may have aborted
if ! git merge -s recursive -Xtheirs --ff --quiet --no-edit upstream/$UPSTREAMBRANCH > /dev/null 2>&1; then
echo "$REPONAME: Failed to correct merge conflicts."
doExit
fi
fi
fi
echo "$REPONAME: Git garbage collect..."
git gc --aggressive --quiet
git svn gc
return 1
fi
}
#Function to clean any erroneous upstream tags from local repo
# doCleanTags RepoName
# RepoName = Name of the repository (used for error reporting)
doCleanTags() {
local REPONAME="$1"
#git tag -l | xargs -n 1 git push --delete origin
git tag | xargs git tag -d > /dev/null
}
#Function to handle getting and merging the upstream source to a specific tag
# doUpstreamMergeTag RepoName UpstreamTag
# RepoName = Name of the repository (used for error reporting)
# UpstreamTag = The tag from the upstream repository to merge into local
doUpstreamMergeTag() {
local REPONAME="$1"
local UPSTREAMTAG="$2"
#Backup existing tags
local EXISTINGTAGS=$(git show-ref --tags | sed -e 's@ @:@g')
local SECLASTTAG=$(git for-each-ref --format='%(*committerdate:raw)%(committerdate:raw) %(refname:short) %(*objectname) %(objectname)' refs/tags | sort -n -r | awk '{ print $3; }' | head -n2 | tail -n1)
local FOUND=false
#Get the latest tag
local RET=$(git fetch upstream --quiet --tags 2>&1)
if [[ "$RET" == "fatal"* ]]; then
# Prevent gc and exit
FOUND=true
echo "$REPONAME: Failed to retrieve data from repo."
git fetch upstream --quiet
else
local UPSTREAMID=$(git rev-list refs/tags/$UPSTREAMTAG --max-count=1 2>/dev/null)
if [ "$UPSTREAMID" == "" ];then
# Prevent gc and exit
FOUND=true
echo "$REPONAME: Failed to retrieve tag from repo."
else
#local UPSTREAMID=$(git ls-remote upstream refs/tags/$UPSTREAMTAG^{} | cut -d " " -f1)
for OUTPUT in $(git rev-list HEAD --max-count=200)
do
if [ "$UPSTREAMID" == "$OUTPUT" ];then
FOUND=true
break
fi
done
local UPDATED=0
if $FOUND; then
local NEWTAGS=$(git --no-pager tag -l --no-merged)
#local LATESTTAG=$(git --no-pager describe --tags --always `git rev-list --remotes=upstream/master --tags --max-count=1` 2>/dev/null)
#local LATESTTAG=$(git ls-remote --tags upstream | grep -v { | sort -r -t '/' -k 3 -V | cut -d '/' -f 3 | head -1)
echo "$REPONAME: Repository up to date."
#Need to check if using latest tag
if [ "$NEWTAGS" != "" ]; then
local UNUSEDTAGS=$(git for-each-ref --format='%(*committerdate:raw)%(committerdate:raw) %(refname:short) %(*objectname) %(objectname)' refs/tags | sort -n -r | awk '{ print $3; }')
#local UNUSEDTAGS=$(git ls-remote --tags upstream | grep -v { | sort -r -t '/' -k 3 -V | cut -d '/' -f 3)
local NEWERTAGS
for OUTPUT in $UNUSEDTAGS
do
if [ "$OUTPUT" == "$SECLASTTAG" ]; then
break;
fi
for OUTPUT2 in $NEWTAGS
do
if [ "$OUTPUT2" == "$OUTPUT" ]; then
NEWERTAGS=("${NEWERTAGS[@]}" "$OUTPUT")
break
fi
done
done
#Check only for recent tags (ignores ones older than this repo)
if [ ${#NEWERTAGS[@]} -gt 0 ]; then
echo "$REPONAME: New tags available! Newer:"
for OUTPUT in ${NEWERTAGS[@]}
do
echo "$OUTPUT"
done
fi
fi
else
git clean -fX --quiet
git checkout master --quiet
git stash --quiet
echo "$REPONAME: Merging upstream commits from $UPSTREAMTAG tag..."
local MERGED=true
if ! git merge -s recursive -Xtheirs --ff --quiet --no-edit --allow-unrelated-histories $UPSTREAMID > /dev/null 2>&1; then
echo "$REPONAME: Merging had conflicts, correcting..."
# Get any remaining conflicts and correct
for FILE in $(git diff --name-only)
do
if [[ $FILE != "SMP/"* ]] && [[ $FILE != ".github/"* ]] && [[ $FILE != "README.markdown" ]]; then
if git rev-parse --verify --quiet $UPSTREAMID:$FILE > /dev/null; then
git checkout -f $UPSTREAMID $FILE --quiet > /dev/null
git add $FILE > /dev/null
else
git rm -f $FILE --quiet > /dev/null
fi
fi
done
if ! git commit --quiet --no-edit --no-verify > /dev/null 2>&1; then
#Merge may have aborted
if ! git merge -s recursive -Xtheirs --ff --quiet --no-edit --allow-unrelated-histories $UPSTREAMID > /dev/null 2>&1; then
echo "$REPONAME: Failed to correct merge conflicts."
read -n 1 -rsp "Press [Enter] key once manually corrected errors or [x] key to skip..." TEMPIN
echo ""
if [ "$TEMPIN" == "x" ]; then
MERGED=false
elif ! git commit --quiet --no-edit --no-verify > /dev/null 2>&1; then
if ! git merge -s recursive -Xtheirs --ff --quiet --no-edit --allow-unrelated-histories $UPSTREAMID > /dev/null 2>&1; then
MERGED=false
fi
fi
fi
fi
fi
if $MERGED; then
UPDATEDTAGS=("${UPDATEDTAGS[@]}" "$REPONAME:$UPSTREAMTAG:$UPSTREAMID")
UPDATED=1
fi
fi
fi
fi
doCleanTags $REPONAME
#Re-add old tags back
for OLDTAG in $EXISTINGTAGS
do
local NAME=${OLDTAG##*/}
local HASH=${OLDTAG%%:*}
git tag $NAME $HASH
done
#git gc after repo tags have been reset
if ! $FOUND; then
echo "$REPONAME: Git garbage collect..."
git gc --aggressive --quiet
fi
return $UPDATED
}
#Function to handle getting and merging the upstream SVN source to a specific tag
# doUpstreamSVNMergeTag RepoName UpstreamTag
# RepoName = Name of the repository (used for error reporting)
# UpstreamTag = The tag from the upstream repository to merge into local
# UpstreamDir = (Optional) Merge only from the specified sub-directory of the upstream
doUpstreamSVNMergeTag() {
local REPONAME="$1"
local UPSTREAMTAG="$2"
local UPSTREAMDIR="$3"
local FOUND=false
local RET=$(git svn fetch svn --quiet 2>&1)
if [ "$RET" != "" ]; then
echo "$REPONAME: Failed to retrieve data from repo."
git svn fetch svn --quiet
return 0
fi
if [[ "$UPSTREAMDIR" == "" ]]; then
local UPSTREAMID=$(git rev-parse upstream/tags/$UPSTREAMTAG)
if [ "$UPSTREAMID" == "" ];then
echo "$REPONAME: Failed to retrieve tag from repo."
return 0
fi
for OUTPUT in $(git rev-list HEAD --max-count=100)
do
if [ "$UPSTREAMID" == "$OUTPUT" ];then
FOUND=true
break
fi
done
else
for OUTPUT in $(git tag)
do
if [ "$UPSTREAMTAG" == "$OUTPUT" ];then
FOUND=true
break
fi
done
fi
if $FOUND; then
local LATESTBRANCH=$(git for-each-ref --sort=-committerdate refs/remotes/upstream/tags --format='%(refname:short)' --count=1)
echo "$REPONAME: Repository up to date."
if [ "$LATESTBRANCH" != "upstream/tags/$UPSTREAMTAG" ] && [ "$LATESTBRANCH" != "" ]; then
echo "$REPONAME: New tags available! Newer:"
for OUTPUT in $(git for-each-ref --sort=-committerdate refs/remotes/upstream/tags --format='%(refname:short)' --count=10)
do
if [ "upstream/tags/$UPSTREAMTAG" == "$OUTPUT" ];then
break
else
echo "$OUTPUT"
fi
done
fi
return 0
else
git checkout master --quiet
git stash --quiet
if [[ "$UPSTREAMDIR" == "" ]]; then
local UPSTREAMLOC="upstream/tags/$UPSTREAMTAG"
else
echo "$REPONAME: Getting upstream svn commits from $UPSTREAMDIR subdirectory..."
git branch -D upstreamsub > /dev/null 2>&1
git branch -D split > /dev/null 2>&1
if ! git checkout -b upstreamsub upstream/tags/$UPSTREAMTAG > /dev/null 2>&1; then
echo "$REPONAME: Failed to checkout upstream tag"
git checkout master > /dev/null 2>&1
git branch -D split > /dev/null 2>&1
git branch -D upstreamsub > /dev/null 2>&1
doExit
fi
if ! git subtree split --prefix=$UPSTREAMDIR --annotate="(split)" -b split; then
echo "$REPONAME: Failed to split upstream branch"
git checkout master > /dev/null 2>&1
git branch -D split > /dev/null 2>&1
git branch -D upstreamsub > /dev/null 2>&1
doExit
fi
git checkout master > /dev/null 2>&1
local UPSTREAMLOC="split"
fi
echo "$REPONAME: Merging upstream svn commits from $UPSTREAMTAG tag..."
if ! git merge -s recursive -Xtheirs --ff --quiet --no-edit -m"Merge remote-tracking branch 'upstream/tags/$UPSTREAMTAG'" $UPSTREAMLOC > /dev/null 2>&1; then
echo "$REPONAME: Merging had conflicts, correcting..."
# Get any remaining conflicts and correct
for FILE in $(git diff --name-only)
do
if [[ $FILE != "SMP/"* ]] && [[ $FILE != ".github/"* ]] && [[ $FILE != "README.markdown" ]]; then
if git rev-parse --verify --quiet $UPSTREAMLOC:$FILE > /dev/null; then
if [[ "$UPSTREAMDIR" == "" ]]; then
git checkout -f $UPSTREAMID $FILE --quiet > /dev/null
else
git checkout split -- $FILE > /dev/null
fi
git add $FILE > /dev/null
else
git rm -f $FILE --quiet > /dev/null
fi
fi
done
if ! git commit --quiet --no-edit -m"Merge remote-tracking branch 'upstream/tags/$UPSTREAMTAG'" > /dev/null 2>&1; then
#Merge may have aborted
if ! git merge -s recursive -Xtheirs --ff --quiet --no-edit -m"Merge remote-tracking branch 'upstream/tags/$UPSTREAMTAG'" $UPSTREAMLOC > /dev/null 2>&1; then
echo "$REPONAME: Failed to correct merge conflicts."
git branch -D split > /dev/null 2>&1
git branch -D upstreamsub > /dev/null 2>&1
doExit
fi
fi
fi
git branch -D upstreamsub > /dev/null 2>&1
git branch -D split > /dev/null 2>&1
echo "$REPONAME: Git garbage collect..."
git gc --aggressive --quiet
git svn gc
UPDATEDTAGS=("${UPDATEDTAGS[@]}" "$REPONAME:$UPSTREAMTAG:")
return 1
fi
}
#Function to generate a patch file indicating difference between this repo and upstream
doCreatePatch() {
local REPONAME="$1"
local UPSTREAMHASH="$2"
if [ "$UPSTREAMHASH" == "" ]; then
echo "WARNING: Hash not specified for $REPONAME. No patch will be generated."
else
git diff $UPSTREAMHASH HEAD -- ':!SMP' ':!README.markdown' ':!.github' ':!.ci' ':!.circleci' ':!.gitlab-ci' ':!.gitignore' ':!.gitattributes' > SMP/SMP.patch
if [ ! -s SMP/SMP.patch ]; then
rm SMP/SMP.patch
else
echo "$REPONAME: Patch updated."
fi
fi
return 1
}
#Function to add a tag to the local repo and push it to the origin
# doCreateTag RepoName UpstreamRepo
# RepoName = Name of the repository (used for error reporting)
# Tag = The tag name to use for the new tag
doCreateTag() {
local REPONAME="$1"
local TAG="$2"
#Create new tag using -f in case tag already exists (forces update)
git tag -f $TAG
#Force tag to be pushed to origin
#git push -f --tags
return 1
}
#Function to loop through all updated repos and add a new tag
# doUpdateTags
doUpdateTags() {
for UTAG in "${UPDATEDTAGS[@]}";
do
local UNAME=${UTAG%%:*}
local UVALUE=${UTAG#*:}
local UVALUE=${UVALUE%:*}
local UHASH=${UTAG##*:}
echo "$UNAME: was updated to tag $UVALUE."
cd $UNAME
# Create initial patch so we can see whats changed
doCreatePatch $UNAME $UHASH
read -n 1 -rsp "Press [Enter] key to create and push new tag [x] key to skip..." TEMPIN
if [ "$TEMPIN" != "x" ]; then
doCreatePatch $UNAME $UHASH
doCreateTag $UNAME $UVALUE
fi
git stash pop --quiet > /dev/null 2>&1
cd ..
echo ""
done
}
#Function to update any submodules
# doUpdateSubmodules RepoName
# RepoName = Name of the repository (used for error reporting)
doUpdateSubmodules() {
local REPONAME="$1"
# if !( git submodule update --init --recursive > /dev/null 2>&1 ); then
# echo "$REPONAME: Failed to initialise submodules."
# return -1
# fi
if !(git submodule update --recursive > /dev/null 2>&1 ); then
echo "$REPONAME: Failed to update submodules."
return -1
fi
return 0
}
#Function to handle graceful exit
# doExit Status
# Status = Exit status (0 for success, 1 for fail)
doExit() {
local STATUS="$1"
if (( $STATUS )); then
cd $SOURCEDIR
#Finish any previously completed jobs
doUpdateTags
cd $CURRDIR
read -rsn 1 -p "Press any key to exit..."
echo
exit 1
else
cd $CURRDIR
exit 0
fi
}
# **** bzip2 ****
dobzip2() {
# Make sure the bzip2 folder is locally available
doCloneRepo "bzip2" "git@github.com:ShiftMediaProject/bzip2.git"
cd bzip2
# Set the upstream source
doUpstreamSource "bzip2" "https://sourceware.org/git/bzip2.git"
# Merge the upstream source
doUpstreamMergeTag "bzip2" $BZIPTAG
cd ..
echo ""
}
# **** enca ****
doenca() {
# Make sure the enca folder is locally available
doCloneRepo "enca" "git@github.com:ShiftMediaProject/enca.git"
cd enca
# Set the upstream source
doUpstreamSource "enca" "https://github.com/nijel/enca.git"
# Merge the upstream source
doUpstreamMergeTag "enca" $ENCATAG
if (( $? )); then
# ******************TODO**********************//
# Auto generate configure file
echo "enca: Warning contains unknown auto created config.h file."
echo "enca: Updating tools encoder header file (tools/encoder.h)..."
# Copied from tools/Makefile.am
# Note: Had to convert $$ in original to $
if !( mkdir -p SMP/tools &&
gcc ./iconvcap.c -o SMP/tools/iconvcap -liconv &&
SMP/tools/iconvcap > SMP/tools/iconvenc.h &&
sed -e 's/^#define \([A-Z0-9_]*\) \(.*\)/@\1@ \2/' -e 's/"//g' -e 's/NULL$//' -e 's/ /\//' -e 's/^\(.*\)$/s\/\1\//' SMP/tools/iconvenc.h > SMP/tools/encodings.sed &&
gcc ./tools/make_hash.c -o SMP/tools/make_hash &&
sed -f SMP/tools/encodings.sed ./tools/encodings.dat | SMP/tools/make_hash > SMP/tools/encodings.h &&
mv SMP/tools/encodings.h SMP/encodings.h &&
rm -rf SMP/tools &&
mkdir -p SMP/tools &&
mv SMP/encodings.h SMP/tools/encodings.h ); then
echo "enca: Error! tools encoder header update failed"
rm -rf SMP/tools
doExit 1
fi
echo "enca: Warning contains unknown created definition file."
fi
cd ..
echo "Warning: Enca only used by libass and is no longer required"
echo ""
}
# **** fdk-aac ****
dofdk() {
# Make sure the fdk-aac folder is locally available
doCloneRepo "fdk-aac" "git@github.com:ShiftMediaProject/fdk-aac.git"
cd fdk-aac
# Set the upstream source
doUpstreamSource "fdk-aac" "https://github.com/mstorsjo/fdk-aac.git"
# Merge the upstream source
doUpstreamMergeTag "fdk-aac" $FDKTAG
if (( $? )); then
echo "fdk-aac: Updating definition file (libfdk-aac.def)..."
echo "EXPORTS" > SMP/libfdk-aac.def
cat ./fdk-aac.sym >> SMP/libfdk-aac.def
fi
cd ..
echo ""
}
# **** fontconfig ****
dofontconfig() {
# Make sure the fontconfig folder is locally available
doCloneRepo "fontconfig" "git@github.com:ShiftMediaProject/fontconfig.git"
cd fontconfig
# Set the upstream source
doUpstreamSource "fontconfig" "git://anongit.freedesktop.org/fontconfig"
# Merge the upstream source
doUpstreamMergeTag "fontconfig" $FONTCONFIGTAG
if (( $? )); then
echo "fontconfig: Removing any previous generated files..."
rm -rf ./SMP/fc-case/*
rm -rf ./SMP/fc-glyphname/*
rm -rf ./SMP/fc-lang/*
rm -rf ./SMP/fc-blanks/*
# ******************TODO**********************//
# Auto generate configure file
echo "fontconfig: Warning contains unknown auto created config.h file."
echo "fontconfig: Updating alias headers (src/*alias.h)."
sh ./src/makealias "./src" SMP/src/fcalias.h SMP/src/fcaliastail.h ./fontconfig/fontconfig.h ./src/fcdeprecate.h ./fontconfig/fcprivate.h
sh ./src/makealias "./src" SMP/src/fcftalias.h SMP/src/fcftaliastail.h ./fontconfig/fcfreetype.h
echo "fontconfig: Updating fcstdint header file (src/fcstdint.h)..."
# Copied from m4/ax_create_stdint_h.m4, line 239
cat > SMP/src/fcstdint.h << EOF
#ifndef _FONTCONFIG_SRC_FCSTDINT_H
#define _FONTCONFIG_SRC_FCSTDINT_H 1
#ifndef _GENERATED_STDINT_H
#define _GENERATED_STDINT_H "fontconfig $FONTCONFIGTAG"
#define _STDINT_HAVE_STDINT_H 1
#include <stdint.h>
#endif
#endif
EOF
echo "fontconfig: Updating fcobjshash header file (src/fcobjshash.h)..."
# Copied from src/MakeFile.am
gcc -E -I. src/fcobjshash.gperf.h | \
sed 's/^ *//;s/ *, */,/' | \
grep '^[^#]' | \
awk ' \
/CUT_OUT_BEGIN/ { no_write=1; next; }; \
/CUT_OUT_END/ { no_write=0; next; }; \
{ if (!no_write) print; next; }; \
' - > SMP/src/fcobjshash.gperf
gperf -m 100 SMP/src/fcobjshash.gperf > SMP/src/fcobjshash.h
rm -f SMP/src/fcobjshash.gperf
echo "fontconfig: Updating font config file (fonts.conf)..."
if !( cp ./fonts.conf.in SMP/fonts.conf &&
sed -i -e 's/@FC_DEFAULT_FONTS@/WINDOWSFONTDIR/g' SMP/fonts.conf &&
sed -i -e 's/@FC_FONTPATH@//g' SMP/fonts.conf &&
sed -i -e 's#@CONFIGDIR@#./fonts/conf.d#g' SMP/fonts.conf &&
sed -i -e 's/@FC_CACHEDIR@/WINDOWSTEMPDIR_FONTCONFIG_CACHE/g' SMP/fonts.conf ); then
echo "fontconfig: Error! font config file update failed"
doExit 1
fi
echo "fontconfig: Updating fc-case header file (fc-case/fc-case.h)..."
if !( python3 ./fc-case/fc-case.py ./fc-case/CaseFolding.txt --template ./fc-case/fccase.tmpl.h --output SMP/fc-case/fccase.h ); then
echo "fontconfig: Error! fc-case file update failed"
doExit 1
fi
echo "fontconfig: Updating fc-lang header file (fc-lang/fc-lang.h)..."
local ORTHFILES=$(cat ./fc-lang/Makefile.am)
ORTHFILES="${ORTHFILES##*ORTH =}"
ORTHFILES="${ORTHFILES%#*}"
ORTHFILES=$(sed -e 's/ \\ / /g' <<< $ORTHFILES)
ORTHFILES=$(sed -e 's/\\ / /g' <<< $ORTHFILES)
ORTHFILES=$(sed -e 's/\\/ /g' <<< $ORTHFILES)
#cd fc-lang
#local ORTHFILES=$(find *.orth -printf "%p ")
#cd ../
if !( python3 ./fc-lang/fc-lang.py $ORTHFILES --template ./fc-lang/fclang.tmpl.h --output SMP/fc-lang/fclang.h --directory ./fc-lang/ ); then
echo "fontconfig: Error! fc-lang file update failed"
doExit 1
fi
rm -rf SMP/tools
echo "fontconfig: Updating fontconfig definition file (libfontconfig.def)."
DEFFILES=$(cat fontconfig/fontconfig.h src/fcdeprecate.h fontconfig/fcprivate.h fontconfig/fcfreetype.h | grep '^Fc[^ ]* *(' | sed -e 's/ *(.*$//' -e 's/^/\t/' | sort)
echo "EXPORTS" > SMP/libfontconfig.def
echo "$DEFFILES" >> SMP/libfontconfig.def
fi
cd ..
echo ""
}
# **** freetype2 ****
dofreetype2() {
# Make sure the freetype2 folder is locally available
doCloneRepo "freetype2" "git@github.com:ShiftMediaProject/freetype2.git"
cd freetype2
# Set the upstream source
doUpstreamSource "freetype2" "https://gitlab.freedesktop.org/freetype/freetype.git"
# Merge the upstream source
doUpstreamMergeTag "freetype2" $FREETYPETAG
if (( $? )); then
echo "freetype2: Removing any previous generated files..."
rm -rf ./SMP/libfreetype.def
echo "freetype2: Updating freetype2 definition file (libfreetype2.def)..."
files=(./include/freetype/*.h)
delete="./include/freetype/ftmac.h"
files=(${files[@]/$delete})
printf -v files "%s " "${files[@]}"
if !( mkdir -p SMP/tools && gcc ./src/tools/apinames.c -o SMP/tools/apinames &&
SMP/tools/apinames -oSMP/libfreetype.def -w $files &&
sed -i -e 's/DESCRIPTION FreeType 2 DLL//g' -e 's/$/\r/' SMP/libfreetype.def ); then
echo "freetype2: Error! definition file update failed"
doExit 1
fi
rm -rf SMP/tools
fi
cd ..
echo ""
}
# **** fribidi ****
dofribidi() {
# Make sure the fribidi folder is locally available
doCloneRepo "fribidi" "git@github.com:ShiftMediaProject/fribidi.git"
cd fribidi
# Set the upstream source
doUpstreamSource "fribidi" "https://github.com/fribidi/fribidi.git"
# Merge the upstream source
doUpstreamMergeTag "fribidi" $FRIBIDITAG
if (( $? )); then
echo "fribidi: Removing any previous generated files..."
rm -rf ./SMP/lib/*
# ******************TODO**********************//
# Auto generate configure file
echo "fribidi: Warning contains unknown auto created config.h file."
echo "fribidi: Updating fibidi-config file (fibidi-config.h)..."
FRIBTAG="${FRIBIDITAG#v*}"
VMICRO="${FRIBTAG##*.}"
VMAJOR="${FRIBTAG%.*}"
VMINOR="${VMAJOR##*.}"
VMAJOR="${VMAJOR%.*}"
VGREP=$(grep -F -m 1 'fribidi_interface_version, ' configure.ac)
VINTERFACE="${VGREP#* }"
VINTERFACE="${VINTERFACE%)*}"
if !( cp lib/fribidi-config.h.in SMP/fribidi-config.h &&
sed -i -e 's/@configure_input@/fribidi-config.h. Generated from fribidi-config.h.in by SMP./g' SMP/fribidi-config.h &&
sed -i -e 's/@PACKAGE@/fribidi/g' SMP/fribidi-config.h &&
sed -i -e 's/@PACKAGE_NAME@/GNU FriBidi/g' SMP/fribidi-config.h &&
sed -i -e 's#@PACKAGE_BUGREPORT@#http://bugs.freedesktop.org/enter_bug.cgi?product=fribidi#g' SMP/fribidi-config.h &&
sed -i -e 's/@FRIBIDI_VERSION@/'$FRIBTAG'/g' SMP/fribidi-config.h &&
sed -i -e 's/@FRIBIDI_MAJOR_VERSION@/'$VMAJOR'/g' SMP/fribidi-config.h &&
sed -i -e 's/@FRIBIDI_MINOR_VERSION@/'$VMINOR'/g' SMP/fribidi-config.h &&
sed -i -e 's/@FRIBIDI_MICRO_VERSION@/'$VMICRO'/g' SMP/fribidi-config.h &&
sed -i -e 's/@FRIBIDI_INTERFACE_VERSION@/'$VINTERFACE'/g' SMP/fribidi-config.h &&
sed -i -e 's/@SIZEOF_INT@/4/g' SMP/fribidi-config.h &&
sed -i -e 's/@FRIBIDI_MSVC_BUILD_PLACEHOLDER@//g' SMP/fribidi-config.h ); then
echo "fribidi: Error! fibidi-config file update failed"
doExit 1
fi
echo "fribidi: Updating generated tab files (lib/*)..."
if !( mkdir -p SMP/tools &&
gcc ./gen.tab/gen-unicode-version.c -DHAVE_CONFIG_H -I./ -I./lib -I./SMP -o SMP/tools/gen-unicode-version &&
SMP/tools/gen-unicode-version ./gen.tab/unidata/ReadMe.txt ./gen.tab/unidata/BidiMirroring.txt > ./SMP/lib/fribidi-unicode-version.h &&
gcc ./gen.tab/gen-bidi-type-tab.c ./gen.tab/packtab.c -DHAVE_CONFIG_H -I./ -I./lib -I./SMP -I./SMP/lib -o SMP/tools/gen-bidi-type-tab &&
SMP/tools/gen-bidi-type-tab 2 ./gen.tab/unidata/UnicodeData.txt ./SMP/lib/fribidi-unicode-version.h > ./SMP/lib/bidi-type.tab.i &&
gcc ./gen.tab/gen-joining-type-tab.c ./gen.tab/packtab.c -DHAVE_CONFIG_H -I./ -I./lib -I./SMP -I./SMP/lib -o SMP/tools/gen-joining-type-tab &&
SMP/tools/gen-joining-type-tab 2 ./gen.tab/unidata/UnicodeData.txt ./gen.tab/unidata/ArabicShaping.txt ./SMP/lib/fribidi-unicode-version.h > ./SMP/lib/joining-type.tab.i &&
gcc ./gen.tab/gen-arabic-shaping-tab.c -DHAVE_CONFIG_H -I./ -I./lib -I./SMP -I./SMP/lib -o SMP/tools/gen-arabic-shaping-tab &&
SMP/tools/gen-arabic-shaping-tab 2 ./gen.tab/unidata/UnicodeData.txt ./SMP/lib/fribidi-unicode-version.h > ./SMP/lib/arabic-shaping.tab.i &&
gcc ./gen.tab/gen-mirroring-tab.c ./gen.tab/packtab.c -DHAVE_CONFIG_H -I./ -I./lib -I./SMP -I./SMP/lib -o SMP/tools/gen-mirroring-tab &&
SMP/tools/gen-mirroring-tab 2 ./gen.tab/unidata/BidiMirroring.txt ./SMP/lib/fribidi-unicode-version.h > ./SMP/lib/mirroring.tab.i &&
gcc ./gen.tab/gen-brackets-tab.c ./gen.tab/packtab.c -DHAVE_CONFIG_H -I./ -I./lib -I./SMP -I./SMP/lib -o SMP/tools/gen-brackets-tab &&
SMP/tools/gen-brackets-tab 2 ./gen.tab/unidata/BidiBrackets.txt ./gen.tab/unidata/UnicodeData.txt ./SMP/lib/fribidi-unicode-version.h > ./SMP/lib/brackets.tab.i &&
gcc ./gen.tab/gen-brackets-type-tab.c ./gen.tab/packtab.c -DHAVE_CONFIG_H -I./ -I./lib -I./SMP -I./SMP/lib -o SMP/tools/gen-brackets-type-tab &&
SMP/tools/gen-brackets-type-tab 2 ./gen.tab/unidata/BidiBrackets.txt ./SMP/lib/fribidi-unicode-version.h > ./SMP/lib/brackets-type.tab.i ); then
echo "fribidi: Error! generated tab files update failed"
doExit 1
fi
rm -rf SMP/tools
fi
cd ..
echo ""
}
# **** game-music-emu ****
dogamemusicemu() {
# Make sure the game-music-emu folder is locally available
doCloneRepo "game-music-emu" "git@github.com:ShiftMediaProject/game-music-emu.git"
cd game-music-emu
# Set the upstream source
doUpstreamSource "game-music-emu" "https://bitbucket.org/mpyne/game-music-emu.git"
# Merge the upstream source
doUpstreamMergeTag "game-music-emu" $GMETAG
if (( $? )); then
echo "game-music-emu: Copying default types header (gme_types.h)..."
if !( cp gme/gme_types.h SMP/gme_types.h ); then
echo "game-music-emu: Error! header file update failed"
doExit 1
fi
fi
cd ..
echo ""
}
# **** gmp ****
dogmp() {
# Make sure the gmp folder is locally available
doCloneRepo "gmp" "git@github.com:ShiftMediaProject/gmp.git"
cd gmp
# Set the upstream source
doUpstreamSource "gmp" "hg::https://gmplib.org/repo/gmp-6.2"
# Merge the upstream source
doUpstreamMergeTag "gmp" $GMPTAG
if (( $? || true )); then
echo "gmp: Removing any previous generated files..."
rm -f ./SMP/gmp.h
rm -f ./SMP/fac_table.h
rm -f ./SMP/fib_table.h
rm -f ./SMP/mp_bases.h
rm -f ./SMP/trialdivtab.h
rm -f ./SMP/mpn/perfsqr.h
rm -f ./SMP/mpn/jacobitab.h
rm -f ./SMP/mpn/mp_bases.c
rm -f ./SMP/mpn/fib_table.c
rm -f ./SMP/gmp-mparam.h
rm -rf ./SMP/mpn/x86_64
rm -rf ./SMP/mpn/x86/*.s
rm -rf ./SMP/mpn/*.h
rm -rf ./SMP/x86
rm -rf ./SMP/x86_64
# ******************TODO**********************//
# Auto generate configure file
echo "gmp: Warning contains unknown auto created config.h file."
echo "gmp: Updating version file (version.h)..."
local VGREP=$(grep -F -m 1 '#define __GNU_MP_VERSION ' gmp-h.in)
local VMAJOR="${VGREP##* }"
local VGREP=$(grep -F -m 1 '#define __GNU_MP_VERSION_MINOR' gmp-h.in)
local VMINOR="${VGREP##* }"
local VGREP=$(grep -F -m 1 '#define __GNU_MP_VERSION_PATCHLEVEL' gmp-h.in)
local VMICRO="${VGREP##* }"
local VVERSIONSTRING="$VMAJOR.$VMINOR.$VMICRO"
cat > SMP/version.h << EOF
/* Version number of package */
#define VERSION "$VVERSIONSTRING"
EOF
echo "gmp: Updating gmp header file (gmp.h)..."
if !( cp gmp-h.in SMP/gmp.h &&
sed -i -e 's/@HAVE_HOST_CPU_FAMILY_power@/0/g' SMP/gmp.h &&
sed -i -e 's/@HAVE_HOST_CPU_FAMILY_powerpc@/0/g' SMP/gmp.h &&
sed -i -e 's/#define GMP_LIMB_BITS @GMP_LIMB_BITS@/#if defined(__x86_64) || defined(_M_X64)\n#define GMP_LIMB_BITS 64\n#else\n#define GMP_LIMB_BITS 32\n#endif/g' SMP/gmp.h &&
sed -i -e 's/@GMP_NAIL_BITS@/0/g' SMP/gmp.h &&
sed -i -e 's/@DEFN_LONG_LONG_LIMB@/#if defined(__x86_64) || defined(_M_X64)\n#define _LONG_LONG_LIMB 1\n#endif/g' SMP/gmp.h &&
sed -i -e 's/@CC@/msvc/g' SMP/gmp.h &&
sed -i -e 's/@CFLAGS@//g' SMP/gmp.h &&
sed -i -e 's/_GMP_EXTERN_INLINE __inline/_GMP_EXTERN_INLINE static __inline/g' SMP/gmp.h &&
sed -i -e 's/#define __GMP_LIBGMP_DLL @LIBGMP_DLL@/#if defined(DLL_EXPORT) \&\& defined(NO_ASM)\n#define __GMP_LIBGMP_DLL 1\n#else\n#define __GMP_LIBGMP_DLL 0\n#endif/g' SMP/gmp.h ); then
echo "gmp: Error! header file update failed"
doExit 1
fi
echo "gmp: Updating gen-bases files (x86[_64]/mp_bases.h, x86[_64]/mpn/mp_bases.c)..."
if !( mkdir -p ./SMP/tools && gcc ./gen-bases.c -o ./SMP/tools/gen-bases &&
mkdir -p ./SMP/x86 &&
mkdir -p ./SMP/x86/mpn &&
./SMP/tools/gen-bases table 32 0 > ./SMP/x86/mpn/mp_bases.c &&
./SMP/tools/gen-bases header 32 0 > ./SMP/x86/mp_bases.h &&
mkdir -p ./SMP/x86_64 &&
mkdir -p ./SMP/x86_64/mpn &&
./SMP/tools/gen-bases table 64 0 > ./SMP/x86_64/mpn/mp_bases.c &&
./SMP/tools/gen-bases header 64 0 > ./SMP/x86_64/mp_bases.h ); then
echo "gmp: Error! gen-bases files update failed"
doExit 1
fi
echo "gmp: Updating gen-fac files (x86[_64]/fac_table.h)..."
if !( gcc ./gen-fac.c -o ./SMP/tools/gen-fac &&
./SMP/tools/gen-fac 32 0 > ./SMP/x86/fac_table.h &&
./SMP/tools/gen-fac 64 0 > ./SMP/x86_64/fac_table.h ); then
echo "gmp: Error! gen-fac files update failed"
doExit 1
fi
echo "gmp: Updating gen-fib files (x86[_64]/fib_table.h, x86[_64]/mpn/fib_table.c)..."
if !( gcc ./gen-fib.c -o ./SMP/tools/gen-fib &&
./SMP/tools/gen-fib table 32 0 > ./SMP/x86/mpn/fib_table.c &&
./SMP/tools/gen-fib header 32 0 > ./SMP/x86/fib_table.h &&
./SMP/tools/gen-fib table 64 0 > ./SMP/x86_64/mpn/fib_table.c &&
./SMP/tools/gen-fib header 64 0 > ./SMP/x86_64/fib_table.h ); then
echo "gmp: Error! gen-fib files update failed"
doExit 1
fi
echo "gmp: Updating gen-jacobitab file (mpn/jacobitab.h)..."
if !( mkdir -p ./SMP/mpn && gcc ./gen-jacobitab.c -o ./SMP/tools/gen-jacobitab &&
./SMP/tools/gen-jacobitab > ./SMP/mpn/jacobitab.h ); then
echo "gmp: Error! gen-jacobitab file update failed"
doExit 1
fi
echo "gmp: Updating gen-psqr files (x86[_64]/mpn/perfsqr.h)..."
if !( gcc ./gen-psqr.c -o ./SMP/tools/gen-psqr &&
./SMP/tools/gen-psqr 32 0 > ./SMP/x86/mpn/perfsqr.h &&
./SMP/tools/gen-psqr 64 0 > ./SMP/x86_64/mpn/perfsqr.h ); then
echo "gmp: Error! gen-psqr files update failed"
doExit 1
fi
echo "gmp: Updating gen-trialdivtab files (x86[_64]/mpn/trialdivtab.h)..."
if !( gcc ./gen-trialdivtab.c -o ./SMP/tools/gen-trialdivtab &&
./SMP/tools/gen-trialdivtab 32 8000 > ./SMP/x86/trialdivtab.h &&
./SMP/tools/gen-trialdivtab 64 8000 > ./SMP/x86_64/trialdivtab.h ); then
echo "gmp: Error! gen-trialdivtab files update failed"
doExit 1
fi
rm -rf SMP/tools