#!/bin/sh

VERSION=0.3
BUILDDIR=`pwd`/pistachio_dist
PROJ=pistachio

if [ ! -x $BUILDDIR ] ; then mkdir $BUILDDIR; fi
cd $BUILDDIR || exit 1

## Export the kernel.
echo "Pulling latest sources from CVS ..."
rm -rf $PROJ
cvs -d i30pc20.ira.uka.de:/home/cvs export -r public $PROJ
cd $PROJ || exit 1

#tools/stripcpp -UCONFIG_DEBUGGER_NEW_KDB `find kernel -type f | xargs grep -l CONFIG_DEBUGGER_NEW_KDB | grep -v xconfig`
#tools/stripcpp -UCONFIG_SMP `find kernel -type f | xargs grep -l CONFIG_SMP | grep -v xconfig`
#tools/stripcpp -UCONFIG_IPC_FASTPATH `find kernel -type f | xargs grep -l CONFIG_IPC_FASTPATH | grep -v xconfig`

echo "Removing .cvsignore files ..."
find . -name .cvsignore | xargs rm

echo "Cleaning up tools directory ..."
rm -rf tools/{*license,makel4kadist,pushl4hq,stripcpp}

echo "Running auto* stuff ..."
cd user && autoheader && autoconf && cd .. || exit -1

echo "Cleaning up user directory ..."
rm -f user/README.CVS
rm -rf user/autom4te.cache

echo "Tarring up ..."
cd $BUILDDIR && \
mv pistachio pistachio-$VERSION && \
tar cjvf pistachio-${VERSION}.tar.bz2 pistachio-$VERSION
