testing the value of ${CXX} in ports Makefile
Don Lewis
truckman at FreeBSD.org
Sat Jan 31 00:02:45 UTC 2015
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 <bsd.port.pre.mk>
>>>>
>>>> post-patch:
>>>> echo CXX=${CXX}
>>>> .if ${CXX} == g++49
>>>> echo detected g++49
>>>> .else
>>>> echo did not detect g++49
>>>> .endif
>>>>
>>>> .include <bsd.port.post.mk>
>>>>
>>>> ...
>>
>>> 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 at FreeBSD.org
COMMENT= junk
USE_GCC= 4.9+
.include <bsd.port.pre.mk>
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 <bsd.port.post.mk>
# 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 <bsd.port.post.mk>, and we're
not allow to put anything in the Makefile after that.
More information about the freebsd-ports
mailing list