Line 1... |
Line 1... |
#!/bin/bash
|
#!/bin/bash
|
|
|
# Copyright (C) 2008,2009 www.meansoffreedom.org, www.orsoc.se
|
# Copyright (C) 2008,2009,2010 www.meansoffreedom.org, www.orsoc.se
|
# This file is free software; you can redistribute it and/or modify it
|
# This file is free software; you can redistribute it and/or modify it
|
# under the terms of the GNU General Public License as published by
|
# under the terms of the GNU General Public License as published by
|
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
# (at your option) any later version.
|
# (at your option) any later version.
|
#
|
#
|
Line 13... |
Line 13... |
#
|
#
|
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
##Date: 26/05/2009
|
##Date: 11/03/2010
|
##Title: MOF_ORSOC_TCN_v5c_or32-elf.sh
|
##Title: MOF_ORSOC_TCN_v5c_or32-elf.sh
|
##Purpose: Complete Toolchain Builder from MOF & ORSoC.
|
##Purpose: Complete Toolchain Builder from MOF & ORSoC.
|
##initial rgd, mse
|
##initial rgd, mse
|
##updated jb
|
##updated jb
|
|
|
Line 81... |
Line 81... |
# OpenRISC repository's kernel.
|
# OpenRISC repository's kernel.
|
# 301109 - Changed GCC patch to one with single precision floating point as
|
# 301109 - Changed GCC patch to one with single precision floating point as
|
# default
|
# default
|
# 021209 - Added --disable-werror flag to gdb-6.8 configure line to fix issue
|
# 021209 - Added --disable-werror flag to gdb-6.8 configure line to fix issue
|
# with gcc-4.4.1
|
# with gcc-4.4.1
|
|
# 110310 - Moved or1ksim to its own directory in the chosen install directory
|
|
|
# TODO: OS X build things - need an "elf.h" from some Linux machine's
|
# TODO: OS X build things - need an "elf.h" from some Linux machine's
|
# /usr/local/include dir and put in Mac's /usr/local/include dir -
|
# /usr/local/include dir and put in Mac's /usr/local/include dir -
|
# this solves issue with Linux compilation
|
# this solves issue with Linux compilation
|
# TODO: OS X build things - add HOST_LOADLIBES="lintl" to make line of uClibc
|
# TODO: OS X build things - add HOST_LOADLIBES="lintl" to make line of uClibc
|
Line 164... |
Line 165... |
# Now check if libncurses-dev has been installed - check for the header
|
# Now check if libncurses-dev has been installed - check for the header
|
# Get host system's GCC prefix dir (usually /usr, but just to be sure)
|
# Get host system's GCC prefix dir (usually /usr, but just to be sure)
|
# Get the verbose output of GCC, redirect STDERR to STDOUT, pipe to grep replacing spaces with newlines
|
# Get the verbose output of GCC, redirect STDERR to STDOUT, pipe to grep replacing spaces with newlines
|
# grep for the prefix dir line, cut away after the equals sign and we should have the right dir
|
# grep for the prefix dir line, cut away after the equals sign and we should have the right dir
|
echo "Checking for libncurses-dev (headers)"
|
echo "Checking for libncurses-dev (headers)"
|
HOST_GCC_PREFIX=`gcc -v 2>&1 | sed 's/\ /\n/g' | grep prefix | cut -d "=" -f 2 | head -1`
|
GCC_V_LIST=`gcc -v 2>&1 | sed -e s/\ /'\\\n'/g`
|
|
HOST_GCC_PREFIX=`echo $GCC_V_LIST | grep prefix | cut -d = -f 2 | head -1`
|
NCURSES_HEADER_COUNT=`find $HOST_GCC_PREFIX/include -name "ncurses.h" | grep ncurses -c`
|
NCURSES_HEADER_COUNT=`find $HOST_GCC_PREFIX/include -name "ncurses.h" | grep ncurses -c`
|
if [ $NCURSES_HEADER_COUNT -eq 0 ]; then
|
if [ $NCURSES_HEADER_COUNT -eq 0 ]; then
|
echo
|
echo
|
echo "\tlibncurses-dev not found"
|
echo "\tlibncurses-dev not found"
|
echo ; echo "Please install libncurses-dev and re-run this script"; echo
|
echo ; echo "Please install libncurses-dev and re-run this script"; echo
|
Line 205... |
Line 207... |
## Local directory variables ##
|
## Local directory variables ##
|
START_DIR=`pwd`
|
START_DIR=`pwd`
|
DN="n"
|
DN="n"
|
DIR=`pwd`
|
DIR=`pwd`
|
|
|
|
## Makedir command we'll use ##
|
|
MKDIR=mkdir -p
|
## Versions of the toolchain components ##
|
## Versions of the toolchain components ##
|
BINUTILS_VER=binutils-2.18.50
|
BINUTILS_VER=binutils-2.18.50
|
GCC_VER_NUM=4.2.2
|
GCC_VER_NUM=4.2.2
|
GCC_VER=gcc-$GCC_VER_NUM
|
GCC_VER=gcc-$GCC_VER_NUM
|
GDB_VER=gdb-6.8
|
GDB_VER=gdb-6.8
|
Line 315... |
Line 319... |
echo "Current directory: [$DIR]"
|
echo "Current directory: [$DIR]"
|
echo "Tools will be installed in [$DIR/$TARGET]"
|
echo "Tools will be installed in [$DIR/$TARGET]"
|
echo [Y/n]:
|
echo [Y/n]:
|
read YN
|
read YN
|
|
|
|
|
## $YN will be zero length string if user just pressed enter ##
|
## $YN will be zero length string if user just pressed enter ##
|
if [ -z $YN ]
|
if [ -z $YN ]
|
then
|
then
|
VAL="y"
|
VAL="y"
|
else
|
else
|
Line 338... |
Line 343... |
#Check the path exists
|
#Check the path exists
|
if [ -d $DIR ]
|
if [ -d $DIR ]
|
then
|
then
|
# The path entered is OK
|
# The path entered is OK
|
echo "Chosen directory is [$DIR]"
|
echo "Chosen directory is [$DIR]"
|
echo "Tools will be installed in [$DIR/$TARGET]"
|
echo "Tools will be installed in [$DIR/$TARGET], or1ksim in [$DIR/or1ksim]"
|
echo "[y/n]:"
|
echo "[y/n]:"
|
read DN
|
read DN
|
|
|
if [ -z $DN ]
|
if [ -z $DN ]
|
then
|
then
|
Line 365... |
Line 370... |
MKPATHYN=$(echo $MKPATH | tr [:upper:] [:lower:])
|
MKPATHYN=$(echo $MKPATH | tr [:upper:] [:lower:])
|
fi
|
fi
|
|
|
if [ $MKPATHYN = "y" ]
|
if [ $MKPATHYN = "y" ]
|
then
|
then
|
`mkdir $DIR`
|
`mkdir -p $DIR`
|
|
|
# Check we made it successfully
|
# Check we made it successfully
|
if [ $? -ne 0 ]
|
if [ $? -ne 0 ]
|
then
|
then
|
DN="n"
|
DN="n"
|
Line 404... |
Line 409... |
DOWNLOAD_DIR=$START_DIR/or32-download
|
DOWNLOAD_DIR=$START_DIR/or32-download
|
|
|
## Setup the target tool installation directory ##
|
## Setup the target tool installation directory ##
|
INSTALL_DIR=$DIR
|
INSTALL_DIR=$DIR
|
|
|
mkdir $INSTALL_DIR
|
$MKDIR $INSTALL_DIR
|
|
|
####################################################################################################
|
####################################################################################################
|
## Now check which sources have already been downloaded, if any ##
|
## Now check which sources have already been downloaded, if any ##
|
DO_DOWNLOADS="y" ## Default is to NOT do downloads
|
DO_DOWNLOADS="y" ## Default is to NOT do downloads
|
|
|
Line 430... |
Line 435... |
|
|
if [ $DO_DOWNLOADS = "y" ]
|
if [ $DO_DOWNLOADS = "y" ]
|
then
|
then
|
## Check if download directory exists, if not create it ##
|
## Check if download directory exists, if not create it ##
|
if [ ! -d $DOWNLOAD_DIR ]; then
|
if [ ! -d $DOWNLOAD_DIR ]; then
|
mkdir $DOWNLOAD_DIR
|
$MKDIR $DOWNLOAD_DIR
|
fi
|
fi
|
|
|
cd $DOWNLOAD_DIR
|
cd $DOWNLOAD_DIR
|
|
|
## We'll need the md5sum file ##
|
## We'll need the md5sum file ##
|
Line 574... |
Line 579... |
|
|
if [ $DBG_BUILD -eq 0 ]
|
if [ $DBG_BUILD -eq 0 ]
|
then
|
then
|
## Always start with a clean build dir ##
|
## Always start with a clean build dir ##
|
rm -fr $BUILD_TOP
|
rm -fr $BUILD_TOP
|
mkdir $BUILD_TOP
|
$MKDIR $BUILD_TOP
|
chmod 777 $BUILD_TOP
|
chmod 777 $BUILD_TOP
|
|
|
mkdir $BUILD_TOP/b-gcc
|
$MKDIR $BUILD_TOP/b-gcc
|
mkdir $BUILD_TOP/b-b
|
$MKDIR $BUILD_TOP/b-b
|
fi
|
fi
|
|
|
## default build option is yes ##
|
## default build option is yes ##
|
BUILD_THIS="y"
|
BUILD_THIS="y"
|
|
|
Line 603... |
Line 608... |
if [ $BUILD_THIS = "y" ]
|
if [ $BUILD_THIS = "y" ]
|
then
|
then
|
## Delete and recreate the binutils directory ##
|
## Delete and recreate the binutils directory ##
|
rm -rf $BUILD_TOP/b-b
|
rm -rf $BUILD_TOP/b-b
|
rm -rf $BUILD_TOP/$BINUTILS_VER
|
rm -rf $BUILD_TOP/$BINUTILS_VER
|
mkdir $BUILD_TOP/b-b
|
$MKDIR $BUILD_TOP/b-b
|
|
|
fi
|
fi
|
fi
|
fi
|
|
|
##########################Building Binutils#######################
|
##########################Building Binutils#######################
|
Line 680... |
Line 685... |
## Delete and recreate the gcc directory ##
|
## Delete and recreate the gcc directory ##
|
rm -rf $BUILD_TOP/b-gcc
|
rm -rf $BUILD_TOP/b-gcc
|
rm -rf $BUILD_TOP/$GCC_VER
|
rm -rf $BUILD_TOP/$GCC_VER
|
rm -rf $BUILD_TOP/$LINUX_VER
|
rm -rf $BUILD_TOP/$LINUX_VER
|
|
|
mkdir $BUILD_TOP/b-gcc
|
$MKDIR $BUILD_TOP/b-gcc
|
|
|
## Undo everything done in the next part
|
## Undo everything done in the next part
|
rm -rf $INSTALL_DIR/$TARGET/include
|
rm -rf $INSTALL_DIR/$TARGET/include
|
unlink $INSTALL_DIR/$TARGET/sys-include
|
unlink $INSTALL_DIR/$TARGET/sys-include
|
|
|
Line 728... |
Line 733... |
## Make sure that built ok ##
|
## Make sure that built ok ##
|
check_exit_code
|
check_exit_code
|
|
|
cd $BUILD_TOP
|
cd $BUILD_TOP
|
|
|
mkdir $INSTALL_DIR/$TARGET/include
|
$MKDIR $INSTALL_DIR/$TARGET/include
|
mkdir $INSTALL_DIR/$TARGET/include/asm
|
$MKDIR $INSTALL_DIR/$TARGET/include/asm
|
mkdir $INSTALL_DIR/$TARGET/include/linux
|
$MKDIR $INSTALL_DIR/$TARGET/include/linux
|
|
|
cp -f -dR $LINUX_VER/include/linux/* $INSTALL_DIR/$TARGET/include/linux
|
cp -f -dR $LINUX_VER/include/linux/* $INSTALL_DIR/$TARGET/include/linux
|
cp -f -dR $LINUX_VER/include/asm-or32/* $INSTALL_DIR/$TARGET/include/asm
|
cp -f -dR $LINUX_VER/include/asm-or32/* $INSTALL_DIR/$TARGET/include/asm
|
|
|
cd $INSTALL_DIR/$TARGET
|
cd $INSTALL_DIR/$TARGET
|
Line 1103... |
Line 1108... |
if [ -z $ON_CYGWIN ]
|
if [ -z $ON_CYGWIN ]
|
then
|
then
|
|
|
RT=`whoami`
|
RT=`whoami`
|
if [ $RT = "root" ];then
|
if [ $RT = "root" ];then
|
mkdir rd_mount
|
$MKDIR rd_mount
|
chmod 777 rd_mount
|
chmod 777 rd_mount
|
mount -t ext2 -o loop $RAMDISK_FILE rd_mount
|
mount -t ext2 -o loop $RAMDISK_FILE rd_mount
|
cp -f -dR $BUILD_TOP/busy_out.1.7.5/* $BUILD_TOP/rd_mount
|
cp -f -dR $BUILD_TOP/busy_out.1.7.5/* $BUILD_TOP/rd_mount
|
umount rd_mount
|
umount rd_mount
|
cp -f $RAMDISK_FILE $LINUX_VER/$LINUX_RAMDISK_FILE
|
cp -f $RAMDISK_FILE $LINUX_VER/$LINUX_RAMDISK_FILE
|
Line 1206... |
Line 1211... |
tar xjf $DOWNLOAD_DIR/$ZBALL6
|
tar xjf $DOWNLOAD_DIR/$ZBALL6
|
|
|
cd $SIM_VER
|
cd $SIM_VER
|
|
|
echo
|
echo
|
echo "Configuring $SIM_VER: --target=$TARGET --prefix=$INSTALL_DIR/$TARGET"
|
echo "Configuring $SIM_VER: --target=$TARGET --prefix=$INSTALL_DIR/$SIM_VER"
|
|
|
./configure --target=$TARGET --prefix=$INSTALL_DIR/$TARGET > $SIM_VER-configure.log 2>&1
|
./configure --target=$TARGET --prefix=$INSTALL_DIR/$SIM_VER > $SIM_VER-configure.log 2>&1
|
|
|
echo
|
echo
|
echo "Making and installing $SIM_VER"
|
echo "Making and installing $SIM_VER"
|
echo "Logging output to $SIM_VER-make.log"
|
echo "Logging output to $SIM_VER-make.log"
|
make all install > $SIM_VER-make.log 2>&1
|
make all install > $SIM_VER-make.log 2>&1
|
|
|
## Make sure that built ok ##
|
## Make sure that built ok ##
|
check_exit_code
|
check_exit_code
|
|
|
|
## Setup symbolic link from or1ksim-x.y.z to simply or1ksim
|
|
|
|
echo "Symbolically linking $INSTALL_DIR/$SIM_VER to $INSTALL_DIR/or1ksim"
|
|
if [ -e $INSTALL_DIR/or1ksim ]; then
|
|
echo "Symlink $INSTALL_DIR/or1ksim already exists. Updating to this version"
|
|
unlink $INSTALL_DIR/or1ksim;
|
|
check_exit_code
|
|
fi
|
|
echo "ln -s $INSTALL_DIR/$SIM_VER $INSTALL_DIR/or1ksim"
|
|
ln -s $INSTALL_DIR/$SIM_VER $INSTALL_DIR/or1ksim
|
|
|
cd $BUILD_TOP
|
cd $BUILD_TOP
|
fi
|
fi
|
##########################Finish Simulator build#########################
|
##########################Finish Simulator build#########################
|
|
|
|
|
Line 1275... |
Line 1291... |
|
|
fi
|
fi
|
|
|
|
|
cd $BUILD_TOP/$LINUX_VER
|
cd $BUILD_TOP/$LINUX_VER
|
$INSTALL_DIR/$TARGET/bin/$TARGET-sim -f or1ksim_linux.cfg vmlinux
|
$INSTALL_DIR/or1ksim/bin/$TARGET-sim -f or1ksim_linux.cfg vmlinux
|
|
|
else
|
else
|
## User didn't run the sim, but tell them how to anyway ##
|
## User didn't run the sim, but tell them how to anyway ##
|
echo "The compiled linux image is found in $BUILD_TOP/$LINUX_VER/vmlinux"
|
echo "The compiled linux image is found in $BUILD_TOP/$LINUX_VER/vmlinux"
|
echo "To run it in the simulator, cd to $BUILD_TOP/$LINUX_VER"
|
echo "To run it in the simulator, cd to $BUILD_TOP/$LINUX_VER"
|
Line 1291... |
Line 1307... |
|
|
echo
|
echo
|
echo "OpenRISC toolchain and architectural simulator build is complete!"
|
echo "OpenRISC toolchain and architectural simulator build is complete!"
|
echo
|
echo
|
echo "Your tools are installed in: $INSTALL_DIR/$TARGET"
|
echo "Your tools are installed in: $INSTALL_DIR/$TARGET"
|
|
echo "or1ksim has been installed in: $INSTALL_DIR/$SIM_VER"
|
|
echo
|
|
echo "Please add the paths:"
|
|
echo "\t$INSTALL_DIR/$TARGET/bin"
|
|
echo "\t$INSTALL_DIR/or1ksim/bin"
|
|
echo "to your PATH variable, for example, in most systems add the line"
|
|
echo "below to your ~/.bashrc file:"
|
|
echo
|
|
echo "\texport PATH=\$PATH:$INSTALL_DIR/$TARGET/bin:$INSTALL_DIR/or1ksim/bin"
|
echo
|
echo
|
echo "Please add $INSTALL_DIR/$TARGET/bin to your PATH variable"
|
echo "For further support please visit the OpenRISC forum at OpenCores"
|
|
echo "http://opencores.org/forum,OpenRISC"
|
echo
|
echo
|
exit 0
|
exit 0
|
|
|
##########################End Script##############################
|
##########################End Script##############################
|
|
|
No newline at end of file
|
No newline at end of file
|