#!/bin/sh

basedir=$(dirname "$0")

add_LD_LIBRARY_PATH() {
  if test -z "$LD_LIBRARY_PATH"
  then
    LD_LIBRARY_PATH="$1"
  else
    LD_LIBRARY_PATH="$1:$LD_LIBRARY_PATH"
  fi
}

# Check if the system has a more recent version of libstdc++.so.6; if yes, use
# that instead of the bundled version.
"$basedir/abicheck" >/dev/null 2>&1
if [ $? -ne 0 ]; then
  add_LD_LIBRARY_PATH "$basedir/[% IF c("var/tor-browser") -%]TorBrowser/Tor/[% END -%]libstdc++/"
fi
export LD_LIBRARY_PATH

exec "$basedir/[% c("var/exe_name") %].real" "$@"
