How to handle WITH_CLANG_IS_CC in ports

Nikolai Lifanov lifanov at mail.lifanov.com
Thu Nov 29 16:46:47 UTC 2012


On 11/29/2012 10:12 AM, Alberto Villa wrote:> On Tue, Nov 27, 2012 at 
5:27 PM, Tobias Rehbein <tobias.rehbein at 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 at 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

Then, in the Makefile, use it like this:

post-patch: setcc



More information about the freebsd-ports mailing list