public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Tutorial 4 - Mcore script
@ 2002-06-25 15:50 Mark Butcher
  0 siblings, 0 replies; only message in thread
From: Mark Butcher @ 2002-06-25 15:50 UTC (permalink / raw)
  To: gcc; +Cc: gcc-help

# Script file to build the c and c++ compiler for the following processor:
MCORE-ELF

# Requirements:
# Windows PC with cygwin installed (options gcc and binutils must have been
installed - not default !)
#  Newest version of binutils (eg. binutils-2.12)
#  Newest version of the gcc compiler (full edition) (eg. gcc-3.1)
#  Newest version of Newlib (eg. newlib-1.10.0)

# Where to put the things
# Use the following directory structure
#  cygwin/usr/local/src/gnu - /src/gnu will have to be created by yourself
#  put the sources in cygwin/tmp (eg. gcc-3.1.tar.gz [compressed archive])

# This script doesn't expand the sources so do this before starting as
follows:
# Change to the directory cygwin/usr/local/src/gnu in the cygwin bash shell
- this can be done by
#   starting the cygwin application and typing cd /usr/local/src/gnu or
else by setting a path to our source
#   directory and using a short-cut [type "src_root=/usr/local/src/gnu" and
afterwards "cd $src_root"]
# Expand the sources to our source directory using
#   tar zxf /tmp/gcc-3.1.tar.gz
#   tar zxf /tmp/binutils-2.12.tar.gz
# and
#   tar zxf /tmp/newlib-1.10.0.tar.gz
#
# After the expansion and extraction has completed, the sources will appear
as directories in our 
# source root directory (cygwin/usr/local/src/gnu or $src_root)

# Once the sources are in place the build of the tools, the libraries and
finally the compilers can begin
# In the source root directory ($src_root) the required steps can be
started by running this script


# Step 1: Compile the tools required for building a basic compiler for the
target (newest version of binutils especially for the targt)
# Step 2: Build a simple compiler for the target without any libraries
# Step 3: Build C libraries (newlib). The simple compiler created in step 2
is used here
# Step 4: Build the final compilers. This requires the libraries from step
3, which were build with the simple compiler which didn't


# Run the build(s) with "./build-mcore.sh" from the $src_root




# 0. Set up some environment variables to simplify the commands
HOST=i686-pc-cygwin
BUILD=i686-pc-cygwin
TARGET=mcore-elf
PREFIX=/usr/local
SRC_ROOT=/usr/local/src/gnu

BINUTILS=binutils-2.12
GCCVERSION=gcc-3.1
LIBVERSION=newlib-1.10.0

# 00. Create the BUILD directory with the required sub directories
echo
echo Creating directories:
echo "    ${PREFIX}/${TARGET}"
echo "    ${SRC_ROOT}/BUILD/binutils"
echo "    ${SRC_ROOT}/BUILD/gcc"
echo "    ${SRC_ROOT}/BUILD/newlib"

mkdir -p ${PREFIX}/${TARGET}
mkdir -p ${SRC_ROOT}/BUILD/binutils
mkdir -p ${SRC_ROOT}/BUILD/littlegcc
mkdir -p ${SRC_ROOT}/BUILD/gcc
mkdir -p ${SRC_ROOT}/BUILD/newlib






# 1. Build the binutils (for our target)
echo Moving to directory:
echo "    ${SRC_ROOT}/BUILD/binutils"

echo Configuring for:
echo "    --target=${TARGET} --host=${HOST} --build=${BUILD}"


cd ${SRC_ROOT}/BUILD/binutils
${SRC_ROOT}/${BINUTILS}/configure \
    --with-included-gettext \
    --target=${TARGET} --host=${HOST} --build=${BUILD} \
    --prefix=${PREFIX} -v > config.log 2>&1

echo Now making binutils:

make > make.log 2>&1

echo Now Installing binutils:

make install > install.log 2>&1


echo Adding path:
echo "    ${PREFIX}/bin:${PATH}"
  
export PATH=${PREFIX}/bin:${PATH}

# A number of tools have now been prepared and have been installed for use
by subsequent steps
# in the directory ${PREFIX}/bin (/usr/local/bin)
# These tools include assembler, linker and others -
#   mcore-elf-addr2line.exe
#   mcore-elf-ar.exe
#   mcore-elf-as.exe
#   mcore-elf-c++filt.exe
#   mcore-elf-dlltool.exe
#   mcore-elf-gasp.exe
#   mcore-elf-ld.exe
#   mcore-elf-nm.exe
#   mcore-elf-objcopy.exe
#   mcore-elf-objdump.exe
#   mcore-elf-ranlib.exe
#   mcore-elf-readelf.exe
#   mcore-elf-size.exe
#   mcore-elf-strings.exe
#   mcore-elf-strip.exe




# 2. Build a simple c compiler (for our target)
echo Moving to directory:
echo "    ${SRC_ROOT}/BUILD/littlegcc"

echo Configuring for:
echo "    --target=${TARGET} --host=${HOST} --build=${BUILD}"

cd ${SRC_ROOT}/BUILD/littlegcc
${SRC_ROOT}/${GCCVERSION}/configure \
        --target=${TARGET} --host=${HOST} --prefix=${PREFIX} \
        --enable-languages=c \
        --without-headers --with-newlib --disable-shared
--with-local-prefix=${PREFIX}/${TARGET} -v \
        > config.log 2>&1

echo Building simple c-compiler:

make > make.log 2>&1

echo Installing simple c-compiler:

make install > install.log 2>&1


# In the directory ${PREFIX}/bin (/usr/local/bin)
# are now additionally the following tools

#   mcore-elf-cpp.exe
#   mcore-elf-gcc.exe
#   mcore-elf-gccbug
#   mcore-elf-gcov.exe






# 3. Build the C-libraries (for our target) which will be required for
building the full-blown compiler
echo Moving to directory:
echo "    ${SRC_ROOT}/BUILD/newlib"
cd ${SRC_ROOT}/BUILD/newlib

echo Configuring for:
echo "    --target=${TARGET} --host=${HOST} --build=${BUILD}"

${SRC_ROOT}/${LIBVERSION}/configure \
        --target=${TARGET} --host=${HOST} --build=${BUILD}
--prefix=${PREFIX} -v \
        > config.log 2>&1

echo Building NewLib:

make > make.log 2>&1

echo Installing NewLib:

make install > install.log 2>&1






# 4. Build the full-blown compiler (for our target)
echo Moving to directory:
echo "    ${SRC_ROOT}/BUILD/gcc"
cd ${SRC_ROOT}/BUILD/gcc

echo Configuring for:
echo "    --target=${TARGET} --host=${HOST} --build=${BUILD}"

${SRC_ROOT}/${GCCVERSION}/configure \
        --target=${TARGET} --host=${HOST} --build=${BUILD}
--prefix=${PREFIX} \
        --enable-languages=c,c++ --with-newlib
--with-local-prefix=${PREFIX}/${TARGET} -v \
        > config.log 2>&1

echo Building Full GCC:

make > make.log 2>&1

echo Installing Full GCC:

make install > install.log 2>&1

exit

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-06-25 22:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-25 15:50 Tutorial 4 - Mcore script Mark Butcher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).