File: combine_libs

package info (click to toggle)
tor 0.4.8.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,852 kB
  • sloc: ansic: 314,750; sh: 7,388; python: 1,829; makefile: 620; perl: 249; pascal: 141
file content (40 lines) | stat: -rwxr-xr-x 847 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh

set -e

TMPDIR="$(mktemp -d -t tor_lib_combining.XXXXXX)"
ORIGDIR="$(pwd)"

trap 'cd "$ORIGDIR" && rm -rf "$TMPDIR"' 0

abspath() {
    echo "$(cd "$(dirname "$1")" >/dev/null && pwd)/$(basename "$1")"
}

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
}

TARGET=$(abspath "$1")

shift

for input in "$@"; do
    cd "$ORIGDIR"
    abs=$(abspath "$input")
    dir="$TMPDIR"/$(basename "$input" .a)
    mkdir "$dir"
    cd "$dir" >/dev/null
    "${AR:-ar}" x "$abs"
done

cd "$TMPDIR" >/dev/null
apple_symdef_fix
"${AR:-ar}" "${ARFLAGS:-cru}" library.tmp.a ./*/**
"${RANLIB:-ranlib}" library.tmp.a
mv -f library.tmp.a "$TARGET"