tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

combine_libs (847B)


      1 #!/bin/sh
      2 
      3 set -e
      4 
      5 TMPDIR="$(mktemp -d -t tor_lib_combining.XXXXXX)"
      6 ORIGDIR="$(pwd)"
      7 
      8 trap 'cd "$ORIGDIR" && rm -rf "$TMPDIR"' 0
      9 
     10 abspath() {
     11     echo "$(cd "$(dirname "$1")" >/dev/null && pwd)/$(basename "$1")"
     12 }
     13 
     14 apple_symdef_fix() {
     15     # On modern macOS and iOS we need to remove the "__.SYMDEF" and "__.SYMDEF
     16     # SORTED" before we repack the archive.
     17     # See: tor#40683.
     18     if [ "$(uname -s)" = "Darwin" ] ; then
     19         find . -name "__.SYMDEF*" -delete
     20     fi
     21 }
     22 
     23 TARGET=$(abspath "$1")
     24 
     25 shift
     26 
     27 for input in "$@"; do
     28     cd "$ORIGDIR"
     29     abs=$(abspath "$input")
     30     dir="$TMPDIR"/$(basename "$input" .a)
     31     mkdir "$dir"
     32     cd "$dir" >/dev/null
     33     "${AR:-ar}" x "$abs"
     34 done
     35 
     36 cd "$TMPDIR" >/dev/null
     37 apple_symdef_fix
     38 "${AR:-ar}" "${ARFLAGS:-cru}" library.tmp.a ./*/**
     39 "${RANLIB:-ranlib}" library.tmp.a
     40 mv -f library.tmp.a "$TARGET"