Using nmake, is it possible to have the makefile build all the .cpp files in the current directory automatically, without having to specify them individually?
So, instea
Just
main.exe: *.c resource.RES
@$(MAKE) $(**:.c=.obj)
link $(**:.c=.obj) /OUT:$@
and you don't need to add anything else! Every time you nmake
, all *.c
will be checked if it is compiled or not.
Where $**
for the dependencies, $@
for the target.
$(**:.c=.obj)
is a string substitute, replacing the .c
suffix with .obj
. And when it comes to resource.RES
, it will not replace anything.
Note that there is a recursive call. This is the most elegant approach, otherwise you can call cmd
to print all *.c
filenames to a text and load from it.