tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Lazy ${${VAR} != "no":? ... : ...}



On 31.08.2020 01:13, Valery Ushakov wrote:
> Hallo, Roland.
>
> Is this form now deprecated?
>
>   CPPFLAGS += ${${USE_INET6} != "no":? -DINET6 :}

No, it isn't.  It is as valid as always.

> which used to be lazy, instead of:
>
>   .if (${USE_INET6} != "no")
>   CPPFLAGS += -DINET6
>   .endif
>
> that requires the variable to be defined and so requires inclusion of
> bsd.init.mk early.

My recent changes to make didn't break this.  The behavior is the same
between make from today and make from 2020-07-01.

The point here is that the current bsd.own.mk has this code in line 352:

.       if empty(CPPFLAGS:M*--sysroot=*)

At that point USE_INET6 is not defined yet, and yet it is evaluated.  It
is defined a bit later, in line 1428:

.for var in ... USE_INET6 ...
.if (${${var:S/USE_/MK/}} == "no")
${var}:= no
.else
${var}?= yes
.endif
.endfor

Including bsd.init.mk therefore removes this warning since then
USE_INET6 is not evaluated in line 352.

Requiring --sysroot=* to be added to CPPFLAGS before including
bsd.init.mk and requiring USE_INET6 to be added to CPPFLAGS after
including bsd.init.mk looks fragile to me.

> On Sun, Aug 30, 2020 at 19:04:44 -0400, Christos Zoulas wrote:
>
>>> On Aug 30, 2020, at 7:01 PM, Valery Ushakov <uwe%stderr.spb.ru@localhost> wrote:
>>>
>>> On Sun, Aug 30, 2020 at 17:12:45 -0400, Christos Zoulas wrote:
>>>
>>>> Module Name:	src
>>>> Committed By:	christos
>>>> Date:		Sun Aug 30 21:12:45 UTC 2020
>>>>
>>>> Modified Files:
>>>> 	src/usr.sbin/puffs/mount_9p: Makefile
>>>>
>>>> Log Message:
>>>> include bsd.init.mk to avoid:
>>>> make: Bad conditional expression ` != "no"' in  != "no"? -DINET6 :
>>>
>>> This worked and the :? for was specifically used to so that the ugly
>>> early include (required for an ifdef) can be avoided.  I don't
>>> remember who pointed out this form to me (joerg@ or mrg@ I'd guess).
>>> We have more forms like this in the tree, so not much.

Yes, it worked in NetBSD 8 since back then bsd.own.mk was different.

Running the plain "make USETOOLS=no clean" on NetBSD 8 works, but
running "make -m /usr/src/current/share/mk USETOOLS=no clean" doesn't.

Roland


Home | Main Index | Thread Index | Old Index