From owner-freebsd-ports@FreeBSD.ORG Sat Jan 31 00:02:45 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 DC70E137 for ; Sat, 31 Jan 2015 00:02:45 +0000 (UTC) Received: from gw.catspoiler.org (cl-1657.chi-02.us.sixxs.net [IPv6:2001:4978:f:678::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5D8C0BB5 for ; Sat, 31 Jan 2015 00:02:45 +0000 (UTC) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.13.3/8.13.3) with ESMTP id t0V02VjT017462; Fri, 30 Jan 2015 16:02:35 -0800 (PST) (envelope-from truckman@FreeBSD.org) Message-Id: <201501310002.t0V02VjT017462@gw.catspoiler.org> Date: Fri, 30 Jan 2015 16:02:31 -0800 (PST) From: Don Lewis Subject: Re: testing the value of ${CXX} in ports Makefile To: kamikaze@bsdforen.de In-Reply-To: <54CB9416.5020802@bsdforen.de> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Cc: ports@FreeBSD.org, elizabeth@interlinked.me 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: Sat, 31 Jan 2015 00:02:45 -0000 On 30 Jan, Dominic Fandrey wrote: > On 30/01/2015 07:28, Don Lewis wrote: >> On 29 Jan, Elizabeth Myers wrote: >>> On 01/29/15 21:43, 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: >>>> >>>> ... >>>> 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 >>>> >>>> ... >> >>> Why do you need to detect it? Shouldn't USE_GCC ensure it's there? In >>> any case, browsing through the ports tree, you could try .if >>> !empty(CXX:M*g++49*) >> >> With USE_GCC=yes, CXX will currently get set to g++48, but at some point >> the default version will get upgraded to 4.9. Unfortunately, that >> breaks the port build unless I apply an extra patch to the source. I >> could set USE_GCC=4.8, but once the default version of gcc gets updated, >> anyone who uses the port will need both gcc 4.8 for this port and 4.9 >> for the majority of parts that just use USE_GCC=yes to get the default. > > Just check against: ${GCC_DEFAULT:M4.9} ${GCC_DEFAULT} isn't even set at that point. # cat 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} @echo GCC_DEFAULT=${GCC_DEFAULT} .if defined(${GCC_DEFAULT}) @echo GCC_DEFAULT is set. .else @echo GCC_DEFAULT is not set. .endif .include # make patch ===> Patching for junk-0.0.0 CXX=g++49 GCC_DEFAULT=4.8 GCC_DEFAULT is not set. For the purposes of variable expansion for .if statements, those variables are not set until after .include , and we're not allow to put anything in the Makefile after that.