blob: 5e4ded2da5bc95d429c6f717a2f25223bbbe210e [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#!/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
11NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)"
12if [[ $# == 0 ]]; then
13 exec "$NEXT_LLVM_CONFIG"
14fi
15
16remain=""
17output=""
18for arg in "$@"; do
19 case "$arg" in
20 --cppflags)
21 output="${output} ${CPPFLAGS}"
22 ;;
23 --cflags)
24 output="${output} ${CFLAGS}"
25 ;;
26 --cxxflags)
27 output="${output} ${CXXFLAGS}"
28 ;;
29 --ldflags)
30 output="${output} ${LDFLAGS}"
31 ;;
Patrick Williams7784c422022-11-17 07:29:11 -060032 --shared-mode)
33 output="${output} shared"
34 ;;
35 --libs)
36 output="${output} -lLLVM"
37 ;;
38 --link-shared)
39 break
40 ;;
Patrick Williams92b42cb2022-09-03 06:53:57 -050041 *)
42 remain="${remain} ${arg}"
43 ;;
44 esac
45done
46
47if [ "${remain}" != "" ]; then
48 output="${output} "$("$NEXT_LLVM_CONFIG" ${remain})
49fi
50
51echo "${output}"