#!/bin/sh
set -eu
here=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
if test -x "$here/scope-local"; then exec "$here/scope-local" "$@"; fi
for dir in "${SCOPE_MERCURY_LIBDIR:-}" "$here/../.runtime/usr/lib/mercury/lib" /usr/lib/mercury/lib /usr/local/lib/mercury/lib; do
    if test -n "$dir" && test -f "$dir/hlc.gc/libmer_std.so"; then
        LD_LIBRARY_PATH="$dir/hlc.gc:$dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
        export LD_LIBRARY_PATH
        exec "$here/scope-linux-x86_64" "$@"
    fi
done
echo 'scope: run make runtime on Debian 13 amd64, or make build with the Mercury compiler.' >&2
exit 2
