pkgsrc-Changes archive

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

Re: $ in make's := operator (was: CVS commit: pkgsrc/mk)



Am 30.11.2021 um 13:43 schrieb Jonathan Perkin:
* On 2021-11-30 at 12:33 GMT, Roland Illig wrote:

Date: Tue, 30 Nov 2021 09:06:37 +0000
From: Jonathan Perkin <jperkin%netbsd.org@localhost>
To: pkgsrc-changes%NetBSD.org@localhost
Subject: CVS commit: pkgsrc/mk
X-Mailer: log_accum

Module Name:    pkgsrc
Committed By:    jperkin
Date:        Tue Nov 30 09:06:37 UTC 2021

Modified Files:
    pkgsrc/mk: bsd.prefs.mk

Log Message:
mk: Don't expand OPSYS_VERSION early.

The goal of this line was to not evaluate the command from line 92 more
than once.

It's unclear to me whether it makes any difference, as these variables
are already wrapped in .if !defined() earlier and set in MAKEFLAGS.
At the very least it should be documented better, as it's not clear (at
least to me) why we would need both constructs simultaneously.

Before removing the ':=' assignment to OS_VERSION:

~/proj/pkgsrc/devel/glib2 $ bmake clean UNAME='echo uname 1>&2; uname'
uname
uname

After removing the ':=' assignment to OS_VERSION:

===> Cleaning for glib2-2.70.1
~/proj/pkgsrc/devel/glib2 $ bmake clean UNAME='echo uname 1>&2; uname'
uname
uname
uname
uname
uname
uname
uname
uname
uname
uname
uname
uname
uname
uname
uname
uname
uname
uname
uname
uname
===> Cleaning for glib2-2.70.1

So even though OS_VERSION is not used much, it is used in
MACHINE_PLATFORM, and there are many tests for MACHINE_PLATFORM matching
a pattern.

MAKEFLAGS applies only to nested invocations of make, but not to
repeated evaluations in the top-level make process.

There is no built-in evaluate-once behavior for make variables, although
it may be possible to construct one using the '::=' modifier. I'm not
sure yet whether that will be easy enough to understand, and devel/bmake
still has a bug in this area, see usr.bin/make/unit-tests/counter.mk.


Something about NetBSD make(1), at least on 9_STABLE, doesn't like
doing this,
resulting in literal "$$3" being passed to awk instead of being
escaped down
to "$3".  The same construct works fine with pkgsrc bmake(1).

For some reason, .MAKE.SAVE_DOLLARS defaults to true in
pkgsrc/devel/bmake (for backwards compatibility) and to false in NetBSD
as well as Simon's bmake distribution.

Ah, interesting, thanks for explaining.

Why does a version number of an operating system contain a '$' at all?

I don't understand the question.  They don't?

The only thing the commit does is to remove the assignment to OS_VERSION.

In the commit message you said something about $$3 and awk, so I assumed
that awk was related to OS_VERSION. The $$3 I found in bsd.prefs.mk
applies to LOWER_VARIANT_VERSION, but I don't see how they relate. Did I
misunderstand something here?

Roland



Home | Main Index | Thread Index | Old Index