Hi, I'm more used to GNU make, but I think something like this should work for nmake:
cflags=-Od -MTd -nologo -fp:fast -fp:except- -Gm- -GR- -EHa- -EHsc -Zo -Oi -WX -W4 -wd4100 -wd4189 -wd4201 -wd4505 -wd4127 -FC -Zi
cvars=-D_CRT_SECURE_NO_WARNINGS -DFROMNOTHINGS_DEBUG=1 -DFROMNOTHINGS_COMPATIBILITY=0
conlibs=user32.lib gdi32.lib opengl32.lib zlibstat.lib
..\build\win32_fromnothings.exe: ..\code\*.cpp ..\code\*.h
ctags -R *
cl.exe $(cflags) $(cvars) ..\code\win32_fromnothings.cpp /link $(link) $(conlibs) /F [email protected]
Basically, the target name "..\build\win32_fromnothings.exe" is the path to the file you want to be created. The file(s) after the colon are the files that the target depends on, in this case the all the .cpp and .h files in "..\code".
The rule uses [email protected]
as a shorthand for the .exe name, along with cl.exe's /F flag to specify the output filename. More details on the shortcuts: https://msdn.microsoft.com/en-us/library/ms933742.aspx
Using the output file name as the target like this also means nmake.exe won't rebuild unless the timestamps of dependencies are newer than the target, so unless you modify one of the .cpp or .h files, nmake will probably (rightly) say nothing needs to be done.
If you want it to always build, then you can keep using "all" as the target name, and replace [email protected]
At least with GNU make, each line in the recipe part of the makefile runs in a separate shell, so if nmake is similar that might be why pushd and popd don't seem to work. You can usually write the rules so that changing directory isn't necessary, but if it is, then you might be able to run everything in the same shell with some bracket syntax if nmake also supports this:
(cd /somewhere && cl.exe some-dependency.cpp)