如何仅在变量扩展中仅在首次使用变量时调用一次make shell
函数?我不想在声明时使用:=
进行扩展(即简单扩展),因为扩展非常昂贵,而且只有一些目标需要变量。
我尝试使用条件变量赋值,但是它每次都会调用shell,例如,以下两次调用shell ls
:
.PHONY: test
FILES ?= $(warning Invoking the shell)$(shell ls)
test:
echo $(FILES) one
echo $(FILES) two
答案 0 :(得分:-1)
将任务移到食谱中
test:
FILES=$$(ls) ;\
echo $$FILES one ;\
echo $$FILES two