How do I only invoke a make shell
function once in a variable expansion, and only when the variable is first used? I don't want to use :=
to expand at declaration time (ie: simple expansion) because the expansion is expensive and only some of my targets need the variable.
I tried using conditional variable assignment but it invokes the shell every time, for example, the following invokes shell ls
twice:
.PHONY: test
FILES ?= $(warning Invoking the shell)$(shell ls)
test:
echo $(FILES) one
echo $(FILES) two