From owner-freebsd-ports@FreeBSD.ORG Fri Jan 30 15:04:33 2015 Return-Path: Delivered-To: freebsd-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 23500BE1 for ; Fri, 30 Jan 2015 15:04:33 +0000 (UTC) Received: from udns.ultimatedns.net (ultimatedns.net [209.180.214.225]) (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 AEAB380C for ; Fri, 30 Jan 2015 15:04:30 +0000 (UTC) Received: from ultimatedns.net (localhost [127.0.0.1]) by udns.ultimatedns.net (8.14.9/8.14.9) with ESMTP id t0UF4UmK062541 for ; Fri, 30 Jan 2015 07:04:30 -0800 (PST) (envelope-from bsd-lists@bsdforge.com) To: In-Reply-To: <012c1901592b44c5c09f0d42576193c5@ultimatedns.net> References: <201501300646.t0U6kW1L009003@gw.catspoiler.org>, <012c1901592b44c5c09f0d42576193c5@ultimatedns.net> From: "Chris H" Subject: Re: testing the value of ${CXX} in ports Makefile Date: Fri, 30 Jan 2015 07:04:30 -0800 Content-Type: text/plain; charset=UTF-8; format=fixed MIME-Version: 1.0 Message-id: <9da2e00a0f6529a1d3be175d25b27a64@ultimatedns.net> Content-Transfer-Encoding: 8bit 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 15:04:33 -0000 On Fri, 30 Jan 2015 06:30:10 -0800 "Chris H" wrote > On Thu, 29 Jan 2015 22:46:32 -0800 (PST) Don Lewis > wrote > > > On 29 Jan, Chris H wrote: > > > On Thu, 29 Jan 2015 19:43:38 -0800 (PST) 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. > > > I'm not attempting to come off as any sot of expert. But it > > > seems like you're going the long way around. Couldn't you > > > just as easily REQUIRE, or perhaps even better; simply reverse > > > the logic; > > > > > > if ${CXX} != g++49 > > > @VOMIT > > > endif > > > > > > It'd be shorter, and still assures the results you require, > > > no? Just a thought. > > > > gcc46, gcc47, gcc48, and probably gcc5 (haven't tested that one yet) all > > work. gcc49 requires a source patch. I just want to be able to set > > USE_GCC=yes and not have the port break when the default version of gcc > > gets changed to 4.9. > > > > The way that the ports infrastructure is written, it looks like I can't > > do the test with a Makefile .if / .endif. It looks like I have to do it > > in the shell code in actions for the target. > > > > Instead of using [ condition ] && do something, I could also write it as > > if [ ${CXX} = g++49 ]; then apply the patch; fi > Ahh. Sure. It's also shorter than the only alternative I can conceive > if ${CXX} <= g++48 || if ${CXX} >= g++50 Ahem... That *should* have read if ${CXX} <= g++48 || ${CXX} >= g++50 Sorry for the noise. In the future, I'll try to refrain from sending email until *after* my first cup of coffee. :( > @${PATCHME} > endif > > --Chris > > -- > > > _______________________________________________ > freebsd-ports@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-ports > To unsubscribe, send any mail to "freebsd-ports-unsubscribe@freebsd.org"