3 # The download a file function.
9 wget
--progress=dot
-c -P tools
$url 2>&1 |
grep "%" |
sed -u -e "s,\.,,g" -e "s,\,,,g" |
awk '{printf("\b\b\b\b%4s", $2)}'
11 # Delete everything and show done.
16 # Export some common stuff - the defaults, if they aren't in the arguments.
17 test ! -n "$PREFIX" && PREFIX
=$
(readlink
-f .
/tools
)
20 # Currently allowed values: bcm2835 [RPi]
21 # TODO: probably spit out error message.
22 test ! -n "$TARGET" && TARGET
=bcm2835
24 # Parse command line options for prefix & target.
25 while getopts "p:t:" optname
37 if test z
"$TARGET" = z
"bcm2835"
42 # Make the build directory.
48 echo -n " [WGET] tools/binutils-2.23.2.tar.bz2, "
49 download
"http://ftp.gnu.org/gnu/binutils/binutils-2.23.2.tar.bz2"
52 echo -n " [WGET] tools/gcc-4.8.1.tar.bz2, "
53 download
"http://ftp.gnu.org/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.bz2"
58 echo " [UNTAR] tools/binutils-2.23.2.tar.bz2"
59 tar -xf tools
/binutils-2.23
.2.
tar.bz2
-C tools
>/dev
/null
60 rm tools
/binutils-2.23
.2.
tar.bz2
63 echo " [UNTAR] tools/gcc-4.8.1.tar.bz2"
64 tar -xf tools
/gcc-4.8
.1.
tar.bz2
-C tools
>/dev
/null
65 rm tools
/gcc-4.8
.1.
tar.bz2
70 mkdir
-p tools
/build-binutils
73 echo " [BINUT] Configuring"
74 cd tools
/build-binutils
&& ..
/binutils-2.23
.2/configure
--target=$TARGET --prefix=$PREFIX --disable-nls
78 echo " [BINUT] Compiling"
79 make -C tools
/build-binutils all
82 echo " [BINUT] Installing"
83 make -C tools
/build-binutils
install
86 echo " [BINUT] Cleaning"
87 rm -rf tools
/build-binutils tools
/binutils-2.23
.2
90 mkdir
-p tools
/build-gcc
93 echo " [GCC] Configuring"
94 export PATH
=$PATH:$PREFIX/bin
95 cd tools
/build-gcc
&& ..
/gcc-4.8
.1/configure
--target=$TARGET --prefix=$PREFIX --disable-nls --enable-languages=c
--without-headers --with-gnu-as --with-gnu-ld
98 export LD_FOR_TARGET
=$PREFIX/bin
/$TARGET-elf-ld
99 export OBJDUMP_FOR_TARGET
=$PREFIX/bin
/$TARGET-elf-objdump
100 export NM_FOR_TARGET
=$PREFIX/bin
/$TARGET-elf-nm
101 export RANLIB_FOR_TARGET
=$PREFIX/bin
/$TARGET-elf-ranlib
102 export READELF_FOR_TARGET
=$PREFIX/bin
/$TARGET-elf-readelf
103 export STRIP_FOR_TARGET
=$PREFIX/bin
/$TARGET-elf-strip
104 export AS_FOR_TARGET
=$PREFIX/bin
/$TARGET-elf-as
107 echo " [GCC] Compiling"
108 make -C tools
/build-gcc all-gcc
111 echo " [GCC] Installing"
112 make -C tools
/build-gcc install-gcc
115 echo " [LIBGCC] Compiling"
116 make -C tools
/build-gcc all-target-libgcc CFLAGS_FOR_TARGET
="-g -O2"
119 echo " [LIBGCC] Installing"
120 make -C tools
/build-gcc install-target-libgcc
123 echo " [GCC] Cleaning"
124 rm -rf tools
/build-gcc tools
/gcc-4.8
.1