pkgsrc-Users archive

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

Re: Surprising make behavior (was: Re: strange trouble building qgis)

Martin Husemann <> wrote:
> On Sat, Sep 12, 2020 at 04:35:48PM +0200, Roland Illig wrote:
> > If you want to know a (good) reason why NetBSD make behaves like this: I
> > have no idea.
> It clearly is a bug. Either in the man page:
>    Additional built-in variables
>      In addition, make sets or knows about the following variables:
>      $               A single dollar sign `$', i.e.  `$$' expands to a single
>                      dollar sign.
> or (my prefered interpretation) in the program.
> How would you even try to explain in the man page how many $ you'd need
> to generate a literal '$' if it depends on what internal path the statement
> actually takes during evaluation?

I'm obviously missing context here, but since I have lots of
very complicated makefiles in hundreds of branches that depend on the
handling of $$ I'm not necessarily keen to see it changed.

$$ can be used to defer expansion eg (from my

# type should be a builtin in any sh since about 1980,
# but sadly there are exceptions!
.if ${.MAKE.OS:Unknown:NBSD/OS} == ""
_type_sh = which

# AUTOCONF := ${autoconf:L:${M_whence}}
M_type = @x@(${_type_sh:Utype} $$x) 2> /dev/null; echo;@:sh:[0]:N* found*:[@]:C,[()],,g
M_whence = ${M_type}:M/*:[1]

in cases where faffing about with $$ gets too complicated/tedious
I use the the following trick:

	whatever | sed 's,_{,$${,g' > ${.TARGET}

which allows "whatever" to output _{FOO} to ensure that
the result contains ${FOO} without any possible interference from make.


Home | Main Index | Thread Index | Old Index