summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/llvm/llvm/llvm-config
blob: a45f38c650a3543b0b16c85011e8b6eaab4cd840 (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
#!/bin/bash
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#
# Wrap llvm-config since the native llvm-config will remap some values correctly
# if placed in the target sysroot but for flags, it would provide the native ones.
# Provide ours from the environment instead.

NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)"
if [[ $# == 0 ]]; then
  exec "$NEXT_LLVM_CONFIG"
fi

remain=""
output=""
for arg in "$@"; do
  case "$arg" in
    --cppflags)
      output="${output} ${CPPFLAGS}"
      ;;
    --cflags)
      output="${output} ${CFLAGS}"
      ;;
    --cxxflags)
      output="${output} ${CXXFLAGS}"
      ;;
    --ldflags)
      output="${output} ${LDFLAGS}"
      ;;
    *)
      remain="${remain} ${arg}"
      ;;
  esac
done

if [ "${remain}" != "" ]; then
      output="${output} "$("$NEXT_LLVM_CONFIG" ${remain})
fi

echo "${output}"