From owner-freebsd-ports@FreeBSD.ORG Fri Jan 30 06:28:51 2015 Return-Path: Delivered-To: ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 24129BB9 for ; Fri, 30 Jan 2015 06:28:51 +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 A7B048E5 for ; Fri, 30 Jan 2015 06:28:50 +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 t0U6Sf5B008970; Thu, 29 Jan 2015 22:28:46 -0800 (PST) (envelope-from truckman@FreeBSD.org) Message-Id: <201501300628.t0U6Sf5B008970@gw.catspoiler.org> Date: Thu, 29 Jan 2015 22:28:41 -0800 (PST) From: Don Lewis Subject: Re: testing the value of ${CXX} in ports Makefile To: elizabeth@interlinked.me In-Reply-To: <54CB164D.60908@interlinked.me> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Cc: ports@FreeBSD.org 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 06:28:51 -0000 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: >> >> 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 >> >> >> 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. >> >> 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. > 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. I think your suggestion has the same problem as what I tried.because when the .if is evaluated, the value of CXX has still not been updated by bsd.gcc.mk. It still has the original value set by /usr/share/mk/sys/mk.