#!/bin/sh

srcdir='@abs_top_srcdir@'
builddir='@abs_top_builddir@'

rundir="${0%/*}"
[ "$rundir" = "$0" ] || builddir="$rundir"

# Absolutify the paths.
case "$srcdir" in
/*) ;;
*) srcdir=`cd "$srcdir" && pwd` || exit ;;
esac
case "$builddir" in
/*) ;;
*) builddir=`cd "$builddir" && pwd` || exit ;;
esac

# Set all the variables to find the source and build trees.
SYSTEMTAP_TAPSET="${srcdir}/tapset"
SYSTEMTAP_RUNTIME="${srcdir}/runtime"
SYSTEMTAP_STAPDYN="${builddir}/stapdyn/stapdyn"
SYSTEMTAP_STAPRUN="${builddir}/staprun/run-staprun"
export SYSTEMTAP_TAPSET SYSTEMTAP_RUNTIME SYSTEMTAP_STAPDYN SYSTEMTAP_STAPRUN

if [ -z "$DEBUG_STAP" ]; then
    exec "${builddir}/stap" ${1+"$@"}
else
    exec ${GDB:-gdb} --args "${builddir}/stap" ${1+"$@"}
fi
