summaryrefslogtreecommitdiffstats
path: root/external/meta-clang/recipes-devtools/clang/llvm-common/llvm-config
blob: a139514dc69a18dc3c9c222bbb631bca01b3bf02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
#
# Wrapper script for llvm-config. Supplies the right environment variables
# for the target and delegates to the native llvm-config for anything else. This
# is needed because arguments like --ldflags, --cxxflags, etc. are set by the
# native compile rather than the target compile.
#

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)"
export YOCTO_ALTERNATE_EXE_PATH="$(readlink -f "$SCRIPT_DIR/../llvm-config")"

if [[ $# == 0 ]]; then
  exec "$NEXT_LLVM_CONFIG"
fi

if [[ $1 == "--libs" ]]; then
  exec "$NEXT_LLVM_CONFIG" $@
fi

if [[ $1 == "--bindir" ]]; then
  unset YOCTO_ALTERNATE_EXE_PATH
  exec "$NEXT_LLVM_CONFIG" $@
fi

for arg in "$@"; do
  case "$arg" in
    --cppflags)
      echo $TARGET_CPPFLAGS
      ;;
    --cflags)
      echo $TARGET_CFLAGS
      ;;
    --cxxflags)
      echo $TARGET_CXXFLAGS
      ;;
    --ldflags)
      echo $TARGET_LDFLAGS
      ;;
    *)
      echo "$("$NEXT_LLVM_CONFIG" "$arg")"
      ;;
  esac
done