diff options
Diffstat (limited to 'eclass/toolchain-funcs.eclass')
-rw-r--r-- | eclass/toolchain-funcs.eclass | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index 1baab96aeb70..a29784cd14a4 100644 --- a/eclass/toolchain-funcs.eclass +++ b/eclass/toolchain-funcs.eclass @@ -585,6 +585,28 @@ tc-endian() { esac } +# @FUNCTION: tc-get-compiler-type +# @RETURN: keyword identifying the compiler: gcc, clang, pathcc, unknown +tc-get-compiler-type() { + local code=' +#if defined(__PATHSCALE__) + HAVE_PATHCC +#elif defined(__clang__) + HAVE_CLANG +#elif defined(__GNUC__) + HAVE_GCC +#endif +' + local res=$($(tc-getCPP "$@") -E -P - <<<"${code}") + + case ${res} in + *HAVE_PATHCC*) echo pathcc;; + *HAVE_CLANG*) echo clang;; + *HAVE_GCC*) echo gcc;; + *) echo unknown;; + esac +} + # Internal func. The first argument is the version info to expand. # Query the preprocessor to improve compatibility across different # compilers rather than maintaining a --version flag matrix. #335943 |