#!/bin/sh
set -eu
base=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
# The system's loader when it resolves every library (with the system's OpenGL drivers); else the bundled one.
if [ -z "${NN_DOSBOX_BUNDLED_ONLY:-}" ] && [ -x /lib/ld-linux-armhf.so.3 ] &&
   ! /lib/ld-linux-armhf.so.3 --library-path "$base/lib" --list "$base/bin/dosbox-x" 2>&1 | grep -q -e 'not found' -e 'No such file'; then
    exec /lib/ld-linux-armhf.so.3 --library-path "$base/lib" "$base/bin/dosbox-x" -conf "$base/portable.conf" "$@"
fi
exec "$base/lib/core/ld-linux-armhf.so.3" --library-path "$base/lib:$base/lib/core" "$base/bin/dosbox-x" -conf "$base/portable.conf" "$@"
