#!/bin/sh # # This script builds a Xtoolchain crosscompiler package # # useage: build.sh processor languages gcc-version libc-version [ headers-version ] # # To use it you must install Darwinports-1.1 (or later) # # Copyright by H. N. Schaller, Jan 2006 # XTOOL=crosstool-0.42 export HERE=$PWD if [ "$5" = "" ] then HDRS="" else HDRS="-hdrs-$5" fi export TARGET=$1 export GCC_LANGUAGES="$2" export GCC_VERSION="$3" export GLIBC_VERSION="$4" export BUILD_GDIR="gcc-$GCC_VERSION-glibc-$GLIBC_VERSION" export BUILD_CONF="$BUILD_GDIR$HDRS" export RESULT_TOP="/opt/local/crosstool" export RESULT_TARGET=$RESULT_TOP/$BUILD_GDIR/$TARGET export TARBALLS_DIR="$HERE/downloads" echo Building $XBUILD_NAME. date set -e export PATH=$HERE/gnutools:/opt/local/bin:$RESULT_TOP/tools:$PATH # make us find wget etc. # allow to fetch files from the online-repositories [ -r /opt/local/bin/wget ] || sudo /opt/local/bin/port install wget || exit 1 mkdir -p $HERE/gnutools $TARBALLS_DIR sudo mkdir -p $RESULT_TOP sudo chown $USER $RESULT_TOP # install GNU tools and override through $PATH [ -r gnutools/awk ] || ( sudo /opt/local/bin/port install gawk && ln -s /opt/local/bin/gawk gnutools/awk ) [ -r gnutools/sed ] || ( sudo /opt/local/bin/port install gsed && ln -s /opt/local/bin/gnused gnutools/sed ) [ -r gnutools/make ] || ( sudo /opt/local/bin/port install gmake && ln -s /opt/local/bin/gmake gnutools/make ) # /usr/bin/make has builtin-rule for .m.c: which conflicts with the sources of gprof [ -r /opt/local/bin/msgfmt ] || sudo /opt/local/bin/port install gettext [ -r gnutools/install ] || ( sudo /opt/local/bin/port install coreutils && ln -s /opt/local/bin/ginstall gnutools/install ) echo awk is: $(which awk) echo sed is: $(which sed) echo make is: $(which make) # wrap Xcode as & ld so that they pretend to be the minimum required binutils echo '[ "$1" = -v ] && echo GNU assembler 2.15 || /usr/bin/as $*' >gnutools/as echo '[ "$1" = --version ] && echo GNU ld 2.15 || /usr/bin/ld $*' >gnutools/ld chmod a+x gnutools/as chmod a+x gnutools/ld [ -r $TARBALLS_DIR/$XTOOL.tar.gz ] || wget -P $TARBALLS_DIR http://kegel.com/crosstool/$XTOOL.tar.gz [ -r $XTOOL ] || tar -xzvf $TARBALLS_DIR/$XTOOL.tar.gz # Local hack for buillding a armv5b target brokentarg="armv5b-softfloat-linux" [ $TARGET == $brokentarg -a ! -r $XTOOL/$brokentarg.dat ] \ && mv $XTOOL/armv5b-softfloat.dat $XTOOL/$brokentarg.dat || true ( cd $XTOOL # Build the toolchain. Takes a couple hours and a couple gigabytes - no not really that long and large. eval `cat $TARGET.dat $BUILD_CONF.dat` sh all.sh --notest file $RESULT_TARGET/tmp/* printf '#include \nint main() { printf("Hello World! %lf", 3.0*5.0); }\n' >test.c $RESULT_TARGET/$TARGET/bin/gcc test.c ls -l a.out file a.out printf '#include \nusing namespace std; int main() { cout << "Hello World!\\n"; return 0; }\n' >test.cpp $RESULT_TARGET/$TARGET/bin/gcc test.cpp -lstdc++ ls -l a.out file a.out )