1 |
On 22-06-2016 22:06:53 +0200, Michał Górny wrote: |
2 |
> +# @FUNCTION: tc-get-compiler-type |
3 |
> +# @RETURN: keyword identifying the compiler: gcc, clang, unknown |
4 |
> +tc-get-compiler-type() { |
5 |
> + set -- $($(tc-getCPP "$@") -E -P - <<<"CPP_WORKS __GNUC__ __clang__") |
6 |
|
7 |
% echo "CPP_WORKS __GNUC__ __clang__" | clang -E -P - |
8 |
CPP_WORKS 4 1 |
9 |
|
10 |
The logic below does the right thing, but it might be good for future |
11 |
reference to make note of this (clang). |
12 |
|
13 |
> + |
14 |
> + # CPP_WORKS shouldn't be substituted -- so if it's not there, |
15 |
> + # cpp is probably broken |
16 |
> + if [[ $1 != CPP_WORKS ]]; then |
17 |
> + echo unknown |
18 |
> + # Check which of the defines were substituted |
19 |
> + elif [[ $3 != __clang__ ]]; then |
20 |
> + echo clang |
21 |
> + elif [[ $2 != __GNUC__ ]]; then |
22 |
> + echo gcc |
23 |
> + else |
24 |
> + echo unknown |
25 |
> + fi |
26 |
> +} |
27 |
|
28 |
-- |
29 |
Fabian Groffen |
30 |
Gentoo on a different level |