Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Nov 2012 10:16:11 -0500
From:      Nikolai Lifanov <lifanov@mail.lifanov.com>
To:        freebsd-ports@freebsd.org
Cc:        Tobias Rehbein <tobias.rehbein@web.de>, Dimitry Andric <dim@FreeBSD.org>
Subject:   Re: How to handle WITH_CLANG_IS_CC in ports
Message-ID:  <50B387BB.3000502@mail.lifanov.com>
In-Reply-To: <50B23382.3030600@FreeBSD.org>
References:  <20121125114918.GA35966@oshi.local> <50B23382.3030600@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11/25/2012 10:04 AM, Dimitry Andric wrote:
> On 2012-11-25 12:49, Tobias Rehbein wrote:
>> I am the maintainer of ganes/stonesoup. This port builds fine with gcc.
>> It also builds with clang, if the MAKE_ARGS are tweaked.
>>
>> Currently I can check for
>>
>>     ${CC:T:M*clang*}
>>
>> to know if I have to change the MAKE_ARGS for building with clang or
>> not.
>>
>> In CURRENT cc is clang and the environment variable CC is no longer set.
>> This lets the build of games/stonesoup fail. My question is how to
>> correctly check if cc is clang or not. My first guess was something
>> along the lines of
>>
>>     ${CC:T:M*clang*} || (defined(WITH_CLANG_IS_CC) && ${CC:T:Mcc})
>>
>> but I guess there is some kind of official way to handle this (ideally
>> warpped in some Mk macro.
>
> Just check if OSVERSION >= 1000024, maybe?  Or add some logic to
> bsd.port.mk that handles this, like was done with pkgng.  For example,
> introducing a PORTS_COMPILER_TYPE macro like in base.

This is bad.
People with OSVERSION >= 1000024 and WITHOUT_CLANG_IS_CC set will be 
left out.

How about something along the lines of this?

bsd.compiler.mk:

#
# Sets CC variable if unset
#

.PHONY: setcc

setcc:

	@if [ ! -z "`cc -v 2>&1|grep clang`" ] ; then \
		CC?= clang; \
	else \
		CC?= gcc; \
	fi


Then, if a port needs this variable to be set, it can call "setcc" in 
the Makefile.




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