#!/bin/sh ########################################################################################### # This is the script file 'build-cross.sh'. # Its job is to build a U**x or Linux-hosted cross compiler targeting an embedded system. # # The script is invoked in the following manner: # sh build-cross.sh targetname [install] # # This script assumes that the 'one-tree' script has already been run # to un-pack the tar files and link them into a source directory named 'src'. # Typical usage would be to run the script without the 'install' option to compile # the tools, and then log in as 'root' and re-run with the 'install' option enabled # to install the tools into the execution directories. ########################################################################################### ########################################################################################### ############################### Configuration variables. ################################## ########################################################################################### # Define some variables which control the process. # Modify these to suit your requirements. # set 'prefix' to the root of the install directory on your U**X box. # For most Linux systems this should be "/usr". prefix=/usr ########################################################################################### ############################ End of Configuration variables. ############################## ########### You will most likely not need to change anything below this line. ############# ########################################################################################### # Stop if errors occur along the way. set -e # Get the target name specified on the command line, and install flag. target=$1 action=$2 # Bail if no target given. if [ x"$target" = x ] || [ x"$target" = xinstall ] then echo "$0: no target name specified." echo "usage: '$0 targetname [install]', where:" echo " - 'targetname' specifies the target configuration to build" echo " - 'install' (optional) directs the script to install the tools (in $prefix)." exit 1 fi # Announce ourselves echo "$0: started `date`" if [ ! -d b-$target ] then mkdir b-$target fi cd b-$target if [ ! -f configure.done ] then echo "$0: configure for $target." ../src/configure --target=$target --prefix=$prefix -v touch configure.done fi echo "$0: compile binutils, gcc, and newlib." make all LANGUAGES="c c++" # Compilation done, install if asked to do so. if [ x"$action" = xinstall ] then echo "$0: installing binutils, gcc, and newlib in $prefix." make install LANGUAGES="c c++" fi # Announce that we're finished. echo "$0: finished `date`" exit $?