#!/bin/bash ####################################################################### ##### This is a script to acquire the necessary packages to build ##### ##### the gcc/g++ tool chain for the Sega Dreamcast. ##### ##### It is based around the build instructions found at: ##### ##### http://uk.geocities.com/munkeechuff/ ##### ##### I added in the arm building. ##### ##### If you can think of anything that should be added to this ##### ##### script then email me: james@sumners.ath.cx ##### ####################################################################### ################################################################## ##### Version 0.3 ##### ##### ##### ##### Added better logging thanks to a suggestion by ##### ##### Gavin Shelley . ##### ##### Log files will be created as follows: ##### ##### 'make install 2>&1 | tee -a build--.log' ##### ################################################################## # change to your desired target sh_target=sh-elf # change to your desired target arm_target=arm-elf # change to your desired install location prefix=/home/dcdev/dc install=$prefix/bin # to update your tool chain just change the version numbers :) # you may also want to build to a temporary install location # so you dont loose your working one right away binutils_ver=2.11.2 gcc_ver=3.0.3 newlib_ver=1.9.0 # download sites # do not add a trailing slash # gcc_site is where binutils, gcc, and g++ are downloaded from # newlib_site is (fairly obvious) where newlib is downloaded from gcc_site=http://metalab.unc.edu/pub/gnu newlib_site=ftp://mirrors.rcn.net/pub/sourceware # you _shouldn't_ (that is not to say that you won't) have to # change anything below here download() { tmp=`which wget` if [ ! -n $tmp ]; then echo The \'wget\' application is not installed. echo Please download the following packages to the build directory manually: echo binutils-${binutils_ver}.tar.gz echo gcc-${gcc_ver}.tar.gz echo gcc-core-${gcc_ver}.tar.gz echo gcc-g++-${gcc_ver}.tar.gz echo newlib-${newlib_ver}.tar.gz exit fi echo : echo : >> log echo \*\*\*\*\* Downloading commenced \*\*\*\*\* echo \*\*\*\*\* Downloading commenced \*\*\*\*\* >> log echo : echo : >> log echo Downloading binutils-${binutils_ver}.tar.gz echo Downloading binutils-${binutils_ver}.tar.gz >> log wget ${gcc_site}/binutils/binutils-${binutils_ver}.tar.gz echo Downloading gcc-${gcc_ver}.tar.gz echo Downloading gcc-${gcc_ver}.tar.gz >> log wget ${gcc_site}/gcc/gcc-${gcc_ver}/gcc-${gcc_ver}.tar.gz echo Downloading gcc-core-${gcc_ver}.tar.gz echo Downloading gcc-core-${gcc_ver}.tar.gz >> log wget wget ${gcc_site}/gcc/gcc-${gcc_ver}/gcc-core-${gcc_ver}.tar.gz echo Downloading gcc-g++-${gcc_ver}.tar.gz echo Downloading gcc-g++-${gcc_ver}.tar.gz >> log wget wget wget ${gcc_site}/gcc/gcc-${gcc_ver}/gcc-g++-${gcc_ver}.tar.gz echo Downloading newlib-${newlib_ver}.tar.gz echo Downloading newlib-${newlib_ver}.tar.gz >> log wget ${newlib_site}/newlib/newlib-${newlib_ver}.tar.gz echo : echo : >> log echo \*\*\*\*\* Downloading done \*\*\*\*\* echo \*\*\*\*\* Downloading done \*\*\*\*\* >> log } extract () { echo \*\*\*\*\* Starting extraction \*\*\*\*\* echo \*\*\*\*\* Starting extraction \*\*\*\*\* >> log echo : echo : >> log echo Extracting binutils-${binutils_ver}.tar.gz echo Extracting binutils-${binutils_ver}.tar.gz >> log tar zxf binutils-${binutils_ver}.tar.gz echo Extracting gcc-${gcc_ver}.tar.gz echo Extracting gcc-${gcc_ver}.tar.gz >> log tar zxf gcc-${gcc_ver}.tar.gz echo Extracting gcc-core-${gcc_ver}.tar.gz echo Extracting gcc-core-${gcc_ver}.tar.gz >> log tar zxf gcc-core-${gcc_ver}.tar.gz echo Extracting gcc-g++-${gcc_ver}.tar.gz echo Extracting gcc-g++-${gcc_ver}.tar.gz >> log tar zxf gcc-g++-${gcc_ver}.tar.gz echo Extracting newlib-${newlib_ver}.tar.gz echo Extracting newlib-${newlib_ver}.tar.gz >> log tar zxf newlib-${newlib_ver}.tar.gz echo : echo : >> log echo \*\*\*\*\* Extraction done \*\*\*\*\* echo \*\*\*\*\* Extraction done \*\*\*\*\* >> log } build_sh4 () { echo Building binutils-${binutils_ver} to build-binutils-${sh_target} echo Building binutils-${binutils_ver} to build-binutils-${sh_target} >> log mkdir build-binutils-${sh_target} cd build-binutils-${sh_target} ../binutils-${binutils_ver}/configure --target=$sh_target --prefix=$prefix make all install 2>&1 | tee -a build-binutils-${sh_target}.log cd .. pth=`echo $PATH | cut - -d : -f 1` if [ $pth != $install ]; then export PATH=$install:$PATH fi echo Building gcc-${gcc_ver} to build-gcc-${sh_target} echo Building gcc-${gcc_ver} to build-gcc-${sh_target} >> log mkdir build-gcc-${sh_target} cd build-gcc-${sh_target} ../gcc-${gcc_ver}/configure --target=$sh_target --prefix=$prefix --without-headers --with-newlib --enable-languages=c make all-gcc 2>&1 | tee -a build-gcc-${sh_target}.log make install-gcc cd .. echo Building newlib-${newlib_ver} to build-newlib-${sh_target} echo Building newlib-${newlib_ver} to build-newlib-${sh_target} >> log mkdir build-newlib-${sh_target} cd build-newlib-${sh_target} ../newlib-${newlib_ver}/configure --target=$sh_target --prefix=$prefix make all install CC_FOR_TARGET=${install}/${sh_target}-gcc AS_FOR_TARGET=${install}/${sh_target}-as LD_FOR_TARGET=${install}/${sh_target}-ld AR_FOR_TARGET=${install}/${sh_target}-ar RANLIB_FOR_TARGET=${install}/${sh_target}-ranlib 2>&1 | tee -a build-newlib-${sh_target}.log cd .. echo Building g++ to build-gcc-${sh_target} echo Building g++ to build-gcc-${sh_target} >> log cd build-gcc-${sh_target} make clean ../gcc-${gcc_ver}/configure --target=$sh_target --prefix=$prefix --without-headers --with-newlib --enable-languages=c,c++ make all install 2>&1 | tee -a build-g++-${sh_target}.log } build_arm () { echo Building binutils-${binutils_ver} to build-binutils-${arm_target} echo Building binutils-${binutils_ver} to build-binutils-${arm_target} >> log mkdir build-binutils-${arm_target} cd build-binutils-${arm_target} ../binutils-${binutils_ver}/configure --target=$arm_target --prefix=$prefix make all install 2>&1 | tee -a build-binutils-${arm_target}.log cd .. pth=`echo $PATH | cut - -d : -f 1` if [ $pth != $install ]; then export PATH=$install:$PATH fi echo Building gcc-${gcc_ver} to build-gcc-${arm_target} echo Building gcc-${gcc_ver} to build-gcc-${arm_target} >> log mkdir build-gcc-${arm_target} cd build-gcc-${arm_target} ../gcc-${gcc_ver}/configure --target=$arm_target --prefix=$prefix --without-headers --with-newlib --enable-languages=c make all-gcc 2>&1 | tee -a build-gcc-${arm_target}.log make install-gcc cd .. echo Building newlib-${newlib_ver} to build-newlib-${arm_target} echo Building newlib-${newlib_ver} to build-newlib-${arm_target} >> log mkdir build-newlib-${arm_target} cd build-newlib-${arm_target} ../newlib-${newlib_ver}/configure --target=$arm_target --prefix=$prefix make all install CC_FOR_TARGET=${install}/${arm_target}-gcc AS_FOR_TARGET=${install}/${arm_target}-as LD_FOR_TARGET=${install}/${arm_target}-ld AR_FOR_TARGET=${install}/${arm_target}-ar RANLIB_FOR_TARGET=${install}/${arm_target}-ranlib 2>&1 | tee -a build-newlib-${arm_target}.log cd .. echo Building g++ to build-gcc-${arm_target} echo Building g++ to build-gcc-${arm_target} >> log cd build-gcc-${arm_target} make clean ../gcc-${gcc_ver}/configure --target=$arm_target --prefix=$prefix --without-headers --with-newlib --enable-languages=c,c++ make all install 2>&1 | tee -a build-g++-${arm_target}.log } clean () { rm -rf build-* rm -rf binutils-* rm -rf gcc-* rm -rf newlib-* } build () { echo \*\*\*\*\* Staring build \*\*\*\*\* echo \*\*\*\*\* Staring build \*\*\*\*\* >> log echo : echo : >> log build_${tgt} clear echo ${tgt} tools built. echo Test the tools before running the script with the clean option. echo Happy coding. } case "$1" in "build_sh4" | "BUILD_SH4" ) clear if [ ! -f gcc-${gcc_ver}.tar.gz ]; then download extract fi tgt=sh4 build $tgt ;; "build_arm" | "BUILD_ARM" ) clear if [ ! -f gcc-${gcc_ver}.tar.gz ]; then download extract fi tgt=arm build $tgt ;; "download" | "DOWNLOAD" ) clear download ;; "extract" | "EXTRACT" ) clear if [ ! -f gcc-${gcc_ver}.tar.gz ]; then download fi extract ;; "clean" | "CLEAN" ) clear echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* echo \*\*\*\*\* Are you sure you want to clean house? \ \ \ \*\*\*\*\* echo \*\*\*\*\* This will delete everything in the \ \ \ \ \ \ \*\*\*\*\* echo \*\*\*\*\* directory that contains the build script \*\*\*\*\* echo \*\*\*\*\* except for the build script. \(yes/no\) \ \ \ \*\*\*\*\* echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* echo :: echo \\\/ read ANSWER if [ "$ANSWER" = "yes" ]; then clean clear echo Build directory cleaned. exit else clear echo Nothing done. exit fi ;; * ) echo \*\*\*\* Stalin\'s build script version 0.3 \*\*\*\* echo echo Script usage\: echo \ download echo \ extract echo \ build_sh4 echo \ build_arm echo \ clean echo echo The script can only takes one argument at a time. echo It will do a test for gcc-${gcc_ver}.tar.gz when you execute one of echo the build options \(e.g. \\). If it does not echo find the package it will initiate the downloading automatically and echo automatically do the extraction. ;; esac