Subject: Re: bsd.pkg.mk broken?
To: None <tech-pkg@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-pkg
Date: 02/23/2004 11:01:56
[CC sjg, in case he is not subscribed to tech-pkg]

On Mon, 23 Feb 2004, Tom Spindler wrote:
> > make: Unclosed variable specification for BUILDLINK_DEPENDS.(variable_x)
> [elided]
> > something wrong with bsd.buildlink3.mk or bsd.buildlink2.mk?
> 
> Try updating your mk/buildlink3/bsd.buildlink3.mk to the (just committed)
> 1.98; this fixes PR/24525, the problem you're describing.

The change from revision 1.97 to 1.98 of bsd.buildlink3.mk seems to add
a mis-matched brace, in order to work around a make(1) bug.  In the
following line (from revision 1.97 of bsd.buildlink3.mk), consider the
'{' that I have marked with a '^' below it:

_BLNK_GE_DEPENDS.${_pkg_}= ${BUILDLINK_DEPENDS.${_pkg_}:N*{*:M*>=[0-9]*}
                                                          ^

The '{' marked above is part of the pattern '*{*', which is terminated
by the ':', and should therefore not need a matching '{'. I can see how
simple-minded brace-counting code could think that there was a missing
'}' at the end, but that is a bug in the brace-matching code, not an
error in the Makefile.

I think that the brace-matching code in make(1) should try to match
'${' and '}', not just '{' and '}'.

It seems risky to rely on make(1) being fixed to handle this case
properly, and wrong to add an extra '}' in the Makefile to work around
the bug in make(1), so I suggest avoiding the problem as follows:

LBRACE={
_BLNK_GE_DEPENDS.${_pkg_}= ${BUILDLINK_DEPENDS.${_pkg_}:N*${LBRACE}*:M*>=[0-9]*}


--apb (Alan Barrett)