On Thu, Mar 12, 2009 at 02:19:48PM +0200, Yorick Hardy wrote: > config(5) says: > > Conditions > Finally, source file selection is possible through the help of condition- > als, referred to as condition later in this documentation. The syntax > for those conditions uses well-known operators ( ``&'', ``|'' and ``!'') > to combine options and attributes. > > and > makeoptions condition name+=value [, condition name+=value] > Appends to a definition in the generated Makefile. > > However, makeoptions does not accept a general condition. > Is the attached patch acceptable? Not really, sorry. [...] > Index: usr.bin/config/gram.y > =================================================================== > RCS file: /cvsroot/src/usr.bin/config/gram.y,v > retrieving revision 1.18 > diff -u -r1.18 gram.y > --- usr.bin/config/gram.y 28 Dec 2008 01:23:46 -0000 1.18 > +++ usr.bin/config/gram.y 12 Mar 2009 11:57:22 -0000 > @@ -507,7 +507,8 @@ > condmkoption; > > condmkoption: > - WORD mkvarname PLUSEQ value { appendcondmkoption($1, $2, $4); }; > + WORD mkvarname PLUSEQ value { appendcondmkoption($1, $2, $4); } | > + fexpr mkvarname PLUSEQ value { appendcondmkoptexpr($1, $2, $4); }; Nasty hack 1. There's no reason to treat a single condition differently from a full expression. [...] > +appendcondmkoptexpr(struct nvlist *l, const char *name, const char *value) > +{ > + struct nvlist *nv; > + > + nv = newnv(name, value, l, 0, NULL); > + *nextappmkopt = nv; > + nextappmkopt = &nv->nv_next; Nasty hack 2. Abusing the list of unconditional make options to squeeze in conditional options... It's actually much simpler to only use 'fexpr' in the grammar and evaluate it in print_condmkoptions. You don't have to be smart in how you fill in condmkopttab, it can actually just be a nvlist. I guess the reason it was done that way was to minimize the number of evaluations of options, but there's no point in doing that if it uses expressions. I thought I had started a patch for that when Matt asked me about it, but I can't find it anymore... -- Quentin Garnier - cube%cubidou.net@localhost - cube%NetBSD.org@localhost "See the look on my face from staying too long in one place [...] every time the morning breaks I know I'm closer to falling" KT Tunstall, Saving My Face, Drastic Fantastic, 2007.
Attachment:
pgpZBEmNCSg52.pgp
Description: PGP signature