From owner-freebsd-ports@FreeBSD.ORG Fri Jan 30 18:14:26 2015 Return-Path: Delivered-To: ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C726C26E; Fri, 30 Jan 2015 18:14:26 +0000 (UTC) Received: from ipmail06.adl6.internode.on.net (ipmail06.adl6.internode.on.net [150.101.137.145]) by mx1.freebsd.org (Postfix) with ESMTP id 3512025B; Fri, 30 Jan 2015 18:14:24 +0000 (UTC) Received: from ppp118-210-27-239.lns20.adl2.internode.on.net (HELO leader.local) ([118.210.27.239]) by ipmail06.adl6.internode.on.net with ESMTP; 31 Jan 2015 04:44:24 +1030 Message-ID: <54CBC9FE.8080304@ShaneWare.Biz> Date: Sat, 31 Jan 2015 04:44:22 +1030 From: Shane Ambler User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Don Lewis , ports@FreeBSD.org Subject: Re: testing the value of ${CXX} in ports Makefile References: <201501300345.t0U3jHwb008745@gw.catspoiler.org> In-Reply-To: <201501300345.t0U3jHwb008745@gw.catspoiler.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jan 2015 18:14:26 -0000 On 30/01/2015 14:13, Don Lewis wrote: > I need to test the value of ${CXX} in the Makefile for a port and am > getting unexpected results. Here is a simplified version of the > Makefile: > > PORTNAME= junk > PORTVERSION= 0.0.0 > CATEGORIES= devel > DISTFILES= > > MAINTAINER= truckman@FreeBSD.org > COMMENT= junk > > USE_GCC= 4.9+ > > .include > > post-patch: > echo CXX=${CXX} > .if ${CXX} == g++49 > echo detected g++49 > .else > echo did not detect g++49 > .endif > > .include > > > If I run "make patch", this is what I get: > > # make patch > ===> junk-0.0.0 depends on file: /usr/local/sbin/pkg - found > ===> Fetching all distfiles required by junk-0.0.0 for building > ===> Extracting for junk-0.0.0 > ===> Patching for junk-0.0.0 > echo CXX=g++49 > CXX=g++49 > echo did not detect g++49 > did not detect g++49 You want to use @${ECHO} in the port makefile for that to print right > > If I run "make -dA patch" and look at the debug output, I observe > bsd.gcc.mk getting processed after the .if is evaluated. When the .if > is processed, the value of ${CXX} is still c++. It sort of looks like > bsd.gcc.mk isn't getting included until bsd.port.post.mk and we are > relying on lazy expansion to get the correct value of ${CXX} for the > actions. Maybe more to the point is that CXX used to build might only be defined as part of MAKE_ENV to be passed as the environment for the make command when it is run. > It sort of looks like I'll have to do something like: > > post-patch: > [ ${CXX} = g++49 ] && echo detected g++49 > > but that just seems goofy. > I believe the correct way to what you want is - USES= compiler .include .if ${CHOSEN_COMPILER_TYPE} == gcc and ${COMPILER_VERSION} == 49 EXTRA_PATCHES= ${FILESDIR}/extra-patch-srcfile.c .endif See https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/uses.html and/or comments in /usr/ports/Mk/Uses/compiler.mk You may also want to consider patching with - #if (__GNUC__ == 4) && (__GNUC_MINOR__ == 9) // 4.9 specific changes #endif Of note is that clang identifies itself as gcc 4.2 so you may also want to test for __clang__ if you want to use < with __GNUC_MINOR__ You can also define more control over gcc version - USE_GCC=4.8 will require gcc 4.8 while USE_GCC=4.8+ says you can use 4.8 or higher. -- FreeBSD - the place to B...Software Developing Shane Ambler