From owner-freebsd-ports@FreeBSD.ORG Thu Nov 29 17:51:28 2012 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 32F4F93A; Thu, 29 Nov 2012 17:51:28 +0000 (UTC) (envelope-from yamayan@kbh.biglobe.ne.jp) Received: from rcpt-expgw.biglobe.ne.jp (rcpt-expgw.biglobe.ne.jp [IPv6:2001:260:401:16::3]) by mx1.freebsd.org (Postfix) with ESMTP id 73CB18FC1D; Thu, 29 Nov 2012 17:51:27 +0000 (UTC) Received: from vc-gw.biglobe.ne.jp by rcpt-expgw.biglobe.ne.jp (shby/5910021009) with SMTP id qATHpPVp013587; Fri, 30 Nov 2012 02:51:25 +0900 Received: from smtp-gw.biglobe.ne.jp ([172.21.175.156]) by vc-gw.biglobe.ne.jp (kbkr/0716090908) with ESMTP id qATHpPMd030202; Fri, 30 Nov 2012 02:51:25 +0900 X-Biglobe-Sender: Received: from [192.168.0.100] (KD027083060020.ppp-bb.dion.ne.jp [27.83.60.20]) by smtp-gw.biglobe.ne.jp id CAAZAC15AFDC; Fri, 30 Nov 2012 02:51:25 +0900 (JST) Message-ID: <50B7A0A3.8030604@kbh.biglobe.ne.jp> Date: Fri, 30 Nov 2012 02:51:31 +0900 From: Yamaya Takashi User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Nikolai Lifanov Subject: Re: How to handle WITH_CLANG_IS_CC in ports References: <20121125114918.GA35966@oshi.local> <20121127162737.GB1790@oshi.local> <50B7916E.4070102@mail.lifanov.com> In-Reply-To: <50B7916E.4070102@mail.lifanov.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Alberto Villa , Tobias Rehbein , freebsd-ports@freebsd.org X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Nov 2012 17:51:28 -0000 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 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 > > 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