I have a GNU Makefile that looks something like this:
LIST = item1
.PHONY: targetMain targetA targetB preA preB
targetMain:
echo $(LIST)
targetA: preA targetMain
targetB: preB targetMain
preA:
LIST += itemA
preB:
LIST += itemB
The idea is that I either run make targetA or create targetB. Both of them do very similar things, but with a different list of items. The problem is that the variable is not conditionally bound to it, it is always added, which means that my output is always "item1 itemA itemB".
How can I conditionally add to a variable?
bramp source
share