On Thu, 23 Jun 2016 08:52:20 +0200 Fabian Groffen <[email protected]> wrote:
> On 22-06-2016 22:06:53 +0200, Michał Górny wrote:
> > +# @FUNCTION: tc-get-compiler-type
> > +# @RETURN: keyword identifying the compiler: gcc, clang, unknown
> > +tc-get-compiler-type() {
> > + set -- $($(tc-getCPP "$@") -E -P - <<<"CPP_WORKS __GNUC__ __clang__")
>
> % echo "CPP_WORKS __GNUC__ __clang__" | clang -E -P -
> CPP_WORKS 4 1
>
> The logic below does the right thing, but it might be good for future
> reference to make note of this (clang).
I'm actually thinking of moving the whole logic into cpp using '#if
defined', and just matching the output for the result. This would be
easier to maintain in the future, I guess.
> > +
> > + # CPP_WORKS shouldn't be substituted -- so if it's not there,
> > + # cpp is probably broken
> > + if [[ $1 != CPP_WORKS ]]; then
> > + echo unknown
> > + # Check which of the defines were substituted
> > + elif [[ $3 != __clang__ ]]; then
> > + echo clang
> > + elif [[ $2 != __GNUC__ ]]; then
> > + echo gcc
> > + else
> > + echo unknown
> > + fi
> > +}
>
--
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
pgpD0aKTNB_ve.pgp
Description: OpenPGP digital signature
