tech-toolchain archive

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

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



On Mon, Aug 31, 2020 at 07:42:07 +0200, Roland Illig wrote:

> On 31.08.2020 01:13, Valery Ushakov wrote:
> 
> > 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:

Ah, thanks for the analysis!  I wonder what changed since the time I
committed this in June.  Stricter warnings?


> 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.

Sure.

I alwys disliked the early .init kludge which is required if you want
to check USE_* variables in an .if and then someone pointed this ?:
trick to me.  But of course mixing the non-lazy .if and lazy ?: is
bad.

OTOH, now that I skimmed it, it looks unhygienic to mess in bsd.own.mk
with CPPFLAGS and LDFLAGS that are "owned" by other mk files, forcing
their evaluation so early.  My impression is that sysroot was added to
those variables b/c they just happen to be passed to the tools we want
sysroot passed to and so instead of adding a proper separate
${SYSROOT} variable the flag was added to the existing vars.  The :M
games just prove this point.


> > 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

-uwe


Home | Main Index | Thread Index | Old Index