Subject: Re: bsd.pkg.mk broken?
To: Alan Barrett <apb@cequrux.com>
From: Simon Gerraty <sjg@juniper.net>
List: tech-pkg
Date: 02/23/2004 13:17:25
On Mon, 23 Feb 2004 11:01:56 +0200, Alan Barrett writes:
>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]*}
>                                                          ^

Yes, the above looks wrong.  Can anyone explain what its trying to do?
Perhaps it can be re-worked.

>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.

The brace parsing for :M is definitely "simple-minded".

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

Yes.  It should probably also handle $() - some folk still use those
;-)  I'm at a conf this week so may get some time to look at fixing
this.

>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]
>*}

That's fine, doesn't a simple \ work?  ISTR :M at least checked for \{
will check later when I get a chance.

--sjg