In order to support building an EXE file from any directory, I would like to make my paths relative to the location of the Makefile.
While I know how to do so with GNU Makefile:
$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
How can I get the path of Microsoft NMAKE Makefile? Is it even possible to achieve the same behavior?
I know that the Makefile variable MAKEDIR can give me the path from where the nmake command was executed, and that at the nmake command the /F variable holds the path from there to the location of the Makefile, but I don't know how to access the value of /F inside the Makefile in order to combine the two.
(Please don't suggest me to use CMake instead.)
Using the
$(MAKEFLAGS)macro, you can access the value of the/Foption, which specifies the path to theMakefile.Example