#!/bin/sh

SELF=$(readlink -f "$0")
SCRIPTS=$(dirname "$SELF")
SOURCE=$(dirname "$SCRIPTS")
SBUILD=$(pwd)
BUILD=$(readlink -f "$SBUILD")

if [ -d "$1" ]
then
	SOURCE="$1"
fi

if [ "$SOURCE" = "$BUILD" ]
then
	echo "In source builds are not allowed, create a new directory and run $SELF there"
	exit 1
fi

if [ "$SCRIPTS" = "$BUILD" ]
then
	echo "You seem to be in the scripts directory, create a new directory and run $SELF there"
	exit 1
fi

cd $BUILD

XDG_RESOLVER="resolver_mf_xp_x"

cmake  -DPLUGINS="resolver;$XDG_RESOLVER;dump;sync" \
       -DKDB_DEFAULT_RESOLVER="$XDG_RESOLVER" \
       $SOURCE
