Better way to do conditional inclusion in make
Justin Hibbits
jhibbits at freebsd.org
Thu Feb 5 18:09:49 UTC 2015
On Thu, Feb 5, 2015 at 9:56 AM, Warner Losh <imp at bsdimp.com> wrote:
> Greetings,
>
> I’ve started a pass through the tree to cleanup how we do conditional inclusion in our build system.
>
> https://reviews.freebsd.org/D1781
>
> It moves away from
>
> .if ${MK_foo} != “no”
> FILES+= files
> .endif
>
> and
>
> SUBDIRS= … ${_foo} …
> ...
> .if ${MK_foo} != “no”
> _foo+= foo
> .endif
>
> and instead more directly assigns things. 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?
>
> Warner
I like it. It makes it easier to see at a glance what options are
available, and how the files are guarded.
- Justin
More information about the freebsd-arch
mailing list