2022-10-17 20:45:32 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-06-09 16:32:36 +03:00
|
|
|
if test -z "$TEA_PREFIX"
|
|
|
|
then
|
|
|
|
echo 'TEA_PREFIX mysteriously unset' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-11-09 21:26:10 +03:00
|
|
|
dir=$(dirname "$0")
|
2022-10-27 03:29:40 +03:00
|
|
|
exe=$(basename "$0")
|
2022-10-17 20:45:32 +03:00
|
|
|
|
2022-11-09 21:26:10 +03:00
|
|
|
# Remove us from our path
|
|
|
|
PATH=$(echo "$PATH" | tr ":" "\n" | grep -v "$dir" | tr "\n" ":")
|
2023-06-09 16:32:36 +03:00
|
|
|
PATH=$(echo "$PATH" | tr ":" "\n" | grep -v "$TEA_PREFIX/.local/bin" | tr "\n" ":")
|
2022-11-09 21:26:10 +03:00
|
|
|
|
|
|
|
# If we can find our specific name, e.g. `lld`,
|
|
|
|
# passthrough to that
|
2022-11-11 01:18:57 +03:00
|
|
|
if which "$exe" >/dev/null 2>&1; then
|
2022-11-09 21:26:10 +03:00
|
|
|
exe=$(which "$exe")
|
|
|
|
# Otherwise, fallback to `ld`
|
|
|
|
# NB: this might not have the right invocations, sometimes;
|
|
|
|
# (invoking `ld` as `lld64.ld`) watch for those potential cases
|
2022-11-11 01:18:57 +03:00
|
|
|
elif which ld >/dev/null 2>&1; then
|
2022-11-09 21:26:10 +03:00
|
|
|
exe=$(which ld)
|
2022-11-09 22:47:21 +03:00
|
|
|
else
|
|
|
|
echo 'ld not found in PATH' >&2
|
|
|
|
exit 127
|
2022-10-27 20:29:16 +03:00
|
|
|
fi
|
|
|
|
|
2023-06-09 16:32:36 +03:00
|
|
|
# At a minimum, `ld` will complain if you mix the `-r` and `-rpath` flags,
|
|
|
|
# so if any argument to this script is `-r`, we just pass through without
|
|
|
|
# additions.
|
|
|
|
for word in "$@"; do
|
|
|
|
if test "$word" = "-r"; then
|
|
|
|
exec "$exe" "$@"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
exec "$exe" "$@" -rpath "$TEA_PREFIX"
|