This Makefile specifies a target-specific variable and a global one
VAR=value
target: VAR2=value2
ifdef VAR
VAR3+=$(VAR)
endif
ifdef VAR2
VAR3+=$(VAR2)
endif
target:
@echo $(VAR) $(VAR2) $(VAR3)
The output of make target is value value2 value (using GNU make 4.1.1).
However, since, for that target, both VAR and VAR2 have a value, I would expect both the ifdef conditions to be true, so the output should be value value2 value value2. Why that? And what needs to be done to have a target-specific variable have an effect in ifdef?