#!/bin/sh

. config/options $1

setup_toolchain host
CC=$LOCAL_CC

cd $PKG_BUILD
./configure --host=$HOST_NAME \
            --build=$HOST_NAME \
            --prefix=$ROOT/$TOOLCHAIN
make

mkdir -p $ROOT/$TOOLCHAIN/bin
  cp -f ccache $ROOT/$TOOLCHAIN/bin

cat > $HOST_CC <<EOF
#!/bin/sh
$ROOT/$TOOLCHAIN/bin/ccache $LOCAL_CC "\$@"
EOF
chmod +x $HOST_CC

cat > $HOST_CXX <<EOF
#!/bin/sh
$ROOT/$TOOLCHAIN/bin/ccache $LOCAL_CXX "\$@"
EOF
chmod +x $HOST_CXX
