llvm-config 1011 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. #
  3. # Wrapper script for llvm-config. Supplies the right environment variables
  4. # for the target and delegates to the native llvm-config for anything else. This
  5. # is needed because arguments like --ldflags, --cxxflags, etc. are set by the
  6. # native compile rather than the target compile.
  7. #
  8. SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
  9. NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)"
  10. export YOCTO_ALTERNATE_EXE_PATH="$(readlink -f "$SCRIPT_DIR/../llvm-config")"
  11. if [[ $# == 0 ]]; then
  12. exec "$NEXT_LLVM_CONFIG"
  13. fi
  14. if [[ $1 == "--libs" ]]; then
  15. exec "$NEXT_LLVM_CONFIG" $@
  16. fi
  17. if [[ $1 == "--bindir" ]]; then
  18. unset YOCTO_ALTERNATE_EXE_PATH
  19. exec "$NEXT_LLVM_CONFIG" $@
  20. fi
  21. for arg in "$@"; do
  22. case "$arg" in
  23. --cppflags)
  24. echo $TARGET_CPPFLAGS
  25. ;;
  26. --cflags)
  27. echo $TARGET_CFLAGS
  28. ;;
  29. --cxxflags)
  30. echo $TARGET_CXXFLAGS
  31. ;;
  32. --ldflags)
  33. echo $TARGET_LDFLAGS
  34. ;;
  35. *)
  36. echo "$("$NEXT_LLVM_CONFIG" "$arg")"
  37. ;;
  38. esac
  39. done