llvm-config 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. #
  3. # Copyright OpenEmbedded Contributors
  4. #
  5. # SPDX-License-Identifier: MIT
  6. #
  7. # Wrap llvm-config since the native llvm-config will remap some values correctly
  8. # if placed in the target sysroot but for flags, it would provide the native ones.
  9. # Provide ours from the environment instead.
  10. NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)"
  11. if [[ $# == 0 ]]; then
  12. exec "$NEXT_LLVM_CONFIG"
  13. fi
  14. remain=""
  15. output=""
  16. for arg in "$@"; do
  17. case "$arg" in
  18. --cppflags)
  19. output="${output} ${CPPFLAGS}"
  20. ;;
  21. --cflags)
  22. output="${output} ${CFLAGS}"
  23. ;;
  24. --cxxflags)
  25. output="${output} ${CXXFLAGS}"
  26. ;;
  27. --ldflags)
  28. output="${output} ${LDFLAGS}"
  29. ;;
  30. --shared-mode)
  31. output="${output} shared"
  32. ;;
  33. --libs)
  34. output="${output} -lLLVM"
  35. ;;
  36. --link-shared)
  37. break
  38. ;;
  39. *)
  40. remain="${remain} ${arg}"
  41. ;;
  42. esac
  43. done
  44. if [ "${remain}" != "" ]; then
  45. output="${output} "$("$NEXT_LLVM_CONFIG" ${remain})
  46. fi
  47. echo "${output}"