.PHONY: all
ifdef IFSETUSEMYVALUE
FOO:=$(IFSETUSEMYVALUE)
else
FOO:="another value"
endif
all:
@echo $(FOO)
$ make
another value
$ IFSETUSEMYVALUE="Hi" make
Hi
Note: Variable assignments with colon equal (:=
) will be expanded only once, whereas =
assignments are expanded on each use.