Turn audio into a shareable video. forked from nypublicradio/audiogram

has_lib.sh 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. has_ldconfig() {
  3. hash ldconfig 2>/dev/null
  4. }
  5. has_system_lib() {
  6. local regex="lib$1.+(so|dylib)"
  7. # Add /sbin to path as ldconfig is located there on some systems - e.g. Debian
  8. # (and it still can be used by unprivileged users):
  9. PATH="$PATH:/sbin"
  10. export PATH
  11. # Try using ldconfig on linux systems
  12. if $(has_ldconfig); then
  13. for _ in $(ldconfig -p 2>/dev/null | grep -E "$regex"); do
  14. return 0
  15. done
  16. fi
  17. # Try just checking common library locations
  18. for dir in /lib /usr/lib /usr/local/lib /opt/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu; do
  19. test -d $dir && ls $dir | grep -E "$regex" && return 0
  20. done
  21. return 1
  22. }
  23. has_freetype() {
  24. pkg-config cairo --cflags-only-I | grep freetype2
  25. }
  26. has_pkgconfig_lib() {
  27. pkg-config --exists "$1"
  28. }
  29. case "$1" in
  30. gif)
  31. has_system_lib "gif" > /dev/null
  32. result=$?
  33. ;;
  34. jpeg)
  35. has_system_lib "jpeg" > /dev/null
  36. result=$?
  37. ;;
  38. pango)
  39. has_pkgconfig_lib "pango" > /dev/null
  40. result=$?
  41. ;;
  42. freetype)
  43. has_freetype > /dev/null
  44. result=$?
  45. ;;
  46. *)
  47. >&2 echo "Unknown library: $1"
  48. exit 1
  49. esac
  50. if test $result -eq 0; then
  51. echo "true"
  52. else
  53. echo "false"
  54. fi