#! /bin/sh
#
# BTest helper for getting values for Bro-related environment variables.

base=`dirname $0`
bro_dist=`cat ${base}/../../build/CMakeCache.txt | grep BRO_DIST | cut -d = -f 2`

if [ -n "${bro_dist}" ]; then
    if [ "$1" = "bropath" ]; then
        ${bro_dist}/build/bro-path-dev
    elif [ "$1" = "bro_plugin_path" ]; then
        ( cd ${base}/../.. && pwd )
    elif [ "$1" = "path" ]; then
        echo ${bro_dist}/build/src:${bro_dist}/aux/btest:${base}/:${bro_dist}/aux/bro-cut:$PATH
    else
        echo "usage: `basename $0` <var>" >&2
        exit 1
    fi
else
    # Use Bro installation for testing. In this case bro-config must be in PATH.
    if ! which bro-config >/dev/null; then
        echo "bro-config not found" >&2
        exit 1
    fi

    if [ "$1" = "bropath" ]; then
        bro-config --bropath
    elif [ "$1" = "bro_plugin_path" ]; then
        ( cd ${base}/../.. && pwd )
    elif [ "$1" = "path" ]; then
        echo ${PATH}
    else
        echo "usage: `basename $0` <var>" >&2
        exit 1
    fi
fi
