Better way to do conditional inclusion in make

Warner Losh imp at bsdimp.com
Fri Feb 6 03:27:08 UTC 2015


> On Feb 5, 2015, at 6:22 PM, Simon J. Gerraty <sjg at juniper.net> wrote:
> 
> Julian Elischer <julian at freebsd.org> wrote:
>> how does it cope with the case where a single file is dependent on
>> either of two options.
>> (we have this in our tree.. not sure if it occurs in the FreeBSD tree.)
>> file could occur in both lists or twice in one list..
> 
> If you accept the premise that order of the list shouldn't matter,
> one can simply apply :O:u to suppress dups.

The order of the list doesn’t matter. If it does, that’s a bug in the list and/or
the dependencies and that should be fixed. I’m not aware of any place in the
tree where this matters that doesn’t have some secondary ordering mechanism
(see the libraries for one such thing).

The phabricator review already has this construct to sort and suppress dups.

Where this conditional breaks down is when you have something predicated
on MACHINE_ARCH and MK_foo. Makes it very hard to have FILES.${MACHINE}
added as well. In user land this isn’t so common (it happens, but not so much
and most of it would disappear if we had some kind of always no flag for
options that flat out can’t work on a given arch)[*]. In the kernel though it happens
a lot with a lot of annoying duplication.

Warner

[*] Consider having something like
.if ${MACHINE} != “i386” && ${MACHINE} != “amd64”
__ALWAYS_NO+= GERBILS PUPPIES WHALES
.endif
then MK_GERBILS would always be no (you aren’t allowed to set another value),
and you don’t have to check for architectures where it is used to exclude it. I
haven’t worked out all the details of this yet, which is why I haven’t posted it
for discussion.


More information about the freebsd-arch mailing list