Better way to do conditional inclusion in make

Simon J. Gerraty sjg at juniper.net
Fri Feb 6 06:10:22 UTC 2015


NGie Cooper <yaneurabeya at gmail.com> wrote:
> .if ${MK_BAR} != "no" && ${MK_FOO} != "no"
> FILES+= a_lot_of_bar_in_my_foo
> .endif
> 

Actually the same idea can handle that:

FILES+= ${FILES.yesyes}
FILES.${MK_BAR}${MK_FOO}+= a_lot_of_bar_in_my_foo

extend as far as you like

> >> What concerns me about the short description of the implementation,
> >> (and something that I'm going to add to the phabricator review) is
> >> that this will:
> >>
> >> 1. Break using FILESGROUPS
> >
> > Why?
> 
> The same reason why bsd.progs.mk didn't work with bsd.prog.mk on
> FreeBSD out of the box originally -- defaults:
> 
> 10 FILESGROUPS?=   FILES
> 11
> 12 .for group in ${FILESGROUPS}
> 13 buildfiles: ${${group}}
> 14 .endfor
> 15

If you do 

FILES:= ${FILES}

prior to the above and even if you don't 
I don't think the behavior would change - at least for the snippet quoted.

${${group}} would still expand to the same thing, and dependency rules
don't care if something is listed more than once

FILES:= ${FILES}

would probably be a good idea anyway though.

> Warner's change (based on what I understand, again I haven't looked at
> the review yet...) would require setting FILESGROUPS explicitly. So if
> you had a Makefile snippet that defines the non-default FILESGROUPS
> already, it will break that usecase.

I don't think Warners change - per the brief description makes no
difference to 

FILESGROUPS?=   FILES



More information about the freebsd-arch mailing list