-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_toolchain.sh
executable file
·734 lines (713 loc) · 19.3 KB
/
build_toolchain.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
#!/bin/sh
# Assumptions: your user id is added to sudoers list as ALL for ex:
# myuserid ALL=(ALL) NOPASSWD: ALL
#
# All dev supporting tools are installed, flex, bison, automake, autoconf, make, gnu toolchains
#
# Source code with all relevant dirs un-tarred/un-gzipped
#
# This script runs inside that root directory where the source code/relevant dirs are located
# minimal error checking so far
#
# Issue(s):
# 1. Zlib is built again after post gcc build (why?)
# 2. Expat is built for host - are they part of linkage purposes ???
# 3.
#
# To do:
# If one step fails then abort immediately instead of carrying on forward to the next step <- DONE!
# When post compile of gcc pass - continue building the other libs with the newly built gcc <- DONE!
# Make it more cleaner
#
# How to run it:
# chmod u+x build_toolchain.sh
# ./build_toolchain.sh > build_toolchain.log 2>&1
# Verify:
# grep ^\>\> build_toolchain.log
# All completion messages indicating success failure will be shown...
#
export BTURL='https://support.codesourcery.com/GNUToolchain/'
export PKGCONF='Samsung Sourcery G++ 4.4-157'
export HOST=i686-pc-linux-gnu
export BUILD=$HOST
export TARGET=arm-samsung-nucleuseabi
export PREFIX=/opt/samwave/arm
export INSTALLPREFIX=$PREFIX/install
export SYSROOT=$PREFIX/sysroot
export BUILDSYSROOT=$SYSROOT/build
export HOSTPREFIX=$PREFIX/host
#
MAKE_PARAMS=-j4
PWDDIR=$PWD
CODESOURCERY_BUILD=build_toolchain.log
#
TEMP_BINUTILS_DIR=temp-binutils-build
TEMP_NEWLIB_DIR=temp-newlib-build
TEMP_GCC_DIR_PRE=temp-gcc-build-pre
TEMP_GCC_DIR_POST=temp-gcc-build-post
POST_GCC_OK=0
#
ZLIB_DIR=zlib-1.2.3
GMP_DIR=gmp-stable
MPFR_DIR=mpfr-stable
PPL_DIR=ppl-0.10.2
CLOOG_DIR=cloog-0.15
BINUTILS_DIR=binutils-stable
GCC_DIR=gcc-4.4
NEWLIB_DIR=newlib-stable
EXPAT_DIR=expat-mirror
GDB_DIR=gdb-stable
#
# This was borrowed from http://stackoverflow.com/questions/1245295/building-arm-gnu-cross-compiler
# Written by Martin Decky
check_error(){
if [ "$1" -ne "0" ]; then
echo
echo "Script failed: $2"
exit
fi
}
#
usage(){
cat << EOF
usage: $0 options
This script builds the bada SDK 1.0.0 toolchain
OPTIONS:
-h Show this message
-c Perform cleanup of all builds
-a Build ALL
-p Build preliminary libs (zlib, gmp, mpfr, ppl, cloog)
-b Build binutils
-f Build gcc (PRE) - bootstrap compiler
-n Build newlib
-l Build gcc (POST) - native compiler
-z Build zlib (POST)
-x Build expat (POST)
-d Build gdb (POST)
Note(s):
When -a is used, it builds preliminary, binutils, gcc (PRE), newlib and gcc (POST), expat and gdb in that order
BUGS:
Contact:
rzr, x29a or t0mm13b via #bada @ irc.freenode.net or at
http://github.com/t0mm13b/linux-samsung-gcc and leave a message for the maintainers
EOF
}
build_zlib(){
cd $ZLIB_DIR
sh configure --prefix=$HOSTPREFIX
if [ $? -eq 0 ]; then
echo ">> $ZLIB_DIR configure successful <<"
echo ">> Doing make on $ZLIB_DIR <<"
make $MAKE_PARAMS
if [ $? -eq 0 ]; then
echo ">> $ZLIB_DIR make successful <<"
sudo make install
if [ $? -eq 0 ]; then
echo ">> $ZLIB_DIR make install successful <<"
return 0
else
echo ">> $ZLIB_DIR make install Failed <<"
fi
else
echo ">> $ZLIB_DIR make Failed <<"
fi
else
echo ">> $ZLIB_DIR configure Failed <<"
fi
return -1
}
build_gmp(){
cd $GMP_DIR
sh configure --build=$BUILD --target=$HOST --prefix=$HOSTPREFIX --disable-shared --host=$HOST --enable-cxx --disable-nls
if [ $? -eq 0 ]; then
echo ">> $GMP_DIR configure successful <<"
echo ">> Doing make on $GMP_DIR <<"
make $MAKE_PARAMS
if [ $? -eq 0 ]; then
echo ">> $GMP_DIR make successful <<"
sudo make install
if [ $? -eq 0 ]; then
echo ">> $GMP_DIR make install successful <<"
sudo make check
if [ $? -eq 0 ]; then
echo ">> $GMP_DIR make check successful <<"
return 0
else
echo ">> $GMP_DIR make check Failed <<"
fi
else
echo ">> $GMP_DIR make install Failed <<"
fi
else
echo ">> $GMP_DIR make Failed <<"
fi
else
echo ">> $GMP_DIR configure Failed <<"
fi
return -1
}
build_mpfr(){
cd $MPFR_DIR
sh configure --build=$BUILD --target=$TARGET --prefix=$HOSTPREFIX --disable-shared --host=$HOST --disable-nls --with-gmp=$HOSTPREFIX
if [ $? -eq 0 ]; then
echo ">> $MPFR_DIR configure successful <<"
echo ">> Doing make on $MPFR_DIR <<"
make $MAKE_PARAMS
if [ $? -eq 0 ]; then
echo ">> $MPFR_DIR make successful <<"
sudo make install
if [ $? -eq 0 ]; then
echo ">> $MPFR_DIR make install successful <<"
sudo make check
if [ $? -eq 0 ]; then
echo ">> $MPFR_DIR make check successful <<"
return 0
else
echo ">> $MPFR_DIR make check Failed <<"
fi
else
echo ">> $MPFR_DIR make install Failed <<"
fi
else
echo ">> $MPFR_DIR make Failed <<"
fi
else
echo ">> $MPFR_DIR configure Failed <<"
fi
return -1
}
build_ppl(){
cd $PPL_DIR
sh configure --build=$BUILD --target=$TARGET --prefix=$HOSTPREFIX --disable-shared --host=$HOST --disable-nls --with-libgmp-prefix=$HOSTPREFIX
if [ $? -eq 0 ]; then
echo ">> $PPL_DIR configure successful <<"
echo ">> Doing make on $PPL_DIR <<"
make $MAKE_PARAMS
if [ $? -eq 0 ]; then
echo ">> $PPL_DIR make successful <<"
sudo make install
if [ $? -eq 0 ]; then
echo ">> $PPL_DIR make install successful <<"
return 0
else
echo ">> $PPL_DIR make install Failed <<"
fi
else
echo ">> $PPL_DIR make Failed <<"
fi
else
echo ">> $PPL_DIR configure Failed <<"
fi
return -1
}
build_cloog(){
cd $CLOOG_DIR
sh configure --build=$BUILD --target=$TARGET --prefix=$HOSTPREFIX --disable-shared --host=$HOST --disable-nls --with-ppl=$HOSTPREFIX --with-gmp=$HOSTPREFIX
if [ $? -eq 0 ]; then
echo ">> $CLOOG_DIR configure successful <<"
echo ">> Doing make on $CLOOG_DIR <<"
make $MAKE_PARAMS
if [ $? -eq 0 ]; then
echo ">> $CLOOG_DIR make successful <<"
sudo make install
if [ $? -eq 0 ]; then
echo ">> $CLOOG_DIR make install successful <<"
sudo make check
if [ $? -eq 0 ]; then
echo ">> $CLOOG_DIR make check successful <<"
return 0
else
echo ">> $CLOOG_DIR make check Failed <<"
fi
else
echo ">> $CLOOG_DIR make install Failed <<"
fi
else
echo ">> $CLOOG_DIR make Failed <<"
fi
else
echo ">> $CLOOG_DIR configure Failed <<"
fi
return -1
}
build_preliminary(){
pushd $PWDDIR
build_zlib
check_error $? ">> Preliminary Build: zlib failed <<"
popd $PWDDIR
#
pushd $PWDDIR
build_gmp
check_error $? ">> Preliminary Build: gmp failed <<"
popd $PWDDIR
#
pushd $PWDDIR
build_mpfr
check_error $? ">> Preliminary Build: mpfr failed <<"
popd $PWDDIR
#
pushd $PWDDIR
build_ppl
check_error $? ">> Preliminary Build: ppl failed <<"
popd $PWDDIR
#
pushd $PWDDIR
build_cloog
check_error $? ">> Preliminary Build: cloog failed <<"
popd $PWDDIR
#
return 0
}
build_binutils(){
mkdir $TEMP_BINUTILS_DIR
cd $TEMP_BINUTILS_DIR
sh ../$BINUTILS_DIR/configure --build=$HOST \
--target=$TARGET \
--prefix=$PREFIX \
--host=$HOST \
'--with-pkgversion=$PKGCONF' \
--with-bugurl=$BTURL \
--disable-nls \
--disable-poison-system-directories
if [ $? -eq 0 ]; then
echo ">> $BINUTILS_DIR configure successful <<"
echo ">> Doing make on $BINUTILS_DIR <<"
make $MAKE_PARAMS
if [ $? -eq 0 ]; then
echo ">> $BINUTILS_DIR make successful <<"
sudo make install
if [ $? -eq 0 ]; then
echo ">> $BINUTILS_DIR make install successful <<"
sudo mkdir -p $HOSTPREFIX/usr/lib && sudo mkdir -p $HOSTPREFIX/usr/include
[ $? -eq 0 ] && echo ">> $HOSTPREFIX/usr/lib + $HOSTPREFIX/usr/include successful <<" || echo ">> $HOSTPREFIX/usr/lib + $HOSTPREFIX/usr/include Failed <<"
sudo cp libiberty/libiberty.a $HOSTPREFIX/usr/lib
[ $? -eq 0 ] && echo ">> $HOSTPREFIX/lib/libiberty.a copied successful <<" || echo ">> $HOSTPREFIX/lib/libiberty.a copy Failed <<"
sudo cp bfd/.libs/libbfd.a $HOSTPREFIX/usr/lib
[ $? -eq 0 ] && echo ">> $HOSTPREFIX/lib/libbfd.a copied successful <<" || echo ">> $HOSTPREFIX/lib/libbfd.a copy Failed <<"
sudo cp bfd/bfd.h $HOSTPREFIX/usr/include
[ $? -eq 0 ] && echo ">> $HOSTPREFIX/include/bfd.h copied successful <<" || echo ">> $HOSTPREFIX/include/bfd.h copy Failed <<"
sudo cp ../$BINUTILS_DIR/bfd/elf-bfd.h $HOSTPREFIX/usr/include
[ $? -eq 0 ] && echo ">> $HOSTPREFIX/include/elf-bfd.h copied successful <<" || echo ">> $HOSTPREFIX/include/elf-bfd.h copy Failed <<"
sudo cp opcodes/.libs/libopcodes.a $HOSTPREFIX/usr/lib
[ $? -eq 0 ] && echo ">> $HOST/lib/libopcodes.a copied successful <<" || echo ">> $HOST/lib/libopcodes.a copy Failed <<"
return 0
else
echo ">> $BINUTILS_DIR make install Failed <<"
fi
else
echo ">> $BINUTILS_DIR make Failed <<"
fi
else
echo ">> $BINUTILS_DIR configure Failed <<"
fi
return -1
}
build_gcc_pre(){
mkdir $TEMP_GCC_DIR_PRE
cd $TEMP_GCC_DIR_PRE
export AR_FOR_TARGET=$TARGET-ar
export NM_FOR_TARGET=$TARGET-nm
export OBJDUMP_FOR_TARGET=$TARGET-objdump
export STRIP_FOR_TARGET=$TARGET-strip
sh ../$GCC_DIR/configure --build=$HOST \
--host=$HOST \
--target=$TARGET \
--enable-threads \
--disable-libmudflap \
--disable-libssp \
--disable-libstdcxx-pch \
--enable-extra-sgxx-multilibs \
--disable-multilib \
--with-mode=thumb \
--with-cpu=cortex-a8 \
--with-float=hard \
--with-gnu-as \
--with-gnu-ld '--with-specs=%{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' \
--enable-languages=c,c++ \
--enable-shared \
--disable-lto \
--with-newlib \
'--with-pkgversion=$PKGCONF' \
--with-bugurl=$BTURL \
--disable-nls \
--prefix=$PREFIX \
--disable-shared \
--disable-threads \
--disable-libssp \
--disable-libgomp \
--without-headers \
--with-newlib \
--disable-decimal-float \
--disable-libffi \
--enable-languages=c \
--with-gmp=$HOSTPREFIX \
--with-mpfr=$HOSTPREFIX \
--with-ppl=$HOSTPREFIX \
'--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
--with-cloog=$HOSTPREFIX \
--disable-libgomp \
--disable-poison-system-directories \
--with-build-time-tools=$PREFIX/$TARGET/bin
if [ $? -eq 0 ]; then
echo ">> $GCC_DIR (PRE) configure successful <<"
echo ">> Doing make on $GCC_DIR <<"
make $MAKE_PARAMS #LDFLAGS_FOR_TARGET=--sysroot=$PREFIX CPPFLAGS_FOR_TARGET=--sysroot=$PREFIX build_tooldir=$PREFIX
if [ $? -eq 0 ]; then
echo ">> $GCC_DIR (PRE) make successful <<"
sudo make install
if [ $? -eq 0 ]; then
echo ">> $GCC_DIR (PRE) make install successful <<"
return 0
fi
else
echo ">> $GCC_DIR (PRE) make Failed <<"
fi
else
echo ">> $GCC_DIR (PRE) configure Failed <<"
fi
#
return -1
}
build_newlib(){
mkdir $TEMP_NEWLIB_DIR
cd $TEMP_NEWLIB_DIR
sh ../$NEWLIB_DIR/configure --build=$BUILD \
--target=$TARGET \
--prefix=$PREFIX \
--host=$HOST \
--enable-newlib-io-long-long \
--disable-newlib-supplied-syscalls \
--enable-shared \
--disable-libgloss \
--disable-newlib-supplied-syscalls \
--disable-nls
if [ $? -eq 0 ]; then
echo ">> $NEWLIB_DIR configure successful <<"
make $MAKE_PARAMS
if [ $? -eq 0 ]; then
echo ">> $NEWLIB_DIR make successful <<"
sudo make install
if [ $? -eq 0 ]; then
echo ">> $NEWLIB_DIR make install successful <<"
return 0
fi
else
echo ">> $NEWLIB_DIR make Failed <<"
fi
else
echo ">> $NEWLIB_DIR configure Failed <<"
fi
return -1
}
build_gcc_post(){
mkdir $TEMP_GCC_DIR_POST
cd $TEMP_GCC_DIR_POST
export AR_FOR_TARGET=$TARGET-ar
export NM_FOR_TARGET=$TARGET-nm
export OBJDUMP_FOR_TARGET=$TARGET-objdump
export STRIP_FOR_TARGET=$TARGET-strip
sh ../$GCC_DIR/configure --build=$HOST \
--host=$HOST \
--target=$TARGET \
--enable-threads \
--disable-libmudflap \
--disable-libssp \
--disable-libstdcxx-pch \
--enable-extra-sgxx-multilibs \
--disable-multilib \
--with-mode=thumb \
--with-cpu=cortex-a8 \
--with-float=hard \
--with-gnu-as \
--with-gnu-ld \
'--with-specs=%{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' \
--enable-languages=c,c++ \
--enable-shared \
--disable-lto \
--with-newlib \
'--with-pkgversion=$PKGCONF' \
--with-bugurl=$BTURL \
--disable-nls \
--prefix=$PREFIX \
--with-headers=yes \
--with-gmp=$HOSTPREFIX \
--with-mpfr=$HOSTPREFIX \
--with-ppl=$HOSTPREFIX \
'--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
--with-cloog=$HOSTPREFIX \
--disable-libgomp \
--disable-poison-system-directories \
--with-build-time-tools=$PREFIX/$TARGET/bin
if [ $? -eq 0 ]; then
echo ">> $GCC_DIR (POST) configure successful <<"
echo ">> Doing make on $GCC_DIR <<"
make $MAKE_PARAMS #LDFLAGS_FOR_TARGET=--sysroot=$PREFIX CPPFLAGS_FOR_TARGET=--sysroot=$PREFIX build_tooldir=$PREFIX
if [ $? -eq 0 ]; then
echo ">> $GCC_DIR (POST) make successful <<"
sudo make install
if [ $? -eq 0 ]; then
echo ">> $GCC_DIR (POST) make install successful <<"
return 0
else
echo ">> $GCC_DIR (POST) make install Failed <<"
fi
else
echo ">> $GCC_DIR (POST) make Failed <<"
fi
else
echo ">> $GCC_DIR (POST) configure Failed <<"
fi
return -1
}
build_all(){
build_preliminary
check_error $? ">> Preliminary Build failed <<"
#
pushd $PWDDIR
build_binutils
check_error $? ">> Binutils Build failed <<"
sudo rm -rf $PWDDIR/$TEMP_BINUTILS_DIR
[ $? -eq 0 ] && echo ">> Removed $TEMP_BINUTILS_DIR successful <<" || echo ">> Failed to remove $TEMP_BINUTILS_DIR <<"
popd $PWDDIR
#
pushd $PWDDIR
build_gcc_pre
check_error $? ">> GCC BootStrap Build failed <<"
sudo rm -rf $PWDDIR/$TEMP_GCC_DIR_PRE
[ $? -eq 0 ] && echo ">> Removed $TEMP_GCC_DIR_PRE (PRE) successful <<" || echo ">> Failed to remove $TEMP_GCC_DIR_PRE (PRE) <<"
popd $PWDDIR
#
pushd $PWDDIR
OLDPATH=$PATH
export PATH=$PREFIX/bin:$OLDPATH
export CFLAGS_FOR_TARGET='-g -O2'
build_newlib
check_error $? ">> NewLib build failed <<"
popd $PWDDIR
sudo rm -rf $PWDDIR/$TEMP_NEWLIB_DIR
[ $? -eq 0 ] && echo ">> Removed $TEMP_NEWLIB_DIR successful <<" || echo ">> Failed to remove $TEMP_NEWLIB_DIR <<"
#
pushd $PWDDIR
OLDPATH=$PATH
export PATH=$PREFIX/bin:$PREFIX:$OLDPATH
build_gcc_post
check_error $? ">> GCC Final Build failed <<"
popd $PWDDIR
sudo rm -rf $PWDDIR/$TEMP_GCC_DIR_POST
[ $? -eq 0 ] && echo ">> Removed $TEMP_GCC_DIR_POST (POST) successful <<" || echo ">> Failed to remove $TEMP_GCC_DIR_POST (POST) <<"
#
pushd $PWDDIR
OLDPATH=$PATH
export PATH=$PREFIX/bin:$PREFIX:$OLDPATH
build_post_expat
check_error $? ">> $EXPAT_DIR (POST) Build failed <<"
popd $PWDDIR
#
pushd $PWDDIR
OLDPATH=$PATH
export PATH=$PREFIX/bin:$PREFIX:$OLDPATH
build_post_gdb
check_error $? ">> $GDB_DIR Final Build failed <<"
popd $PWDDIR
#
return 0
}
# Not sure if this is right as to why not build a native zlib????
# As per steps 62/154, we built that right?
# Questionable ???
build_post_zlib(){
cd $ZLIB_DIR
make distclean && make clean
sh configure --prefix=$PREFIX
if [ $? -eq 0 ]; then
echo ">> $ZLIB_DIR (POST) configure successful <<"
make $MAKE_PARAMS
if [ $? -eq 0 ]; then
echo ">> $ZLIB_DIR (POST) make successful <<"
sudo make install
if [ $? -eq 0 ]; then
echo ">> $ZLIB_DIR (POST) make install successful <<"
return 0
else
echo ">> $ZLIB_DIR (POST) make install Failed <<"
fi
else
echo ">> $ZLIB_DIR (POST) make failed <<"
fi
else
echo ">> $ZLIB_DIR (POST) configure failed <<"
fi
return -1
}
build_post_expat(){
cd $EXPAT_DIR
sh configure --build=$HOST \
--host=$HOST \
--target=$TARGET \
--prefix=$HOSTPREFIX \
--disable-shared \
--disable-nls
if [ $? -eq 0 ]; then
echo ">> $EXPAT_DIR (POST) configure successful <<"
make $MAKE_PARAMS
if [ $? -eq 0 ]; then
echo ">> $EXPAT_DIR (POST) make successful <<"
sudo make install
if [ $? -eq 0 ]; then
echo ">> $EXPAT_DIR (POST) make install successful <<"
return 0
else
echo ">> $EXPAT_DIR (POST) make install Failed <<"
fi
else
echo ">> $EXPAT_DIR (POST) make failed <<"
fi
else
echo ">> $EXPAT_DIR (POST) configure failed <<"
fi
return -1
}
build_post_gdb(){
cd $GDB_DIR
sh configure --build=$HOST \
--target=$TARGET \
--prefix=$HOSTPREFIX \
--host=$HOST \
--disable-sim \
'--with-pkgversion=$PKGCONF' \
--with-bugurl=$BTURL \
--disable-nls \
--with-libexpat-prefix=$HOSTPREFIX \
--with-separate-debug-dir=$PREFIX/$TARGET.debug \
--with-relocated-sources=$PREFIX/$TARGET \
--with-system-gdbinit=$PREFIX/$TARGET/lib/gdbinit \
'--with-gdb-datadir=$PREFIX/$TARGET/share/gdb'
if [ $? -eq 0 ]; then
echo ">> $GDB_DIR (POST) configure successful <<"
make $MAKE_PARAMS
if [ $? -eq 0 ]; then
echo ">> $GDB_DIR (POST) make successful <<"
sudo make install prefix=$PREFIX
if [ $? -eq 0 ]; then
echo ">> $GDB_DIR (POST) make install successful <<"
return 0
else
echo ">> $GDB_DIR (POST) make install Failed <<"
fi
else
echo ">> $GDB_DIR (POST) make failed <<"
fi
else
echo ">> $GDB_DIR (POST) configure failed <<"
fi
}
cleanup(){
pushd $PWDDIR
for i in *; do
if [ -d $i ]; then
echo ">> Cleaning $i <<"
cd $i
make distclean && make clean
cd ..
fi
done
popd $PWDDIR
}
echo ">> $0 started: `date` <<"
if [ $# -eq 0 ]; then
usage
exit 1
fi
#
OPTIND=1
while getopts "hcapbfnlxzd" opt; do
case "$opt" in
h)
usage
exit 1
;;
a)
build_all
;;
c)
cleanup
;;
p)
build_preliminary
check_error $? ">> Preliminary Build failed <<"
;;
b)
pushd $PWDDIR
build_binutils
check_error $? ">> Binutils Build failed <<"
popd $PWDDIR
sudo rm -rf $PWDDIR/$TEMP_BINUTILS_DIR
[ $? -eq 0 ] && echo ">> Removed $TEMP_BINUTILS_DIR successful <<" || echo ">> Failed to remove $TEMP_BINUTILS_DIR <<"
;;
f)
pushd $PWDDIR
build_gcc_pre
check_error $? ">> GCC BootStrap Build failed <<"
popd $PWDDIR
sudo rm -rf $PWDDIR/$TEMP_GCC_DIR_PRE
[ $? -eq 0 ] && echo ">> Removed $TEMP_GCC_DIR_PRE (PRE) successful <<" || echo ">> Failed to remove $TEMP_GCC_DIR_PRE (PRE) <<"
;;
n)
pushd $PWDDIR
OLDPATH=$PATH
export PATH=$PREFIX/bin:$OLDPATH
export CFLAGS_FOR_TARGET='-g -O2'
build_newlib
check_error $? ">> NewLib build failed <<"
popd $PWDDIR
sudo rm -rf $PWDDIR/$TEMP_NEWLIB_DIR
[ $? -eq 0 ] && echo ">> Removed $TEMP_NEWLIB_DIR successful <<" || echo ">> Failed to remove $TEMP_NEWLIB_DIR <<"
;;
l)
pushd $PWDDIR
OLDPATH=$PATH
export PATH=$PREFIX/bin:$PREFIX:$OLDPATH
build_gcc_post
check_error $? ">> GCC Final Build failed <<"
popd $PWDDIR
sudo rm -rf $PWDDIR/$TEMP_GCC_DIR_POST
[ $? -eq 0 ] && echo ">> Removed $TEMP_GCC_DIR_POST (POST) successful <<" || echo ">> Failed to remove $TEMP_GCC_DIR_POST (POST) <<"
;;
z)
pushd $PWDDIR
OLDPATH=$PATH
export PATH=$PREFIX/bin:$PREFIX:$OLDPATH
export CC=$PREFIX/bin/$TARGET-gcc
export CFLAGS=-fPIC
build_post_zlib
check_error $? ">> $ZLIB_DIR (POST) Build failed <<"
popd $PWDDIR
;;
x)
pushd $PWDDIR
OLDPATH=$PATH
unset CC
export PATH=$PREFIX/bin:$PREFIX:$OLDPATH
build_post_expat
check_error $? ">> $EXPAT_DIR (POST) Build failed <<"
popd $PWDDIR
;;
d)
pushd $PWDDIR
OLDPATH=$PATH
export PATH=$PREFIX/bin:$PREFIX:$OLDPATH
build_post_gdb
check_error $? ">> $GDB_DIR Final Build failed <<"
popd $PWDDIR
;;
\?)
usage
exit
;;
*)
usage
exit
;;
esac
done
echo ">> $0 stopped: `date` <<"