#!/bin/bash # install cross-binutils and cross-egcs, glibc-2.0.7 SRPMs from SGI FTP # into SOURCEDIR # put kernel source into KERNELSRC (or uncomment below to install it) # this process requires 400-500MB of free space, including source, intermediate # build, and installed files. # note that BUIDLROOT is wiped out at the beginning of this script. also note # that it is left at the end. it can be safely deleted afterwards, otherwise # you'll be wasting several hundreds of MB of storage space. BUILDROOT=~/cdtest/cross-devtools-build SOURCEDIR=~/cdtest/source # This is the prefix for the HOST system, the one cross-build tools will run on # the user running this script must have write permissions to this dir (which # usually means being root if it's /usr or /usr/local) PREFIX=~/cdtest/install # This is the prefix on the TARGET system, usually /usr TPREFIX=/usr # TARGET is mips-linux for big endian, mipsel-linux for little endian TARGET=mips-linux KERNELARCH=mips KERNELCONF=$BUILDROOT/linux/arch/mips/defconfig-vr KERNELSRC=~/cdtest/source/linux rm -rf $BUILDROOT mkdir -p $BUILDROOT # Note: the '|| exit 1's just mean "abort on error", # otherwise the script will try to go on ... echo --- Building binutils for $TARGET --- cd $BUILDROOT gzip -dc $SOURCEDIR/binutils-2.8.1.tar.gz | tar xf - || exit 1 cd binutils-2.8.1 patch -p1 < $SOURCEDIR/binutils-2.8.1-mips.patch || exit 1 mkdir build cd build ../configure --prefix=$PREFIX --target=$TARGET || exit 1 make || exit 1 make install || exit 1 echo --- Building first egcs for $TARGET --- cd $BUILDROOT bzip2 -dc $SOURCEDIR/egcs-1.0.3a.tar.bz2 | tar xf - || exit 1 cd egcs-1.0.3a patch -p1 < $SOURCEDIR/egcs-1.0.3a-mips.patch || exit 1 patch -p1 < $SOURCEDIR/egcs-1.0.3a-sgidefs.patch || exit 1 mkdir build1 cd build1 ../configure --prefix=$PREFIX --program-prefix=$PREFIX/bin/$TARGET- \ --with-newlib --target=$TARGET || exit 1 make SUBDIRS="libiberty texinfo gcc" ALL_TARGET_MODULES= \ CONFIGURE_TARGET_MODULES= INSTALL_TARGET_MODULES= LANGUAGES="c" \ || exit 1 make SUBDIRS="libiberty texinfo gcc" INSTALL_TARGET_MODULES= \ LANGUAGES="c" install || exit 1 echo --- Configuring kernel build --- #mkdir -p $KERNELSRC #cd $KERNELSRC/.. #bzip2 -dc $SOURCEDIR/linux-2.3.99-pre3.tar.bz2 | tar xf - || exit 1 #cd linux #patch -p1 < $SOURCEDIR/linux-2.3.99-pre3-linux-mips || exit 1 #patch -p1 < $SOURCEDIR/linux-2.3.99-pre3-linux-vr || exit 1 ## TBD: if $KERSELSRC isn't [something]/linux, need to mv it cd $KERNELSRC cp -f $KERNELCONF .config make ARCH=$KERNELARCH oldconfig || exit 1 make ARCH=$KERNELARCH CROSS_COMPILE=$PREFIX/bin/$TARGET- dep || exit 1 # This doesn't really need to succeed, it mostly just needs to generate # some header files, but it's a good test of the cross-compiler make ARCH=$KERNELARCH CROSS_COMPILE=$PREFIX/bin/$TARGET- || exit 1 echo --- Setting up kernel include headers for $TARGET --- mkdir -p $PREFIX/$TARGET/include rm -rf $PREFIX/$TARGET/include/asm rm -rf $PREFIX/$TARGET/include/linux ln -s $KERNELSRC/include/asm-$KERNELARCH $PREFIX/$TARGET/include/asm ln -s $KERNELSRC/include/linux $PREFIX/$TARGET/include/linux echo --- Building glibc for $TARGET --- cd $BUILDROOT gzip -dc $SOURCEDIR/glibc-2.0.7-980711.tar.gz | tar xf - || exit 1 cd glibc-2.0.7 gzip -dc $SOURCEDIR/glibc-crypt-2.0.6.tar.gz | tar xf - || exit 1 gzip -dc $SOURCEDIR/glibc-localedata-2.0.7pre3.tar.gz | tar xf - || exit 1 gzip -dc $SOURCEDIR/glibc-linuxthreads-2.0.7pre5.tar.gz | tar xf - || exit 1 patch -p1 < $SOURCEDIR/glibc-2.0.7-preload.patch || exit 1 patch -p1 < $SOURCEDIR/glibc-2.0.7-localedata.patch || exit 1 patch -p1 < $SOURCEDIR/glibc-2.0.7-misc.patch || exit 1 patch -p1 < $SOURCEDIR/glibc-2.0.7-tz.patch || exit 1 patch -p1 < $SOURCEDIR/glibc-2.0.7-gafton.patch || exit 1 # some chunks of this next patch do fail, just let them... patch -p1 -f < $SOURCEDIR/glibc-2.0.7-mips.patch patch -p1 < $SOURCEDIR/glibc-2.0.7-mips2.patch || exit 1 patch -p1 < $SOURCEDIR/glibc-2.0.7-mips_from_2.0.6.patch || exit 1 mkdir build cd build CC=$PREFIX/bin/$TARGET-gcc \ ../configure --prefix=$TPREFIX $TARGET \ --enable-add-ons=crypt,linuxthreads,localedata --enable-profile || exit 1 echo CC=$PREFIX/bin/$TARGET-gcc > configparms echo BUILD_CC=gcc >> configparms echo AR=$PREFIX/bin/$TARGET-ar >> configparms echo RANLIB=$PREFIX/bin/$TARGET-ranlib >> configparms make || exit 1 # This overrides first few lines of build/make.config to install to right place: make prefix=$PREFIX exec_prefix=$PREFIX/$TARGET slibdir=$PREFIX/$TARGET/lib \ sysconfdir=$PREFIX/etc rootsbindir=$PREFIX/$TARGET/sbin install || exit 1 echo --- Building final egcs for $TARGET --- cd $BUILDROOT/egcs-1.0.3a mkdir build2 cd build2 ../configure --prefix=$PREFIX --program-prefix=$PREFIX/bin/$TARGET- \ --target=$TARGET || exit 1 make LANGUAGES="c c++" || exit 1 make LANGUAGES="c c++" install || exit 1