Source-Changes-D archive

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

Re: CVS commit: src/share/mk



Am 28.06.2024 um 22:45 schrieb Taylor R Campbell:
> +# It is tempting to use the make :P modifier here so that you can just
> +# write
> +#
> +#	VERSION_MAP=	foo.map
> +#
> +# instead of
> +#
> +#	VERSION_MAP=	${.CURDIR}/foo.map
> +#
> +# but it appears that :P works _only_ with literal names, not with
> +# expansions, so while you could write
> +#
> +#	VERSION_MAP=	${foo.map:P}
> +#
> +# in the makefile, we can't set
> +#
> +#	LDFLAGS+=	-Wl,--version-script=${${VERSION_MAP}:P}
> +#
> +# here.

The ':P' modifier treats a literal in the same way as an expression, so
there's no difference between ${foo.map:P} and ${${:Ufoo.map}:P}, as in
both cases the "variable name" is 'foo.map'. If you still remember how
you came to that conclusion, I'd be interested in it.

In order to make the ':P' modifier work, the "variable name" must be an
existing node in the dependency tree, at the point where the ':P'
modifier is evaluated.

Here's a demonstration:

> .MAKEFLAGS: -dv
> .PATH: /dev
> VERSION_MAP=	null
> Resolve_via_Path: .PHONY .NOTMAIN ${VERSION_MAP}
> LDFLAGS+=	-Wl,--version-script=${${VERSION_MAP}:P}
> LDFLAGS+=	-Wl,--version-script=${null:P}
> .info ${LDFLAGS}
> .MAKEFLAGS: -dF/dev/null
> all:

The 'Resolve_via_Path' dependency line adds the VERSION_MAP file to the
dependency tree. Instead of 'Resolve_via_Path', you can choose any other
name or even leave it empty, making the line start with a "magic colon".

Roland



Home | Main Index | Thread Index | Old Index