我有一个看起来有点像这样的 GNU Makefile:
LIST = item1
.PHONY: targetMain targetA targetB preA preB
targetMain:
# DO all the work in here
echo $(LIST)
targetA: preA targetMain
targetB: preB targetMain
preA:
LIST += itemA
preB:
LIST += itemB
这个想法是我要么运行 make targetA 要么运行 targetB。他们俩都做非常相似的事情,但项目列表不同。问题是变量不是有条件地附加到,它总是附加到,这意味着我的输出总是“item1 itemA itemB”。
如何有条件地附加到变量?