Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2012 02:51:31 +0900
From:      Yamaya Takashi <yamayan@kbh.biglobe.ne.jp>
To:        Nikolai Lifanov <lifanov@mail.lifanov.com>
Cc:        Alberto Villa <avilla@FreeBSD.org>, Tobias Rehbein <tobias.rehbein@web.de>, freebsd-ports@freebsd.org
Subject:   Re: How to handle WITH_CLANG_IS_CC in ports
Message-ID:  <50B7A0A3.8030604@kbh.biglobe.ne.jp>
In-Reply-To: <50B7916E.4070102@mail.lifanov.com>
References:  <20121125114918.GA35966@oshi.local> <CAJp7RHZuB2t=QAVs3QwAqz7T%2BMbwiL1mMz8o9u0C4S%2BBKX_3Lg@mail.gmail.com> <20121127162737.GB1790@oshi.local> <CAJp7RHY17pm_FNMn6vUHELU8FPBMhC0nWKVRYNPY3FRdpULUuA@mail.gmail.com> <50B7916E.4070102@mail.lifanov.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2012/11/30 01:46, Nikolai Lifanov wrote:
> On 11/29/2012 10:12 AM, Alberto Villa wrote:> On Tue, Nov 27, 2012 at
> 5:27 PM, Tobias Rehbein <tobias.rehbein@web.de> wrote:
> >> Is there any chance you turn this into a generic Mk macro?
> >
> > I don't think so, it would mean running `cc --version` on every
> > bsd.port.mk inclusion.
> > --
> > Alberto Villa, FreeBSD committer <avilla@FreeBSD.org>
> > http://people.FreeBSD.org/~avilla
> >
>
> What I meant is to add something like a "setcc" target that port
> Makefiles (that need this) can call.
>
> This logic:
>
> setcc:
>
>     @if [ ! -z "`cc -v 2>&1|grep clang`" ] ; then \
>         CC?= clang; \
>     else \
>         CC?= gcc; \
>     fi
>
> Or this logic:
>
> setcc:
>
>     @if [ -z "$CC" ] ; then \
>     CC=`cc -v 2>&1|\
>     sed '/version/!d;s/.*\(clang\).*/\1/;s/.*\(gcc\).*/\1/'`
>     fi
>
Your logic is broken.
When CC=cc, no effect.

I wrote Mk/bsd.compiler.mk based on share/mk/bsd.compiler.mk

.if !defined(COMPILER_TYPE)
. if ${CC:T:Mgcc*}
COMPILER_TYPE:= gcc
. elif ${CC:T:Mclang}
COMPILER_TYPE:= clang
. elif ${CC:T} == "cc"
_COMPILER_VERSION!=     ${CC} --version
.  if ${_COMPILER_VERSION:Mgcc}
COMPILER_TYPE:= gcc
.  elif ${_COMPILER_VERSION:M\(GCC\)}
COMPILER_TYPE:= gcc
.  elif ${_COMPILER_VERSION:Mclang}
COMPILER_TYPE:= clang
.  endif
.  undef _COMPILER_VERSION
. else
COMPILER_TYPE:= ${CC:T}
. endif
.endif


Include Mk/bsd.compiler.mk, and
.if ${COMPILER_TYPE} == "clang"
  clang specific code
.endif





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50B7A0A3.8030604>