src="">
obj=$top/obj
tools=$top/tools
sysroot=$top/sysroot
# Compile binutils
mkdir -p $obj/binutils1
cd $obj/binutils1
$src/$binutilsv/configure --target=$target --prefix=$tools --with-sysroot=$sysroot
make
make install
# Compile gcc-minimal
mkdir -p $obj/gcc1
cd $obj/gcc1
#$src/$gccv/contrib/download_prerequisites
#$src/$gccv/configure --target=$target --prefix=$tools --with-sysroot=$sysroot --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --disable-decimal-float --disable-libffi --disable-libquadmath --disable-libgcc --disable-zlib --disable-libiberty --enable-languages=c
#$src/$gccv/configure --target=$target --prefix=$tools --with-sysroot=$sysroot --without-headers --with-newlib --disable-shared --disable-threads --enable-languages=c
$src/$gccv/configure --target=$target --prefix=$tools --with-sysroot=$sysroot --without-headers --with-newlib --disable-shared --disable-threads --disable-libgcc --disable-libssp --disable-libmudflap --disable-libgomp --disable-libquadmath --enable-languages=c
PATH=$tools/bin:$PATH make
PATH=$tools/bin:$PATH make install
# Copy kernel headers
ln -s $src/$linuxv $obj/linux
cd $obj/linux
PATH=$tools/bin:$PATH make headers_install ARCH=$linux_arch CROSS_COMPILE=$target- INSTALL_HDR_PATH=$sysroot/usr
# Build eglibc-minimal for cross gcc-minimal
mkdir -p $obj/eglibc-headers
cd $obj/eglibc-headers
BUILD_CC=gcc CC=$tools/bin/$target-gcc CXX=$tools/bin/$target-g++ AR=$tools/bin/$target-ar RANLIB=$tools/bin/$target-ranlib $src/libc/configure --prefix=/usr --with-headers=$sysroot/usr/include --build=$build --host=$target --disable-profile --without-gd --without-cvs --enable-add-ons
make install-headers install_root=$sysroot install-bootstrap-headers=yes
# Build shared object eglibc files
mkdir -p $sysroot/usr/lib
make csu/subdir_lib
cp csu/crt1.o csu/crti.o csu/crtn.o $sysroot/usr/lib
$tools/bin/$target-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $sysroot/usr/lib/libc.so
# Compile second stage gcc with eglibc-minimal
mkdir -p $obj/gcc2
cd $obj/gcc2
#$src/$gccv/configure --target=$target --prefix=$tools --with-sysroot=$sysroot --disable-libssp --disable-libgomp --disable-libmudflap --disable-libquadmath --enable-languages=c
$src/$gccv/configure --target=$target --prefix=$tools --with-sysroot=$sysroot --disable-libssp --disable-libmudflap --disable-libgomp --disable-libquadmath --enable-languages=c
PATH=$tools/bin:$PATH make
PATH=$tools/bin:$PATH make install
# Compile gperf
mkdir -p $obj/gperf
cd $obj/gperf
$src/$gperfv/configure --prefix=$tools
PATH=$tools/bin:$PATH make
PATH=$tools/bin:$PATH make install
# Compile full eglibc
mkdir -p $obj/eglibc
cd $obj/eglibc
BUILD_CC=gcc CC=$tools/bin/$target-gcc CXX=$tools/bin/$target-g++ AR=$tools/bin/$target-ar RANLIB=$tools/bin/$target-ranlib $src/libc/configure --build=$build --host=$target --prefix=/usr --with-headers=$sysroot/usr/include --without-gd --without-cvs --enable-add-ons
PATH=$tools/bin:$PATH make
PATH=$tools/bin:$PATH make install install_root=$sysroot
# Compile full gcc
mkdir -p $obj/gcc3
cd $obj/gcc3
$src/$gccv/contrib/download_prerequisites
#$src/$gccv/configure --target=$target --prefix=$tools --with-sysroot=$sysroot --disable-libssp --disable-libgomp --disable-libmudflap --disable-libquadmath --enable-languages=c,c++
$src/$gccv/configure --target=$target --prefix=$tools --with-sysroot=$sysroot --enable-languages=$languages
PATH=$tools/bin:$PATH make
PATH=$tools/bin:$PATH make install
# Build sysroot tree
cp -d $tools/$target/lib/libgcc_s.so* $sysroot/lib
cp -d $tools/$target/lib/libstdc++.so* $sysroot/usr/lib
# Test the cross compiler
cd $obj
cat > c++-hello.cc <<EOF
#include <iostream>
int
main (int argc, char **argv)
{
std::cout << "Hello, C++ world!" << std::endl;
return 0;
}
EOF
$tools/bin/$target-g++ -Wall c++-hello.cc -o c++-hello
$tools/bin/$target-readelf -hl c++-hello >hello-cross-elf.txt
$tools/bin/$target-readelf -d $sysroot/lib/libgcc_s.so.1 >libgcc-cross-elf.txt
# Compile canadian binutils
mkdir -p $obj/binutils2
cd $obj/binutils2
$src/$binutilsv/configure --target=$target --host=$target --prefix=$sysroot/usr --with-sysroot=$sysroot
PATH=$tools/bin:$PATH make
PATH=$tools/bin:$PATH make install
# Compile canadian gcc
mkdir -p $obj/gcc4
cd $obj/gcc4
$src/$gccv/contrib/download_prerequisites
cd $obj/gcc4/gmp
./configure --host=$target --prefix=$tools/usr
make
make install
cd $obj/gcc4/mpfr
./configure --host=$target --with-gmp=$tools/usr --prefix=$tools/usr
make
make install
cd $obj/gcc4/mpc
./configure --host=$target --with-gmp=$tools/usr --with-mpfr=$tools/usr --prefix=$tools/usr
make
make install
cd $obj/gcc4
CC=$tools/bin/$target-gcc CXX=$tools/bin/$target-g++ AR=$tools/bin/$target-ar RANLIB=$tools/bin/$target-ranlib $src/$gccv/configure --build=$build --target=$target --host=$target --prefix=$sysroot/usr --with-sysroot=$sysroot --enable-languages=$languages --with-gmp=$tools/usr --with-mpfr=$tools/usr --with-mpc=$tools/usr
PATH=$tools/bin:$PATH make
PATH=$tools/bin:$PATH make install