#!/usr/bin/sh

tar jxvf binutils-2.16.tar.bz2
cd binutils-2.16
./configure --target=sh-elf --prefix=/usr/local/sh-tools
make install
cd ..

export PATH=$PATH:/usr/local/sh-tools/bin
tar jxvf gcc-3.4.5.tar.bz2
cd gcc-3.4.5
make
./configure --target=sh-elf --prefix=/usr/local/sh-tools --enable-languages=c
make
make install
cd ..


tar jxvf insight-6.4.tar.bz2
cd insight-6.4
./configure --target=sh-elf --prefix=/usr/local/sh-tools
make
make install
cd ..

tar zxvf newlib-1.14.0.tar.gz
cd newlib-1.14.0
export TARGET_CFLAGS=-DREENTRANT_SYSCALLS_PROVIDED
./configure --target=sh-elf --prefix=/usr/local/sh-tools/newlib
make
make install
/usr/local/sh-tools/bin/sh-elf-ar d /usr/local/sh-tools/newlib/sh-elf/lib/m2/libc.a syscalls.o
cd ..

