2020-09-18 18:17:02 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
TMPDIR="$(mktemp -d -t tor_lib_combining.XXXXXX)"
|
|
|
|
ORIGDIR="$(pwd)"
|
|
|
|
|
|
|
|
trap 'cd "$ORIGDIR" && rm -rf "$TMPDIR"' 0
|
|
|
|
|
|
|
|
abspath() {
|
2021-08-14 21:45:44 +02:00
|
|
|
echo "$(cd "$(dirname "$1")" >/dev/null && pwd)/$(basename "$1")"
|
2020-09-18 18:17:02 +02:00
|
|
|
}
|
|
|
|
|
2022-10-14 12:12:46 +02:00
|
|
|
apple_symdef_fix() {
|
|
|
|
# On modern macOS and iOS we need to remove the "__.SYMDEF" and "__.SYMDEF
|
|
|
|
# SORTED" before we repack the archive.
|
|
|
|
# See: tor#40683.
|
|
|
|
if [ "$(uname -s)" = "Darwin" ] ; then
|
|
|
|
find . -name "__.SYMDEF*" -delete
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-09-18 18:17:02 +02:00
|
|
|
TARGET=$(abspath "$1")
|
|
|
|
|
|
|
|
shift
|
|
|
|
|
|
|
|
for input in "$@"; do
|
|
|
|
cd "$ORIGDIR"
|
|
|
|
abs=$(abspath "$input")
|
|
|
|
dir="$TMPDIR"/$(basename "$input" .a)
|
|
|
|
mkdir "$dir"
|
2021-08-14 21:45:44 +02:00
|
|
|
cd "$dir" >/dev/null
|
2021-04-16 15:17:43 +02:00
|
|
|
"${AR:-ar}" x "$abs"
|
2020-09-18 18:17:02 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
cd "$TMPDIR" >/dev/null
|
2022-10-14 12:12:46 +02:00
|
|
|
apple_symdef_fix
|
2020-09-18 18:17:02 +02:00
|
|
|
"${AR:-ar}" "${ARFLAGS:-cru}" library.tmp.a ./*/**
|
|
|
|
"${RANLIB:-ranlib}" library.tmp.a
|
|
|
|
mv -f library.tmp.a "$TARGET"
|