-
Notifications
You must be signed in to change notification settings - Fork 1
/
bigbrownbuild.sh
executable file
·1770 lines (1562 loc) · 95.9 KB
/
bigbrownbuild.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
# NOTE: for all fancy ascii art text in this script use this generator: http://www.patorjk.com/software/taag/#p=display&f=Big&t=Cross
#set -e #stop on any error encountered
#set -x #echo all commands
set -Eeo pipefail #enable error trapping
mainbrown()
{
#
# Make sure this is being run under bash
# Very bad things happen on other shells (like sh)
#
if [ -z "$BASH_VERSION" ]; then
echo "Please run this script under bash!"
exit
fi
#
# Where the compiler(s) will be installed. Feel free to change. If you specify a path that requires root
# privileges, then this script must be run as root!
#
INSTALL_PREFIX=${HOME}/brown
#
# Ensure flex and bison is installed
# Don't look at me about what this does, I just copied it from stack overflow...
# (https://stackoverflow.com/a/677212)
#
#command -v bison >/dev/null 2>&1 || { echo >&2 "I require bison but it's not installed. Aborting."; exit 1; }
#command -v flex >/dev/null 2>&1 || { echo >&2 "I require flex but it's not installed. Aborting."; exit 1; }
#
# User definable stuff
#
# Set this to "A" if you want a completely automated run
GLOBAL_OVERRIDE=A
# Set this to 0 if you don't want to build fortran at all.
# For now this is only enabled for gcc 7.x anyway.
# If anyone wants to test this on older gccs, be my guest
# Fortran does NOT work when CROSS_COMPILING=1 for now!
GLOBAL_BUILD_FORTRAN=0
# Set this to 1 if you want to tell gcc to download and
# build prerequisite libraries if they are not installed
# on your system
GLOBAL_DOWNLOAD_PREREQUISITES=1
# Use less RAM when compiling, for low end systems
USE_MIN_RAM=0
# Set this to 1 if you are building a compiler for a different platform. For example you are building this
# on a x64 PC and want to produce a compiler that runs on ARM. Note that you are required to have the
# platform's cross compiler installed and change HOST AND HOST_PREFIX from the examples below to your
# actual compiler names
CROSS_COMPILING=0
# Which gccs to build. 1=Build, anything else=Don't build
BUILD_4_6_4=0 # Produces Internal Compiler Error when built with gcc 4.8.5?
BUILD_4_9_4=0
BUILD_5_4_0=0
BUILD_6_2_0=0
BUILD_7_1_0=0
BUILD_7_2_0=0
BUILD_7_3_0=0
BUILD_8_1_0=0
BUILD_8_2_0=0
BUILD_8_3_0=0
BUILD_9_1_0=0
BUILD_9_2_0=0
BUILD_9_3_0=0
BUILD_10_1_0=0
BUILD_10_2_0=0
BUILD_10_3_0=0
BUILD_11_1_0=0
BUILD_11_2_0=0
BUILD_12_1_0=0
BUILD_12_2_0=0
BUILD_13_1_0=0
BUILD_13_2_0=0
BUILD_14_1_0=1
BUILD_TRUNK=0 # NOTE: requires 'makeinfo' (installed by package texinfo on ubuntu, at least)
TRUNK_VERSION=15.0.0 # This needs to change with every major gcc release
if [ "$CROSS_COMPILING" == "1" ]; then
# The cross compiler we are building is supposedly called "canadian", because
# "host", "build" and "target" are all different. For more info (as if anyone cares)
# read https://crosstool-ng.github.io/docs/toolchain-types/
export PATH=$PATH:/home/ggn/gcc-linaro-7.1.1-2017.05-x86_64_arm-linux-gnueabihf/bin
HOST=--host=arm-linux-gnueabihf
HOST_PREFIX=arm-linux-gnueabihf-
BUILD="--build $(gcc -dumpmachine)"
fi
# Some global stuff that are platform dependent
HOMEDIR=$PWD
NICE='nice -n 19'
JMULT=-j12
SED=sed
TAR=tar
TAROPTS='--owner=0 --group=0'
# Only set this to nonzero when you do want to build mintlib
# Note that if you don't build mintlib then libstdc++v3 will also fail to build
BUILD_MINTLIB=1
# Set this to nonzero to build Newlib instead of MiNTlib (experimental for now)
BUILD_NEWLIB=0
#
# Setup stuff
#
# Figure out from what environment we are being run
# Nicked from https://stackoverflow.com/a/3466183
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
MSYS*) machine=msys;;
*) machine="UNKNOWN:${unameOut}"
esac
echo Host machine: $machine
host_arch=`uname -m`
if [ "$machine" == "msys" ]; then
# msys default compilers generate binaries that are dependent
# on msys dlls. Which means you need to ship msys dlls alongside.
# So let's just refuse to build on msys and force people to use
# a MinGW shell instead (which is what people wanted anyway)
echo "Refusing to build on Msys shell, use a MinGW shell instead!"
exit
fi
# If building 4.6.4 warn the user that the coldfire mintlib is hosed
# and thus disabled for now
if [ "$GLOBAL_OVERRIDE" == "A" ] || [ "$GLOBAL_OVERRIDE" == "a" ]; then
GLOBAL_SKIP_464_CF=Y
else
if [ "$BUILD_4_6_4" == "1" ]; then
echo You\'re building gcc 4.6.4
echo Be aware that currently when building MiNTlib the cross compiler
echo throws an Internal Compiler Error when trying to build the coldfire
echo target, thus it is disabled. Answer no to the question below
echo otherwise and/or file a report to the authors if you know how
echo to overcome this!
read -p "Disable building MiNTlib for coldfire on 4.6.4?" -n 1 -r GLOBAL_SKIP_464_CF
echo
fi
fi
# As per https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag/3801032#3801032
# you can't build static binaries on Apple silicon platforms. Fantastic
if [ "$machine" == "Mac" ]; then
STATIC=
STATIC_LINK=
else
STATIC=-static
STATIC_LINK=-Wl,-Bstatic
fi
if [ "$machine" == "Mac" ]; then
TAR=tar
SED=gsed
TAROPTS=
fi
if [ "$machine" == "MinGw" ]; then
unset NICE
# Flex is a msys built package but we use the mingw32 compiler.
# Instead of modifying the Makefiles (urgh) just copy the
# flex library over where mingw's lib search path will find it.
# Not the best practice but hey...
cp /usr/lib/libfl.a /mingw64/lib
fi
if [ "$machine" == "Cygwin" ]; then
# Disable some stuff for cygwin as well
unset NICE
# This is probably safe for cygwin, but only been tested
# when building gcc 7.x
fi
# Cleanup folders
if [ "$GLOBAL_OVERRIDE" == "A" ] || [ "$GLOBAL_OVERRIDE" == "a" ]; then
echo "Cleaning up build dirs from previous build"
CLEANUP=Y
else
read -p "Cleanup build dirs from previous build?" -n 1 -r
echo
fi
if [ "$CLEANUP" == "Y" ] || [ "$CLEANUP" == "y" ]; then
if [ "$BUILD_4_6_4" == "1" ] || [ "$BUILD_4_9_4" == "1" ] || [ "$BUILD_5_4_0" == "1" ] || [ "$BUILD_6_2_0" == "1" ] || [ "$BUILD_7_1_0" == "1" ] || [ "$BUILD_7_2_0" == "1" ] || [ "$BUILD_7_3_0" == "1" ] || [ "$BUILD_8_1_0" == "1" ]; then
if [ ! -f binutils-2.27.tar.bz2 ]; then rm -rf binutils-2.27; fi; fi
if [ "$BUILD_8_2_0" == "1" ]; then
if [ ! -f binutils-2.31.tar.xz ]; then rm -rf binutils-2.31; fi; fi
if [ "$BUILD_8_3_0" == "1" ] || [ "$BUILD_9_1_0" == "1" ] || [ "$BUILD_9_2_0" == "1" ] || [ "$BUILD_9_3_0" == "1" ]; then
if [ ! -f binutils-2.32.tar.xz ]; then rm -rf binutils-2.32; fi; fi
if [ "$BUILD_10_1_0" == "1" ]; then
if [ ! -f binutils-2.34.tar.xz ]; then rm -rf binutils-2.34; fi; fi
if [ "$BUILD_10_2_0" == "1" ] || [ "$BUILD_10_3_0" == "1" ]; then
if [ ! -f binutils-2.35.tar.xz ]; then rm -rf binutils-2.35; fi; fi
if [ "$BUILD_11_1_0" == "1" ]; then
if [ ! -f binutils-2.36.tar.xz ]; then rm -rf binutils-2.36; fi; fi
if [ "$BUILD_11_2_0" == "1" ]; then
if [ ! -f binutils-2.37.tar.xz ]; then rm -rf binutils-2.37; fi; fi
if [ "$BUILD_12_1_0" == "1" ]; then
if [ ! -f binutils-2.38.tar.xz ]; then rm -rf binutils-2.38; fi; fi
if [ "$BUILD_12_2_0" == "1" ]; then
if [ ! -f binutils-2.39.tar.xz ]; then rm -rf binutils-2.39; fi; fi
if [ "$BUILD_13_1_0" == "1" ]; then
if [ ! -f binutils-2.40.tar.xz ]; then rm -rf binutils-2.40; fi; fi
if [ "$BUILD_13_2_0" == "1" ]; then
if [ ! -f binutils-2.41.tar.xz ]; then rm -rf binutils-2.41; fi; fi
if [ "$BUILD_14_1_0" == "1" ] || [ "$BUILD_TRUNK" == "1" ]; then
if [ ! -f binutils-2.41.tar.xz ]; then rm -rf binutils-2.42; fi; fi
rm -rf mintlib-bigbrownbuild
rm -rf build-newlib*
fi
# Get all the things
echo "Downloading all relevant archives"
if [ "$BUILD_4_6_4" == "1" ]; then if [ ! -f gcc-4.6.4.tar.bz2 ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-4.6.4/gcc-4.6.4.tar.bz2 --quiet; fi; fi
if [ "$BUILD_4_9_4" == "1" ]; then if [ ! -f gcc-4.9.4.tar.bz2 ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-4.9.4/gcc-4.9.4.tar.bz2 --quiet; fi; fi
if [ "$BUILD_5_4_0" == "1" ]; then if [ ! -f gcc-5.4.0.tar.bz2 ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.bz2 --quiet; fi; fi
if [ "$BUILD_6_2_0" == "1" ]; then if [ ! -f gcc-6.2.0.tar.bz2 ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-6.2.0/gcc-6.2.0.tar.bz2 --quiet; fi; fi
if [ "$BUILD_7_1_0" == "1" ]; then if [ ! -f gcc-7.1.0.tar.bz2 ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-7.1.0/gcc-7.1.0.tar.bz2 --quiet; fi; fi
if [ "$BUILD_7_2_0" == "1" ]; then if [ ! -f gcc-7.2.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.xz --quiet; fi; fi
if [ "$BUILD_7_3_0" == "1" ]; then if [ ! -f gcc-7.3.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.xz --quiet; fi; fi
if [ "$BUILD_8_1_0" == "1" ]; then if [ ! -f gcc-8.1.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-8.1.0/gcc-8.1.0.tar.xz --quiet; fi; fi
if [ "$BUILD_8_2_0" == "1" ]; then if [ ! -f gcc-8.2.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.xz --quiet; fi; fi
if [ "$BUILD_8_3_0" == "1" ]; then if [ ! -f gcc-8.3.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz --quiet; fi; fi
if [ "$BUILD_9_1_0" == "1" ]; then if [ ! -f gcc-9.1.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-9.1.0/gcc-9.1.0.tar.xz --quiet; fi; fi
if [ "$BUILD_9_2_0" == "1" ]; then if [ ! -f gcc-9.2.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz --quiet; fi; fi
if [ "$BUILD_9_3_0" == "1" ]; then if [ ! -f gcc-9.3.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.xz --quiet; fi; fi
if [ "$BUILD_10_1_0" == "1" ]; then if [ ! -f gcc-10.1.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-10.1.0/gcc-10.1.0.tar.xz --quiet; fi; fi
if [ "$BUILD_10_2_0" == "1" ]; then if [ ! -f gcc-10.2.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-10.2.0/gcc-10.2.0.tar.xz --quiet; fi; fi
if [ "$BUILD_10_3_0" == "1" ]; then if [ ! -f gcc-10.3.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-10.3.0/gcc-10.3.0.tar.xz --quiet; fi; fi
if [ "$BUILD_11_1_0" == "1" ]; then if [ ! -f gcc-11.1.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-11.1.0/gcc-11.1.0.tar.xz --quiet; fi; fi
if [ "$BUILD_11_2_0" == "1" ]; then if [ ! -f gcc-11.2.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.xz --quiet; fi; fi
if [ "$BUILD_12_1_0" == "1" ]; then if [ ! -f gcc-12.1.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-12.1.0/gcc-12.1.0.tar.xz --quiet; fi; fi
if [ "$BUILD_12_2_0" == "1" ]; then if [ ! -f gcc-12.2.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-12.2.0/gcc-12.2.0.tar.xz --quiet; fi; fi
if [ "$BUILD_13_1_0" == "1" ]; then if [ ! -f gcc-13.1.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-13.1.0/gcc-13.1.0.tar.xz --quiet; fi; fi
if [ "$BUILD_13_2_0" == "1" ]; then if [ ! -f gcc-13.2.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.xz --quiet; fi; fi
if [ "$BUILD_14_1_0" == "1" ]; then if [ ! -f gcc-14.1.0.tar.xz ]; then wget ftp://ftp.gnu.org/pub/pub/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.xz --quiet; fi; fi
if [ "$BUILD_TRUNK" == "1" ]; then if [ ! -d gcc-TRUNK ]; then git clone git://gcc.gnu.org/git/gcc.git gcc-TRUNK --quiet; fi; fi
if [ "$BUILD_4_6_4" == "1" ] || [ "$BUILD_4_9_4" == "1" ] || [ "$BUILD_5_4_0" == "1" ] || [ "$BUILD_6_2_0" == "1" ] || [ "$BUILD_7_1_0" == "1" ] || [ "$BUILD_7_2_0" == "1" ] || [ "$BUILD_7_3_0" == "1" ] || [ "$BUILD_8_1_0" == "1" ]; then
if [ ! -f binutils-2.27.tar.bz2 ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.bz2 --quiet; fi; fi
if [ "$BUILD_8_2_0" == "1" ]; then
if [ ! -f binutils-2.31.tar.xz ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.31.tar.xz --quiet; fi; fi
if [ "$BUILD_8_3_0" == "1" ] || [ "$BUILD_9_1_0" == "1" ] || [ "$BUILD_9_2_0" == "1" ] || [ "$BUILD_9_3_0" == "1" ]; then
if [ ! -f binutils-2.32.tar.xz ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.32.tar.xz --quiet; fi; fi
if [ "$BUILD_10_1_0" == "1" ]; then
if [ ! -f binutils-2.34.tar.xz ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.34.tar.xz --quiet; fi; fi
if [ "$BUILD_10_2_0" == "1" ] || [ "$BUILD_10_3_0" == "1" ]; then
if [ ! -f binutils-2.35.tar.xz ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.35.tar.xz --quiet; fi; fi
if [ "$BUILD_11_1_0" == "1" ]; then
if [ ! -f binutils-2.36.tar.xz ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.36.tar.xz --quiet; fi; fi
if [ "$BUILD_11_2_0" == "1" ]; then
if [ ! -f binutils-2.37.tar.xz ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.37.tar.xz --quiet; fi; fi
if [ "$BUILD_12_1_0" == "1" ]; then
if [ ! -f binutils-2.38.tar.xz ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.xz --quiet; fi; fi
if [ "$BUILD_12_2_0" == "1" ]; then
if [ ! -f binutils-2.39.tar.xz ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.39.tar.xz --quiet; fi; fi
if [ "$BUILD_13_1_0" == "1" ]; then
if [ ! -f binutils-2.40.tar.xz ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.40.tar.xz --quiet; fi; fi
if [ "$BUILD_13_2_0" == "1" ]; then
if [ ! -f binutils-2.41.tar.xz ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.xz --quiet; fi; fi
if [ "$BUILD_14_1_0" == "1" ] || [ "$BUILD_TRUNK" == "1" ]; then
if [ ! -f binutils-2.42.tar.xz ]; then wget http://ftp.gnu.org/gnu/binutils/binutils-2.42.tar.xz --quiet; fi; fi
if [ ! -d mintlib-bigbrownbuild ]; then git clone https://github.com/ggnkua/mintlib-bigbrownbuild.git --quiet; fi
if [ "$BUILD_NEWLIB" != "0" ]; then if [ ! -f newlib-4.1.0.tar.gz ]; then wget ftp://sourceware.org/pub/newlib/newlib-4.1.0.tar.gz --quiet; fi; fi
# requires GMP, MPFR and MPC
# Unpack all the things
cd "$HOMEDIR"
if [ "$GLOBAL_OVERRIDE" == "A" ] || [ "$GLOBAL_OVERRIDE" == "a" ]; then
echo "Unpacking binutils, gcc (, Newlib)"
REPLY=Y
else
read -p "Unpack binutils, gcc (, Newlib)?" -n 1 -r
echo
fi
if [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; then
if [ "$CLEANUP" == "Y" ]; then
if [ "$BUILD_4_6_4" == "1" ]; then rm -rf gcc-4.6.4; fi
if [ "$BUILD_4_9_4" == "1" ]; then rm -rf gcc-4.9.4; fi
if [ "$BUILD_5_4_0" == "1" ]; then rm -rf gcc-5.4.0; fi
if [ "$BUILD_6_2_0" == "1" ]; then rm -rf gcc-6.2.0; fi
if [ "$BUILD_7_1_0" == "1" ]; then rm -rf gcc-7.1.0; fi
if [ "$BUILD_7_2_0" == "1" ]; then rm -rf gcc-7.2.0; fi
if [ "$BUILD_7_3_0" == "1" ]; then rm -rf gcc-7.3.0; fi
if [ "$BUILD_8_1_0" == "1" ]; then rm -rf gcc-8.1.0; fi
if [ "$BUILD_8_2_0" == "1" ]; then rm -rf gcc-8.2.0; fi
if [ "$BUILD_8_3_0" == "1" ]; then rm -rf gcc-8.3.0; fi
if [ "$BUILD_9_1_0" == "1" ]; then rm -rf gcc-9.1.0; fi
if [ "$BUILD_9_2_0" == "1" ]; then rm -rf gcc-9.2.0; fi
if [ "$BUILD_9_3_0" == "1" ]; then rm -rf gcc-9.3.0; fi
if [ "$BUILD_10_1_0" == "1" ]; then rm -rf gcc-10.1.0; fi
if [ "$BUILD_10_2_0" == "1" ]; then rm -rf gcc-10.2.0; fi
if [ "$BUILD_10_3_0" == "1" ]; then rm -rf gcc-10.3.0; fi
if [ "$BUILD_11_1_0" == "1" ]; then rm -rf gcc-11.1.0; fi
if [ "$BUILD_11_2_0" == "1" ]; then rm -rf gcc-11.2.0; fi
if [ "$BUILD_12_1_0" == "1" ]; then rm -rf gcc-12.1.0; fi
if [ "$BUILD_12_2_0" == "1" ]; then rm -rf gcc-12.2.0; fi
if [ "$BUILD_13_1_0" == "1" ]; then rm -rf gcc-13.1.0; fi
if [ "$BUILD_13_2_0" == "1" ]; then rm -rf gcc-13.2.0; fi
if [ "$BUILD_14_1_0" == "1" ]; then rm -rf gcc-14.1.0; fi
fi
if [ "$BUILD_4_6_4" == "1" ]; then tar -jxf gcc-4.6.4.tar.bz2; fi
if [ "$BUILD_4_9_4" == "1" ]; then tar -jxf gcc-4.9.4.tar.bz2; fi
if [ "$BUILD_5_4_0" == "1" ]; then tar -jxf gcc-5.4.0.tar.bz2; fi
if [ "$BUILD_6_2_0" == "1" ]; then tar -jxf gcc-6.2.0.tar.bz2; fi
if [ "$BUILD_7_1_0" == "1" ]; then tar -jxf gcc-7.1.0.tar.bz2; fi
if [ "$BUILD_7_2_0" == "1" ]; then tar -Jxf gcc-7.2.0.tar.xz; fi
if [ "$BUILD_7_3_0" == "1" ]; then tar -Jxf gcc-7.3.0.tar.xz; fi
if [ "$BUILD_8_1_0" == "1" ]; then tar -Jxf gcc-8.1.0.tar.xz; fi
if [ "$BUILD_8_2_0" == "1" ]; then tar -Jxf gcc-8.2.0.tar.xz; fi
if [ "$BUILD_8_3_0" == "1" ]; then tar -Jxf gcc-8.3.0.tar.xz; fi
if [ "$BUILD_9_1_0" == "1" ]; then tar -Jxf gcc-9.1.0.tar.xz; fi
if [ "$BUILD_9_2_0" == "1" ]; then tar -Jxf gcc-9.2.0.tar.xz; fi
if [ "$BUILD_9_3_0" == "1" ]; then tar -Jxf gcc-9.3.0.tar.xz; fi
if [ "$BUILD_10_1_0" == "1" ]; then tar -Jxf gcc-10.1.0.tar.xz; fi
if [ "$BUILD_10_2_0" == "1" ]; then tar -Jxf gcc-10.2.0.tar.xz; fi
if [ "$BUILD_10_3_0" == "1" ]; then tar -Jxf gcc-10.3.0.tar.xz; fi
if [ "$BUILD_11_1_0" == "1" ]; then tar -Jxf gcc-11.1.0.tar.xz; fi
if [ "$BUILD_11_2_0" == "1" ]; then tar -Jxf gcc-11.2.0.tar.xz; fi
if [ "$BUILD_12_1_0" == "1" ]; then tar -Jxf gcc-12.1.0.tar.xz; fi
if [ "$BUILD_12_2_0" == "1" ]; then tar -Jxf gcc-12.2.0.tar.xz; fi
if [ "$BUILD_13_1_0" == "1" ]; then tar -Jxf gcc-13.1.0.tar.xz; fi
if [ "$BUILD_13_2_0" == "1" ]; then tar -Jxf gcc-13.2.0.tar.xz; fi
if [ "$BUILD_14_1_0" == "1" ]; then tar -Jxf gcc-14.1.0.tar.xz; fi
if [ "$BUILD_TRUNK" == "1" ]; then cd gcc-TRUNK && git reset --hard HEAD --quiet && cd ..; fi
if [ "$GLOBAL_DOWNLOAD_PREREQUISITES" == "1" ]; then
if [ "$BUILD_4_6_4" == "1" ]; then cd gcc-4.6.4;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_4_9_4" == "1" ]; then cd gcc-4.9.4;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_5_4_0" == "1" ]; then cd gcc-5.4.0;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_6_2_0" == "1" ]; then cd gcc-6.2.0;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_7_1_0" == "1" ]; then cd gcc-7.1.0;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_7_2_0" == "1" ]; then cd gcc-7.2.0;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_7_3_0" == "1" ]; then cd gcc-7.3.0;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_8_1_0" == "1" ]; then cd gcc-8.1.0;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_8_2_0" == "1" ]; then cd gcc-8.2.0;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_8_3_0" == "1" ]; then cd gcc-8.3.0;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_9_1_0" == "1" ]; then cd gcc-9.1.0;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_9_2_0" == "1" ]; then cd gcc-9.2.0;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_9_3_0" == "1" ]; then cd gcc-9.3.0;./contrib/download_prerequisites &> prerequisites.log; cd "$HOMEDIR"; fi
if [ "$BUILD_10_1_0" == "1" ]; then cd gcc-10.1.0;./contrib/download_prerequisites &> prerequisites.log;cd "$HOMEDIR"; fi
if [ "$BUILD_10_2_0" == "1" ]; then cd gcc-10.2.0;./contrib/download_prerequisites &> prerequisites.log;cd "$HOMEDIR"; fi
if [ "$BUILD_10_3_0" == "1" ]; then cd gcc-10.3.0;./contrib/download_prerequisites &> prerequisites.log;cd "$HOMEDIR"; fi
if [ "$BUILD_11_1_0" == "1" ]; then cd gcc-11.1.0;./contrib/download_prerequisites &> prerequisites.log;cd "$HOMEDIR"; fi
if [ "$BUILD_11_2_0" == "1" ]; then cd gcc-11.2.0;./contrib/download_prerequisites &> prerequisites.log;cd "$HOMEDIR"; fi
if [ "$BUILD_12_1_0" == "1" ]; then cd gcc-12.1.0;./contrib/download_prerequisites &> prerequisites.log;cd "$HOMEDIR"; fi
if [ "$BUILD_12_2_0" == "1" ]; then cd gcc-12.2.0;./contrib/download_prerequisites &> prerequisites.log;cd "$HOMEDIR"; fi
if [ "$BUILD_13_1_0" == "1" ]; then cd gcc-13.1.0;./contrib/download_prerequisites &> prerequisites.log;cd "$HOMEDIR"; fi
if [ "$BUILD_13_2_0" == "1" ]; then cd gcc-13.2.0;./contrib/download_prerequisites &> prerequisites.log;cd "$HOMEDIR"; fi
if [ "$BUILD_14_1_0" == "1" ]; then cd gcc-14.1.0;./contrib/download_prerequisites &> prerequisites.log;cd "$HOMEDIR"; fi
if [ "$BUILD_TRUNK" == "1" ]; then cd gcc-TRUNK;./contrib/download_prerequisites &> prerequisites.log;cd "$HOMEDIR"; fi
fi
if [ "$BUILD_NEWLIB" != "0" ]; then tar -zxf newlib-4.1.0.tar.gz; fi
if [ "$BUILD_4_6_4" == "1" ] || [ "$BUILD_4_9_4" == "1" ] || [ "$BUILD_5_4_0" == "1" ] || [ "$BUILD_6_2_0" == "1" ] || [ "$BUILD_7_1_0" == "1" ] || [ "$BUILD_7_2_0" == "1" ] || [ "$BUILD_7_3_0" == "1" ] || [ "$BUILD_8_1_0" == "1" ]; then
tar -jxf binutils-2.27.tar.bz2
fi
if [ "$BUILD_8_2_0" == "1" ]; then tar -Jxf binutils-2.31.tar.xz; fi
if [ "$BUILD_8_3_0" == "1" ] || [ "$BUILD_9_1_0" == "1" ] || [ "$BUILD_9_2_0" == "1" ] || [ "$BUILD_9_3_0" == "1" ]; then tar -Jxf binutils-2.32.tar.xz; fi
if [ "$BUILD_10_1_0" == "1" ]; then tar -Jxf binutils-2.34.tar.xz; fi
if [ "$BUILD_10_2_0" == "1" ] || [ "$BUILD_10_3_0" == "1" ]; then tar -Jxf binutils-2.35.tar.xz; fi
if [ "$BUILD_11_1_0" == "1" ]; then tar -Jxf binutils-2.36.tar.xz; fi
if [ "$BUILD_11_2_0" == "1" ]; then tar -Jxf binutils-2.37.tar.xz; fi
if [ "$BUILD_12_1_0" == "1" ]; then tar -Jxf binutils-2.38.tar.xz; fi
if [ "$BUILD_12_2_0" == "1" ]; then tar -Jxf binutils-2.39.tar.xz; fi
if [ "$BUILD_13_1_0" == "1" ]; then tar -Jxf binutils-2.40.tar.xz; fi
if [ "$BUILD_13_2_0" == "1" ]; then tar -Jxf binutils-2.41.tar.xz; fi
if [ "$BUILD_14_1_0" == "1" ] || [ "$BUILD_TRUNK" == "1" ]; then tar -Jxf binutils-2.42.tar.xz; fi
fi
#
# Start the build
#
BINUTILS=2.27
# Building Fortran for old gcc versions doesn't seem to work so it's disabled for now...
BUILD_FORTRAN=0
NO_RTTI="-fno-rtti"
SKIP_464_CF=$GLOBAL_SKIP_464_CF # Enabled only for 4.6.4
if [ "$BUILD_4_6_4" == "1" ]; then buildgcc 4.6.4; fi
SKIP_464_CF=0
if [ "$BUILD_4_9_4" == "1" ]; then buildgcc 4.9.4; fi
if [ "$BUILD_5_4_0" == "1" ]; then buildgcc 5.4.0; fi
if [ "$BUILD_6_2_0" == "1" ]; then buildgcc 6.2.0; fi
BUILD_FORTRAN=$GLOBAL_BUILD_FORTRAN
if [ "$BUILD_7_1_0" == "1" ]; then buildgcc 7.1.0; fi
if [ "$BUILD_7_2_0" == "1" ]; then buildgcc 7.2.0; fi
if [ "$BUILD_7_3_0" == "1" ]; then buildgcc 7.3.0; fi
if [ "$BUILD_8_1_0" == "1" ]; then buildgcc 8.1.0; fi
BINUTILS=2.31
if [ "$BUILD_8_2_0" == "1" ]; then buildgcc 8.2.0; fi
BINUTILS=2.32
if [ "$BUILD_8_3_0" == "1" ]; then buildgcc 8.3.0; fi
if [ "$BUILD_9_1_0" == "1" ]; then buildgcc 9.1.0; fi
if [ "$BUILD_9_2_0" == "1" ]; then buildgcc 9.2.0; fi
if [ "$BUILD_9_3_0" == "1" ]; then buildgcc 9.3.0; fi
BINUTILS=2.34
if [ "$BUILD_10_1_0" == "1" ]; then buildgcc 10.1.0; fi
BINUTILS=2.35
if [ "$BUILD_10_2_0" == "1" ]; then buildgcc 10.2.0; fi
if [ "$BUILD_10_3_0" == "1" ]; then buildgcc 10.3.0; fi
BINUTILS=2.36
if [ "$BUILD_11_1_0" == "1" ]; then buildgcc 11.1.0; fi
BINUTILS=2.37
if [ "$BUILD_11_2_0" == "1" ]; then buildgcc 11.2.0; fi
BINUTILS=2.38
if [ "$BUILD_12_1_0" == "1" ]; then buildgcc 12.1.0; fi
BINUTILS=2.39
if [ "$BUILD_12_2_0" == "1" ]; then buildgcc 12.2.0; fi
BINUTILS=2.40
if [ "$BUILD_13_1_0" == "1" ]; then buildgcc 13.1.0; fi
BINUTILS=2.41
if [ "$BUILD_13_2_0" == "1" ]; then buildgcc 13.2.0; fi
NO_RTTI=
BINUTILS=2.42
if [ "$BUILD_14_1_0" == "1" ]; then buildgcc 14.1.0; fi
if [ "$BUILD_TRUNK" == "1" ]; then buildgcc TRUNK; fi
echo "All done!"
}
# Build subroutine
# Parameter 1=version
buildgcc()
{
# Construct compiler vendor name
echo ----------------------
echo Building gcc $1...
VENDOR=atari$1
case "$1" in # Brown up the names
4.6.4) VENDOR=atarioriginalbrown;;
4.9.4) VENDOR=atarioriginalbrowner;;
5.4.0) VENDOR=ataribrownish;;
6.2.0) VENDOR=ataribrown;;
7.1.0) VENDOR=ataribrowner;;
7.2.0) VENDOR=ataribrownerer;;
7.3.0) VENDOR=ataribrownest;;
8.1.0) VENDOR=atariultrabrown;;
8.2.0) VENDOR=ataribrownart;;
8.3.0) VENDOR=atariultrabrowner;;
9.1.0) VENDOR=atarihyperbrown;;
9.2.0) VENDOR=atarihyperbrowner;;
9.3.0) VENDOR=atarihyperbrownest;;
10.1.0) VENDOR=atariextrabrown;;
10.2.0) VENDOR=atariextrabrowner;;
10.3.0) VENDOR=atariextrabrownest;;
11.1.0) VENDOR=atarisuperbrown;;
11.2.0) VENDOR=atarisuperbrowner;;
12.1.0) VENDOR=atarimegabrown;;
12.2.0) VENDOR=atarimegabrowner;;
13.1.0) VENDOR=atariturbobrown;;
13.2.0) VENDOR=atariturbobrowner;;
14.1.0) VENDOR=atarisubliminalbrown;;
TRUNK) VENDOR=ataribleedingbrown;;
esac # Brooooooooown
# Clean build folders if requested
if [ "$CLEANUP" == "Y" ]; then rm -rf build-gcc-$1 build-binutils-$1 mintlib-bigbrownbuild-$1 build-newlib-$1; cp -frp mintlib-bigbrownbuild mintlib-bigbrownbuild-$1; fi
if [ "$BUILD_NEWLIB" != "0" ]; then cp -frp newlib-4.1.0 newlib-4.1.0-$1; fi
if [ "$BUILD_FORTRAN" == "1" ]; then
LANGUAGES=c,c++,fortran
else
LANGUAGES=c,c++
fi
if [ "$USE_MIN_RAM" == "1" ]; then
MIN_RAM_CFLAGS="--param ggc-min-expand=10 --param ggc-min-heapsize=32768"
export CFLAGS=$MIN_RAM_CFLAGS
export CXXFLAGS=$MIN_RAM_CFLAGS
fi
export CFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer -fleading-underscore -fno-plt -fno-pic $MIN_RAM_CFLAGS"
export CXXFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer -fleading-underscore -fno-plt -fno-pic -fno-threadsafe-statics -fno-exceptions ${NO_RTTI} $MIN_RAM_CFLAGS"
export LDFLAGS_FOR_TARGET="--emit-relocs -Ttext=0"
# ____ _ _ _ _
# | _ \(_) | | (_) |
# | |_) |_ _ __ _ _| |_ _| |___
# | _ <| | '_ \| | | | __| | / __|
# | |_) | | | | | |_| | |_| | \__ \
# |____/|_|_| |_|\__,_|\__|_|_|___/
# binutils build dir
# Configure, build and install binutils for m68k elf
if [ "$GLOBAL_OVERRIDE" == "A" ] || [ "$GLOBAL_OVERRIDE" == "a" ]; then
echo "Configuring, building and installing binutils"
REPLY=Y
else
read -p "Configure, build and install binutils?" -n 1 -r
echo
fi
if [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; then
# For gcc 8.x and MinGW, patch some nuisances in the source
if [ "$machine" == "MinGw" ]; then
if [ "$BINUTILS" == "2.31" ]; then
# No MinGW isntall I have knows what ENOTSUP is.
# Random internet suggestions said to replace this with ENOSYS so here we go
$SED -i -e "s/ENOTSUP/ENOSYS/gI" $HOMEDIR/binutils-$BINUTILS/libiberty/simple-object-elf.c
fi
if [ "$BINUTILS" == "2.37" ]; then
# For some reason the following file uses type 'uint'. Twice only. This compiles cleanly
# on linux with gcc 6.3.0. I have 0 ideas why it doesn't here (gcc 10.2.0)
$SED -i -e "s/ uint / uint64_t /gI" $HOMEDIR/binutils-$BINUTILS/libiberty/rust-demangle.c
$SED -i -e "s/(uint)/(uint64_t)/gI" $HOMEDIR/binutils-$BINUTILS/libiberty/rust-demangle.c
fi
fi
# Patch Text start to be 0x00000000 instead of 0x80000000
$SED -i -e "s/TEXT_START_ADDR=0x80000000/TEXT_START_ADDR=0x00000000/gI" binutils-$BINUTILS/ld/emulparams/m68kelf.sh
if [ "$CROSS_COMPILING" != "0" ]; then
echo "Building temp local bintools..."
rm -rf "$HOMEDIR"/crosstemp-$1
mkdir -p "$HOMEDIR"/crosstemp-$1
cd "$HOMEDIR"/crosstemp-$1
../binutils-$BINUTILS/configure --disable-multilib --disable-nls --enable-lto --prefix=$INSTALL_PREFIX-crosstemp-$1 --target=m68k-$VENDOR-elf LDFLAGS=$STATIC &> binutils_cross_config.log
make $JMULT &> binutils_cross_build.log
make install $JMULT &> binutils_cross_install.log
#echo "Building temp local gcc..."
rm -rf "$HOMEDIR"/crosstemp-$1
mkdir -p "$HOMEDIR"/crosstemp-$1
cd "$HOMEDIR"/crosstemp-$1
../gcc-$1/configure \
--target=m68k-$VENDOR-elf \
--disable-nls \
--enable-languages=$LANGUAGES \
--enable-lto \
--prefix=$INSTALL_PREFIX-crosstemp-$1 \
--disable-libssp \
--enable-softfloat \
--disable-libstdcxx-pch \
--disable-clocale \
--disable-libstdcxx-threads \
--disable-libstdcxx-filesystem-ts \
--disable-libquadmath \
--enable-cxx-flags='-O2 -fomit-frame-pointer -fno-threadsafe-statics -fno-exceptions ${NO_RTTI} -fleading-underscore -fno-plt -fno-pic' \
LDFLAGS=$STATIC \
CFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer -fleading-underscore -fno-plt -fno-pic $MIN_RAM_CFLAGS" \
CXXFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer -fleading-underscore -fno-plt -fno-pic -fno-threadsafe-statics -fno-exceptions ${NO_RTTI} $MIN_RAM_CFLAGS" \
LDFLAGS_FOR_TARGET="--emit-relocs -Ttext=0" &> gcc_cross_config.log
$NICE make all-gcc $JMULT &> gcc_cross_compile.log
make install-gcc $JMULT &> gcc_cross_install.log
# And then export the path because libgcc will need it
export PATH=$PATH:$INSTALL_PREFIX-crosstemp-$1/bin:${INSTALL_PREFIX}/bin
#export PATH=$INSTALL_PREFIX-crosstemp-$1/bin:$PATH
fi
echo "Building the actual cross binutils..."
mkdir -p "$HOMEDIR"/build-binutils-$1
cd "$HOMEDIR"/build-binutils-$1
../binutils-$BINUTILS/configure $HOST $BUILD --target=m68k-$VENDOR-elf --disable-multilib --disable-nls --enable-lto --prefix=$INSTALL_PREFIX LDFLAGS=$STATIC &> binutils_config.log
make $JMULT &> binutils_build.log
make install $JMULT &> binutils_install.log
${HOST_PREFIX}strip $INSTALL_PREFIX/bin/*$VENDOR* || true &> binutils_install.log
${HOST_PREFIX}strip $INSTALL_PREFIX/m68k-$VENDOR-elf/bin/* &> binutils_install.log
gzip -f -9 $INSTALL_PREFIX/share/man/*/*.1
fi
# home directory
cd "$HOMEDIR"
# __ _ ___ ___
# / _` |/ __/ __|
# | (_| | (_| (__
# \__, |\___\___|
# __/ |
# |___/
#
# gcc build dir
# Configure, build and install gcc without any libs for now
#
# Export flags for target compiler as well as pass them on configuration time.
# Who knows, maybe one of the two will actually work!
# TODO: This should build all target for all 000/020/040/060 and fpu/softfpu combos but it doesn't.
#export MULTILIB_OPTIONS="m68000/m68020/m68040/m68060 msoft-float"
if [ "$GLOBAL_OVERRIDE" == "A" ] || [ "$GLOBAL_OVERRIDE" == "a" ]; then
echo "Configuring, builing and installing gcc (without libs)"
REPLY=Y
else
read -p "Configure, build and install gcc (without libs)?" -n 1 -r
echo
fi
if [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; then
# For gcc 8.x and MinGW, patch some nuisances in the source
if [ "$machine" == "MinGw" ]; then
if [ "$1" == "8.1.0" ] || [ "$1" == "8.2.0" ] || [ "$1" == "8.3.0" ] || [ "$1" == "9.1.0" ] || [ "$1" == "9.2.0" ] || [ "$1" == "9.3.0" ]; then
# No MinGW install I have knows what ENOTSUP is.
# Random internet suggestions said to replace this with ENOSYS so here we go
$SED -i -e "s/ENOTSUP/ENOSYS/gI" $HOMEDIR/gcc-$1/libiberty/simple-object-elf.c
# The following two defines appear on most windows.h versions I have here
# but not on MinGW. Who knows
$SED -i '1s;^;#define COMMON_LVB_REVERSE_VIDEO 0x4000 \/\/ DBCS: Reverse fore\/back ground attribute.\n#define COMMON_LVB_UNDERSCORE 0x8000 \/\/ DBCS: Underscore.\n;' $HOMEDIR/gcc-$1/gcc/pretty-print.c
fi
fi
# When building for a different architecture than the one we are compiling for, we need to
# build an extra version of gcc in order to compile libgcc and friends. Makes sense in hindsight
if [ "$CROSS_COMPILING" != "0" ]; then
#echo "Building temp local gcc..."
rm -rf "$HOMEDIR"/crosstemp-$1
mkdir -p "$HOMEDIR"/crosstemp-$1
cd "$HOMEDIR"/crosstemp-$1
../gcc-$1/configure \
--target=m68k-$VENDOR-elf \
--disable-nls \
--enable-languages=$LANGUAGES \
--enable-lto \
--prefix=$INSTALL_PREFIX-crosstemp-$1 \
--disable-libssp \
--enable-softfloat \
--disable-libstdcxx-pch \
--disable-clocale \
--disable-libstdcxx-threads \
--disable-libstdcxx-filesystem-ts \
--disable-libquadmath \
--enable-cxx-flags='-O2 -fomit-frame-pointer -fno-threadsafe-statics -fno-exceptions ${NO_RTTI} -fleading-underscore -fno-plt -fno-pic' \
LDFLAGS=$STATIC \
CFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer -fleading-underscore -fno-plt -fno-pic $MIN_RAM_CFLAGS" \
CXXFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer -fleading-underscore -fno-plt -fno-pic -fno-threadsafe-statics -fno-exceptions ${NO_RTTI} $MIN_RAM_CFLAGS" \
LDFLAGS_FOR_TARGET="--emit-relocs -Ttext=0" &> gcc_cross_config.log
$NICE make all-gcc $JMULT &> gcc_cross_compile.log
make install-gcc $JMULT &> gcc_cross_install.log
# And then export the path because libgcc will need it
export PATH=$INSTALL_PREFIX-crosstemp-$1/bin:${INSTALL_PREFIX}/bin:$PATH
else
export PATH=${INSTALL_PREFIX}/bin:$PATH
fi
echo "Building the actual cross gcc..."
mkdir -p "$HOMEDIR"/build-gcc-$1
cd "$HOMEDIR"/build-gcc-$1
../gcc-$1/configure \
$HOST \
$BUILD \
--target=m68k-$VENDOR-elf \
--disable-nls \
--enable-languages=$LANGUAGES \
--enable-lto \
--prefix=$INSTALL_PREFIX \
--disable-libssp \
--enable-softfloat \
--disable-libstdcxx-pch \
--disable-clocale \
--disable-libstdcxx-threads \
--disable-libstdcxx-filesystem-ts \
--disable-libquadmath \
--enable-cxx-flags='-O2 -fomit-frame-pointer -fno-threadsafe-statics -fno-exceptions ${NO_RTTI} -fleading-underscore -fno-plt -fno-pic' \
LDFLAGS=$STATIC \
CFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer -fleading-underscore -fno-plt -fno-pic $MIN_RAM_CFLAGS" \
CXXFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer -fleading-underscore -fno-plt -fno-pic -fno-threadsafe-statics -fno-exceptions ${NO_RTTI} $MIN_RAM_CFLAGS" \
LDFLAGS_FOR_TARGET="--emit-relocs -Ttext=0" &> gcc_configure.log
$NICE make all-gcc $JMULT &> gcc_build.log
make install-gcc $JMULT &> gcc_install.log
# In some linux distros (linux mint for example) it was observed
# that make install-gcc didn't set the read permission for users
# so gcc couldn't work properly. No idea how to fix this propery
# which means - botch time!
if [ "$machine" != "Cygwin" ] && [ "$machine" != "Mac" ]; then
chmod 755 -R $INSTALL_PREFIX/m68k-$VENDOR-elf/
chmod 755 -R $INSTALL_PREFIX/libexec/gcc/m68k-$VENDOR-elf/
chmod 755 -R $INSTALL_PREFIX/lib/gcc/m68k-$VENDOR-elf/
fi
fi
# TODO:
# Other candidates to pass to configure:
# This probably won't be used:
# --disable-multilib \
# Dunno, does anyone NEED unicode for building ST applications?
# --disable-wchar_t \
# This ditches all coldfire lib building stuff:
# --with-arch=m68k
# _ _ _
# | (_) |
# | |_| |__ __ _ ___ ___
# | | | '_ \ / _` |/ __/ __|
# | | | |_) | (_| | (_| (__
# |_|_|_.__/ \__, |\___\___|
# __/ |
# |___/
#INSTALL_PREFIX
# Build/install libgcc
#
cd "$HOMEDIR"/build-gcc-$1
if [ "$GLOBAL_OVERRIDE" == "A" ] || [ "$GLOBAL_OVERRIDE" == "a" ]; then
echo "Building and installing libgcc"
REPLY=Y
else
read -p "Build and install libgcc?" -n 1 -r
echo
fi
if [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; then
if [ "$CROSS_COMPILING" != "0" ]; then
cd "$HOMEDIR"/crosstemp-$1
make all-target-libgcc $JMULT &> libgcc_build.log
$SUDO make install-target-libgcc $JMULT &> libgcc_build.log
fi
cd "$HOMEDIR"/build-gcc-$1
make all-target-libgcc $JMULT &> libgcc_build.log
$SUDO make install-target-libgcc $JMULT &> libgcc_build.log
# Some extra permissions
if [ "$machine" != "Cygwin" ] && [ "$machine" != "Mac" ]; then
chmod 755 -R $INSTALL_PREFIX/libexec/
fi
fi
# _ _ _
# | (_) |
# _ __ _____ _| |_| |__
# | '_ \ / _ \ \ /\ / / | | '_ \
# | | | | __/\ V V /| | | |_) |
# |_| |_|\___| \_/\_/ |_|_|_.__/
#
# Newlib
# This will require building a second version of gcc so we can tell it to use Newlib instead of libgcc.
# Who knows, maybe this is not super required. But install guides on the internets seem to suggest doing this.
#
if [ "$BUILD_NEWLIB" != "0" ]; then
if [ "$GLOBAL_OVERRIDE" == "A" ] || [ "$GLOBAL_OVERRIDE" == "a" ]; then
echo "Building and installing newlib (and custom gcc)"
REPLY=Y
else
read -p "Build and install newlib (and custom gcc)?" -n 1 -r
echo
fi
if [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; then
mkdir -p "$HOMEDIR/build-newlib-$1/build"
cd "$HOMEDIR/build-newlib-$1/build"
CC=m68k-$VENDOR-elf-gcc $HOMEDIR/newlib-4.1.0-$1/newlib/configure $HOST $BUILD --target=m68k-$VENDOR-elf --build=m68k-$VENDOR-elf --host=m68k-$VENDOR-elf --prefix=${INSTALL_PREFIX}-newlib &> newlib_config.log
$NICE make $JMULT &> newlib_build.log
make install &> newlib_install.log
# Re-configure and build gcc with "--with-newlib". Exciting.
# TODO: this is copypasta from gcc configure above. Probably define it once and use it in both places as it will get out of sync...
mkdir -p "$HOMEDIR"/build-gcc-newlib-$1
cd "$HOMEDIR"/build-gcc-newlib-$1
../gcc-$1/configure \
--with-newlib \
$HOST \
$BUILD \
--target=m68k-$VENDORnewlib-elf \
--disable-nls \
--enable-languages=$LANGUAGES \
--enable-lto \
--prefix=${INSTALL_PREFIX}-newlib \
--disable-libssp \
--enable-softfloat \
--disable-libstdcxx-pch \
--disable-clocale \
--disable-libstdcxx-threads \
--disable-libstdcxx-filesystem-ts \
--disable-libquadmath \
--enable-cxx-flags='-O2 -fomit-frame-pointer -fno-threadsafe-statics -fno-exceptions ${NO_RTTI} -fleading-underscore -fno-plt -fno-pic' \
LDFLAGS=$STATIC \
CFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer -fleading-underscore -fno-plt -fno-pic $MIN_RAM_CFLAGS" \
CXXFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer -fleading-underscore -fno-plt -fno-pic -fno-threadsafe-statics -fno-exceptions ${NO_RTTI} $MIN_RAM_CFLAGS" \
LDFLAGS_FOR_TARGET="--emit-relocs -Ttext=0" &> gcc_newlib_configure
$NICE make all-gcc $JMULT &> gcc_newlib_build.log
make install-gcc $JMULT &> gcc_newlib_install.log
fi
fi
# __ __ _ _ _ _______ _ _ _
# | \/ (_) \ | |__ __| (_) |
# | \ / |_| \| | | | | |_| |__
# | |\/| | | . ` | | | | | | '_ \
# | | | | | |\ | | | | | | |_) |
# |_| |_|_|_| \_| |_| |_|_|_.__/
#
# Mintlib
#
if [ "$BUILD_MINTLIB" != "0" ]; then
# Patch mintlib at the source level
cd "$HOMEDIR"
if [ "$GLOBAL_OVERRIDE" == "A" ] || [ "$GLOBAL_OVERRIDE" == "a" ]; then
echo "Source patching and building mintlib"
REPLY=Y
else
read -p "Source patch and build mintlib?" -n 1 -r
echo
fi
if [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; then
MINTLIBDIR="$HOMEDIR"/mintlib-bigbrownbuild-$1
# Create missing targets
cp -R $MINTLIBDIR/lib/ $MINTLIBDIR/lib_mshort
cp -R $MINTLIBDIR/lib020/ $MINTLIBDIR/lib020_soft
cp -R $MINTLIBDIR/lib020/ $MINTLIBDIR/lib020-60
cp -R $MINTLIBDIR/lib020/ $MINTLIBDIR/lib020-60_soft
cp -R $MINTLIBDIR/lib020/ $MINTLIBDIR/lib040
cp -R $MINTLIBDIR/lib020/ $MINTLIBDIR/lib060
# Change build rules for targets
$SED -i -e "s/instdir =/instdir = m68020_Mshort/gI" \
-e "s/cflags =/cflags = -m68000 -mshort/gI " \
-e "s/subdir = lib/subdir = lib_mshort/gI" $MINTLIBDIR/lib_mshort/Makefile
$SED -i -e "s/instdir = m68020-60/instdir = m68020/gI" \
-e "s/cflags = -m68020-60/cflags = -m68020/gI " \
-e "s/subdir = lib020/subdir = lib020/gI" $MINTLIBDIR/lib020/Makefile
$SED -i -e "s/instdir = m68020-60/instdir = m68020-20_soft/gI" \
-e "s/cflags = -m68020-60/cflags = -m68020 -msoft-float/gI " \
-e "s/subdir = lib020/subdir = lib020_soft/gI" $MINTLIBDIR/lib020_soft/Makefile
$SED -i -e "s/instdir = m68020-60/instdir = m68020-60_soft/gI" \
-e "s/cflags = -m68020-60/cflags = -m68020-60 -msoft-float/gI " \
-e "s/subdir = lib020/subdir = lib020-60_soft/gI" $MINTLIBDIR/lib020-60_soft/Makefile
$SED -i -e "s/instdir = m68020-60/instdir = m68040/gI" \
-e "s/cflags = -m68020-60/cflags = -m68040/gI " \
-e "s/subdir = lib020/subdir = lib040/gI" $MINTLIBDIR/lib040/Makefile
$SED -i -e "s/instdir = m68020-60/instdir = m68060/gI" \
-e "s/cflags = -m68020-60/cflags = -m68060/gI " \
-e "s/subdir = lib020/subdir = lib020_soft/gI" $MINTLIBDIR/lib060/Makefile
$SED -i -e "s/subdir = lib020/subdir = lib020-60/gI" $MINTLIBDIR/lib020-60/Makefile
# Add targets to main makefile
$SED -i -e "s/ifeq (\$(WITH_020_LIB), yes)/ifeq (\$(WITH_020SOFT_LIB), yes)\n SUBDIRS += lib020_soft\n DIST_SUBDIRS += lib020_soft\nendif\n\n\
ifeq (\$(WITH_000MSHORT_LIB), yes)\n SUBDIRS += lib_mshort\n DIST_SUBDIRS += lib_mshort\nendif\n\n\
ifeq (\$(WITH_020_060_LIB), yes)\n SUBDIRS += lib020-60\n DIST_SUBDIRS += lib020-60\nendif\n\n\
ifeq (\$(WITH_020_060SOFT_LIB), yes)\n SUBDIRS += lib020-60_soft\n DIST_SUBDIRS += lib020-60_soft\nendif\n\n\
ifeq (\$(WITH_040_LIB), yes)\n SUBDIRS += lib040\n DIST_SUBDIRS += lib040\nendif\n\n\
ifeq (\$(WITH_060_LIB), yes)\n SUBDIRS += lib060\n DIST_SUBDIRS += lib060\nendif\n\n\
ifeq (\$(WITH_020_LIB), yes)/gI" $MINTLIBDIR/Makefile
# It's probably not possible to build mintlib with mshort....
$SED -i -e "s/# Uncomment this out if you want extra libraries that are optimized/# Uncomment this out if you want extra libraries that are optimized\n# for m68020 processors.\nWITH_020SOFT_LIB=yes\nWITH_000MSHORT_LIB=no\nWITH_020_060_LIB=yes\nWITH_020_060SOFT_LIB=yes\nWITH_040_LIB=yes\nWITH_060_LIB=yes\n\n# Uncomment this out if you want extra libraries/gI" $MINTLIBDIR/configvars
# Force 68000 mode in the default lib since our gcc defaults to 68020
$SED -i -e "s/cflags = /cflags = -m68000/gI " $MINTLIBDIR/lib/Makefile
# When building using cross-gcc-4.6.4 the compilers ICE with coldfire targets at
# stdio/printf_fp.c. So let's disable this...
if [ "$SKIP_464_CF" == "Y" ] || [ "$SKIP_464_CF" == "y" ]; then
$SED -i -e "s/WITH_V4E_LIB/#WITH_V4E_LIB #disabled since we get Internal Compiler Error :(/gI" $MINTLIBDIR/configvars
fi
if [ "$1" == "TRUNK" ] || [ "$1" == "10.1.0" ] || [ "$1" == "10.2.0" ] || [ "$1" == "10.3.0" ] || [ "$1" == "11.1.0" ] || [ "$1" == "11.2.0" ] || [ "$1" == "12.1.0" ] || [ "$1" == "12.2.0" ] || [ "$1" == "13.1.0" ] || [ "$1" == "13.2.0" ] || [ "$1" == "14.1.0" ]; then
# h_errno is defined in 2 sources of MiNTlib and up till gcc 9 it was
# fine. But not anymore O_o
$SED -i -e 's/int h_errno/extern int h_errno/gI' $MINTLIBDIR/socket/res_query.c
fi
if [ "$machine" == "MinGw" ]; then
# Because MinGW/Msys has mixed forward/backward slashs in paths, convert
# installdir=`$(CC) --print-search-dirs | awk '{ print $$2; exit; }'`; \
# to:
# installdir=`$(CC) --print-search-dirs | awk '{ print $$2; exit; }' | sed -e 's/\\\\/\//gI'`; \
# .....
# I need a drink...
$SED -i -e $'s/2; exit; }\'`/2; exit; }\' | sed -e \'s\/\\\\\\\\\\\\\\\\\/\\\\\/\/gi\' `/gI' $MINTLIBDIR/buildrules
fi
# Set C standard to prevent shit from blowing up
$SED -i -e "s/-O2 -fomit-frame-pointer/-O2 -fomit-frame-pointer -std=gnu89/gI" $MINTLIBDIR/configvars
# Set cross compiler
$SED -i -e "s/AM_DEFAULT_VERBOSITY = 1/AM_DEFAULT_VERBOSITY = 0/gI" $MINTLIBDIR/configvars
$SED -i -e "s/#CROSS=yes/CROSS=yes/gI" $MINTLIBDIR/configvars
$SED -i -e "s|prefix=/usr/m68k-atari-mint|prefix=${INSTALL_PREFIX}/m68k-$VENDOR-elf|gI" $MINTLIBDIR/configvars
$SED -i -e "s/m68k-atari-mint/m68k-$VENDOR-elf/gI" $MINTLIBDIR/configvars
# Convert syntax into new gcc/gas format
$SED -i -e "s/|/\/\//gI" $MINTLIBDIR/startup/crt0.S
$SED -i -e "s/a6/%a6/gI" $MINTLIBDIR/startup/crt0.S
$SED -i -e "s/a0/%a0/gI" $MINTLIBDIR/startup/crt0.S
$SED -i -e "s/d0/%d0/gI" $MINTLIBDIR/startup/crt0.S
$SED -i -e "s/sp/%sp/gI" $MINTLIBDIR/startup/crt0.S
$SED -i -e "s/sp/%sp/gI" $MINTLIBDIR/dirent/closedir.c
$SED -i -e "s/,sp@/,%%sp@/gI" $MINTLIBDIR/include/mint/mintbind.h
$SED -i -e "s/,sp\"/,%%sp\"/gI" $MINTLIBDIR/include/mint/mintbind.h
$SED -i -e "s/,sp \"/,%%sp\"/gI" $MINTLIBDIR/include/mint/mintbind.h
$SED -i -e "s/\tsp/\t%%sp/gI" $MINTLIBDIR/include/mint/mintbind.h
$SED -i -e "s/,sp@/,%%sp@/gI" $MINTLIBDIR/include/mint/osbind.h
$SED -i -e "s/,sp\"/,%%sp\"/gI" $MINTLIBDIR/include/mint/osbind.h
$SED -i -e "s/,sp\\\\n/,%%sp\\\\n/gI" $MINTLIBDIR/include/mint/osbind.h
$SED -i -e "s/,sp \"/,%%sp\"/gI" $MINTLIBDIR/include/mint/osbind.h
$SED -i -e "s/\tsp/\t%%sp/gI" $MINTLIBDIR/include/mint/osbind.h
$SED -i -e "s/sp@-/%sp@-/gI" $MINTLIBDIR/mintlib/checkcpu.S
$SED -i -e "s/,sp/,%sp/gI" $MINTLIBDIR/mintlib/checkcpu.S
$SED -i -e "s/\tsp/\t%%sp/gI" $MINTLIBDIR/include/mint/osbind.h
$SED -i -e "s/sp/%sp/gI" $MINTLIBDIR/mintlib/frexp.S
$SED -i -e "s/a0/%a0/gI" $MINTLIBDIR/mintlib/frexp.S
$SED -i -e "s/a1/%a1/gI" $MINTLIBDIR/mintlib/frexp.S
$SED -i -e "s/d4/%d4/gI" $MINTLIBDIR/mintlib/frexp.S
$SED -i -e "s/d5/%d5/gI" $MINTLIBDIR/mintlib/frexp.S
$SED -i -e "s/d0/%d0/gI" $MINTLIBDIR/mintlib/frexp.S
$SED -i -e "s/d1/%d1/gI" $MINTLIBDIR/mintlib/frexp.S
$SED -i -e "s/d2/%d2/gI" $MINTLIBDIR/mintlib/frexp.S
$SED -i -e "s/d3/%d3/gI" $MINTLIBDIR/mintlib/frexp.S
$SED -i -e "s/d7/%d7/gI" $MINTLIBDIR/mintlib/frexp.S
$SED -i -e "s/d6/%d6/gI" $MINTLIBDIR/mintlib/frexp.S
$SED -i -e "s/sp/%sp/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/a0/%a0/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/5%a0/5a0/gI" $MINTLIBDIR/mintlib/getcookie.S #lolol
$SED -i -e "s/a1/%a1/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/a2/%a2/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/a3/%a3/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/d4/%d4/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/d5/%d5/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/d0/%d0/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/d1/%d1/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/d2/%d2/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/d3/%d3/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/d7/%d7/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/d6/%d6/gI" $MINTLIBDIR/mintlib/getcookie.S
$SED -i -e "s/sp/%sp/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/a0/%a0/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/a1/%a1/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/a2/%a2/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/a3/%a3/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/d4/%d4/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/d5/%d5/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/d0/%d0/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/d1/%d1/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/d2/%d2/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/d3/%d3/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/d7/%d7/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/d6/%d6/gI" $MINTLIBDIR/mintlib/getsysvar.S
$SED -i -e "s/sp/%sp/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/a0/%a0/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/a1/%a1/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/a2/%a2/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/a3/%a3/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/d4/%d4/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/d5/%d5/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/d0/%d0/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/d1/%d1/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/d2/%d2/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/d3/%d3/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/d7/%d7/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/d6/%d6/gI" $MINTLIBDIR/mintlib/ldexp.S
$SED -i -e "s/sp/%sp/gI" $MINTLIBDIR/mintlib/libc_exit.S
$SED -i -e "s/a0/%a0/gI" $MINTLIBDIR/mintlib/libc_exit.S
$SED -i -e "s/a1/%a1/gI" $MINTLIBDIR/mintlib/libc_exit.S
$SED -i -e "s/a2/%a2/gI" $MINTLIBDIR/mintlib/libc_exit.S
$SED -i -e "s/a3/%a3/gI" $MINTLIBDIR/mintlib/libc_exit.S
$SED -i -e "s/a4/%a4/gI" $MINTLIBDIR/mintlib/libc_exit.S
$SED -i -e "s/a5/%a5/gI" $MINTLIBDIR/mintlib/libc_exit.S
$SED -i -e "s/a6/%a6/gI" $MINTLIBDIR/mintlib/libc_exit.S
$SED -i -e "s/d4/%d4/gI" $MINTLIBDIR/mintlib/libc_exit.S
$SED -i -e "s/d5/%d5/gI" $MINTLIBDIR/mintlib/libc_exit.S
$SED -i -e "s/d0/%d0/gI" $MINTLIBDIR/mintlib/libc_exit.S