function print_help {
	echo ""
	echo "Prepare environment for perinet-based yocto builds."
	echo ""
	echo "Usage:"
	echo "source perinet-init-build-env <build_dir>"
	echo ""
	echo "<build_dir> is optional. If not specified it defaults to 'build'."
	echo ""
}

function print_config {
	echo "Configuration:"
	echo "    MACHINE:   $1"
	echo "    BUILD_DIR: $2"
}


DEFAULT_MACHINE=genericx86-64
BUILD_DIR=build

#print_help

if [ -z "$MACHINE" ]; then
	MACH=$DEFAULT_MACHINE
else
	MACH=$MACHINE
fi

unset MACHINE

if [ $# -eq "1" ]; then
	BUILD_DIR=$1
fi

print_config $MACH $BUILD_DIR

rm -f	build/conf/bblayers.conf \
	build/conf/templateconf.cfg

mkdir -p $BUILD_DIR

export MACHINE=$MACH
export TEMPLATECONF="../meta-perinet/buildconf/$MACHINE"

source layers/poky/oe-init-build-env $BUILD_DIR

return 0