mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.3 KiB

  1. #!/bin/bash
  2. # run the original command
  3. "$@"; rc=$?
  4. if [ -n "$AUTOSO2A_DIR" ] && \
  5. [[ "$*" == *" -shared "* ]]
  6. then
  7. mkdir -p "$AUTOSO2A_DIR"
  8. {
  9. echo "--"; echo "$0 $*"; shift
  10. arname="a.out"; objs=""; del=""
  11. while [ "$#" -gt 0 ]
  12. do
  13. case "$1" in
  14. -o)
  15. arname="${2##*/}"; shift
  16. ;;
  17. [^-]*.o|[^-]*.lo)
  18. if [ -f $1 ]; then
  19. echo "Add object: $1"
  20. objs="$objs $1"
  21. else
  22. echo "$0: Don't know how to handle $1 .." >&2
  23. echo "Don't know how to handle $1 .."
  24. fi
  25. ;;
  26. [^-]*.a|[^-]*.al)
  27. if [ -f $1 ]; then
  28. echo "Add archive: $1"
  29. tmpdir=$( mktemp -d ); del="$del $tmpdir"
  30. ( cd $tmpdir; ar x /dev/fd/0; ) < $1
  31. for x in $tmpdir/*; do
  32. [ -f $x ] || continue
  33. echo " - $x"; objs="$objs $x"
  34. done
  35. else
  36. echo "$0: Don't know how to handle $1 .." >&2
  37. echo "Don't know how to handle $1 .."
  38. fi
  39. ;;
  40. [^-]*)
  41. echo "$0: Don't know how to handle $1 .." >&2
  42. echo "Don't know how to handle $1 .."
  43. ;;
  44. esac
  45. shift
  46. done
  47. [[ "$arname" == *.so* ]] && arname="${arname%.so*}.a"
  48. echo "Output file: $arname"
  49. rm -f "$AUTOSO2A_DIR/$arname"
  50. if ! $AUTOSO2A_AR q "$AUTOSO2A_DIR/$arname" $objs 2>&1; then
  51. echo "$0: Got an error while running $AUTOSO2A_AR .." >&2
  52. fi
  53. $AUTOSO2A_RANLIB "$AUTOSO2A_DIR/$arname"
  54. } >> "$AUTOSO2A_DIR/so2a_wrapper.log"
  55. fi
  56. exit $rc