combine_libs 695 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh
  2. set -e
  3. TMPDIR="$(mktemp -d -t tor_lib_combining.XXXXXX)"
  4. ORIGDIR="$(pwd)"
  5. trap 'cd "$ORIGDIR" && rm -rf "$TMPDIR"' 0
  6. abspath() {
  7. echo "$(cd "$(dirname "$1")">/dev/null && pwd)/$(basename "$1")"
  8. }
  9. TARGET=$(abspath "$1")
  10. #echo ORIGDIR="$ORIGDIR"
  11. #echo AR="$AR"
  12. #echo ARFLAGS="$AFLAGS"
  13. shift
  14. for input in "$@"; do
  15. cd "$ORIGDIR"
  16. abs=$(abspath "$input")
  17. dir="$TMPDIR"/$(basename "$input" .a)
  18. mkdir "$dir"
  19. cd "$dir">/dev/null
  20. "${AR:-ar}" x "$abs"
  21. done
  22. cd "$TMPDIR" >/dev/null
  23. #echo "${AR:-ar}" "${ARFLAGS:-cru}" library.tmp.a ./*/**
  24. "${AR:-ar}" "${ARFLAGS:-cru}" library.tmp.a ./*/**
  25. "${RANLIB:-ranlib}" library.tmp.a
  26. mv -f library.tmp.a "$TARGET"