Better way to do conditional inclusion in make

Dimitry Andric dim at FreeBSD.org
Thu Feb 5 21:32:15 UTC 2015


On 05 Feb 2015, at 18:56, Warner Losh <imp at bsdimp.com> wrote:
> 
> We know that MK_foo is always going to be yes or no
> for build options. We can leverage that fact, and the fact that bmake is so much better at variable
> expansion than fmake was (especially in the early days) to instead move to something like:
> 
> FILES=list of unconditional files here ${FILES.yes}
> FILES.${MK_foo}+=foo bar biz
> FILES.${MK_baz}+=baz bing boo
> 
> which eliminates a whole lot of needless .if / .endif lines, lots of extra blank lines, etc.
> 
> Comments?

One disadvantage is that you then cannot intersperse MK_foo files or
subdirs in between unconditional ones, and keep a certain order, e.g.
like:

FILES+= a b c
.if ${MK_foo} != "no"
FILES+= d e f
.endif
FILES+= g h i

Of course, this is only important for a few particular places, most of
the tree should not care too much about the order in which subdirs or
files are built.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20150205/a791c7ef/attachment.sig>


More information about the freebsd-arch mailing list