#!/bin/bash

cd $SOURCE_DIR
if [ ! -f binutils-$BINUTILS_VER.tar.bz2 ]; then
  wget http://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VER.tar.bz2
fi

cd $BUILD_DIR
rm -rf binutils-$BINUTILS_VER
tar -xf $SOURCE_DIR/binutils-$BINUTILS_VER.tar.bz2

rm -rf cross-binutils-build
mkdir -p cross-binutils-build
cd cross-binutils-build

../binutils-$BINUTILS_VER/configure \
  --prefix=$CROSS_DIR \
  --host=$HOST \
  --target=$TARGET \
  --with-sysroot=$HURD_DIR \
  --disable-nls

make all install

cd $ROOT
