This directory contains source code of cross compiler tool-chain.
The following verisions we used:
GCC 4.1.2
Binutils 2.17
Newlib 1.15.0
Directory Structure
===================
README: This document
build.script: Toolchain building script, use --help to get help information.
src/: Source code directory
binutils/: Symbolic link to binutils' source directory
gcc/: Symbolic link to gcc's source directory
Toolchain building steps:(gcc 4.1.2, binutils 2.17, newlib 1.15.0)
Step 1: Fecth source from the internet
You can use following commands to get the source code.
wget ftp://ftp.gnu.org/pub/gnu/binutils/binutils-2.17.tar.bz2
wget ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.1.2/gcc-4.1.2.tar.bz2
wget ftp://sourceware.org/pub/newlib/newlib-1.15.0.tar.gz
Step 2: Uncompress tarball
You can use following commands to uncompress source code tarball.
cd src
tar zxvf filename.gz or tar jxvf filename.bz2
Step 3: Establish symbolic link for each feather under directory src.
ln -s gcc-4.1.2/ gcc
ln -s binutils-2.17 binutils
Step 4: Deal with newlib's related things...
When we compile gcc we will enable option '--with-newlib', we shall add two
symbolic link under gcc directory.
cd gcc
ln -s ../newlib-1.15.0/newlib newlib
ln -s ../newlib-1.15.0/libgloss libgloss
Step 5: Patch gcc's Makefile.in
If we don't modify the Makefile.in, error occurs when we compile newlib.
-CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+CFLAGS_FOR_TARGET = $(strip -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
-CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+CXXFLAGS_FOR_TARGET = $(strip $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
Step 6: Build the toolchain
It will cost 12 minutes for binutils and 3 and a half hours for gcc and newlib.
Of cource, it depends on your machine's speed.
./build.script
==build.script======================================================
# Parameter settings
LANG=en
export LANG
TARGET=mips-elf
PREFIX=/opt/mycrosstools/mips
PROJDIR=$PWD
CONFIGBINLOG=configbin.log
MAKEBINLOG=makebin.log
CONFIGGCCLOG=configgcc.log
MAKEGCCLOG=makegcc.log
mkdir -p tmp/build/binutils
mkdir -p tmp/build/gcc
echo "Building Binutils Starts..."
cd tmp/build/binutils
date>$MAKEBINLOG
$PROJDIR/src/binutils/configure --target=$TARGET --prefix=$PREFIX 2>&1|tee $CONFIGBINLOG
make all install 2>&1| tee $MAKEBINLOG
date>>$MAKEBINLOG
cd $PROJDIR/tmp/build/gcc
PATH=$PREFIX/bin:$PATH
export PATH
date>$MAKEGCCLOG
$PROJDIR/src/gcc/configure --target=$TARGET --prefix=$PREFIX --disable-shared --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-gxx-include-dir=$PREFIX/mips-elf/include 2>&1|tee $CONFIGGCCLOG
make all install 2>&1| tee $MAKEGCCLOG
date>>$MAKEGCCLOG
echo "DONE!!"
CORSS_COMPILE
最新推荐文章于 2024-11-05 10:30:00 发布