In an nmake
Makefile, i would like to set a variable to the value of an environment variable, but provide a default value if the envvar is not set.
With GNU make I would use the ?=
syntax:
VCINSTALLDIR ?= "%ProgramFiles%\\Microsoft Visual Studio 3.14\\VC"
So if the VCINSTALLDIR variable is set as an environment variable, the makefile uses that value, but falls back to the value provided.
Unfortunately nmake
cannot handle the ?=
syntax.
Which other options do I have?
it seems that the trick is to use IFNDEF
:
!IFNDEF VCINSTALLDIR
VCINSTALLDIR = "%ProgramFiles%\\Microsoft Visual Studio 3.14\\VC"
!ENDIF