macOS: make openconnect relocatable; drive installation through make install (#668)

Co-authored-by: Kevin Yue <[email protected]>
This commit is contained in:
Ihar HrachyshkaandKevin Yue authored and GitHub committed 2026-10-12 10:12:17 +08:00
1 parent f7649898fd
commit f9965f8a35
12 files changed
+427 -162

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
# Resolve the library used by this build, rather than choosing a stale Cargo output.
set -eu
binary=$1
library=$(otool -L "$binary" | awk '/^[[:space:]]+@rpath\/libopenconnect\..*\.dylib / { sub("@rpath/", "", $1); print $1 }')
test -n "$library" || { echo "No OpenConnect dependency in $binary" >&2; exit 1; }
rpaths=$(otool -l "$binary" | awk '/cmd LC_RPATH/ { rpath=1; next } rpath && $1 == "path" { sub(/^[[:space:]]*path /, ""); sub(/ \(offset [0-9]+\)$/, ""); print; rpath=0 }')
while IFS= read -r directory; do
case "$directory" in /*) ;; *) continue ;; esac
if [ -f "$directory/$library" ]; then
printf '%s\n' "$directory/$library"
exit 0
fi
done <<EOF
$rpaths
EOF
echo "Cannot resolve the OpenConnect build library for $binary" >&2
exit 1