2014-06-27 09:15:28 +00:00
|
|
|
# This setup hook calls patchelf to automatically remove unneeded
|
|
|
|
# directories from the RPATH of every library or executable in every
|
|
|
|
# output.
|
|
|
|
|
2019-10-30 14:40:07 +00:00
|
|
|
fixupOutputHooks+=('if [ -z "${dontPatchELF-}" ]; then patchELF "$prefix"; fi')
|
2014-06-27 09:15:28 +00:00
|
|
|
|
|
|
|
patchELF() {
|
2016-02-24 10:13:36 +00:00
|
|
|
local dir="$1"
|
2016-05-12 10:18:59 +00:00
|
|
|
[ -e "$dir" ] || return 0
|
|
|
|
|
2023-01-15 22:08:12 +00:00
|
|
|
echo "shrinking RPATHs of ELF executables and libraries in $dir"
|
2016-02-18 21:52:44 +00:00
|
|
|
|
|
|
|
local i
|
|
|
|
while IFS= read -r -d $'\0' i; do
|
|
|
|
if [[ "$i" =~ .build-id ]]; then continue; fi
|
|
|
|
if ! isELF "$i"; then continue; fi
|
|
|
|
echo "shrinking $i"
|
|
|
|
patchelf --shrink-rpath "$i" || true
|
2016-02-24 10:13:36 +00:00
|
|
|
done < <(find "$dir" -type f -print0)
|
2014-06-27 09:15:28 +00:00
|
|
|
}
|