I currently have something like this in my Makefile
PLAY?=$(shell ${BREW} --prefix)/bin/test
PLAY?=/usr/local/test/bin/go
Why is statement 2 not taking affect ? Is it not possible to reassign a value to PLAY variable in my Makefile ?
?=
in a Makefile sets a variable only if it is not already set. Since the lines are read in order, the first one will set PLAY
if it previously was not set, while the second one will never do anything, since by the time you get to it, PLAY
will be set to something.
If you want to set a variable even if it was previously set (replacing the value), use =
instead of ?=
Note that a variable might be "set" to an empty string (by something like PLAY=$(shell true)
or even PLAY=
, which is not the same as it being unset. You can unset a variable with
undefine PLAY