#!/bin/sh

set -e

readonly wrkdir="$(mktemp -d /tmp/nsnake-XXXXXX)"
readonly repo="http://hg.malikania.fr/nsnake"

trap "cleanup" INT TERM EXIT

cleanup()
{
	rm -rf $wrkdir
}

if [ "$#" -ne 1 ]; then
	echo "abort: $(basename $0) revision" 1>&2
	exit 1
fi

echo "=> Cloning repository $repo (revision $1) into $wrkdir"
hg clone -r "$1" "$repo" "$wrkdir"
cd "$wrkdir"

echo "=> Building"
make
