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, instead of something like:
O = $(OBJ_DIR)/main.obj
{$(SOURCE_DIR)}.cpp{$(OBJ_DIR)}.obj:
---COMPILE $< HERE---
I'd like to avoid having to specify each obj to make. Can this be done?
-
I think this can be done with wild cards in GNU make (and IIRC you can run it on windows). Aside from that, I'm sorry but I don't known
nmake. -
You can use a rule like this:
{src\mystuff}.c{tmp\src\mystuff}.obj:: $(CC) /nologo $(CFLAGS) /c /Fotmp\src\mystuff\ $<which will find and compile all the
.cfiles insrc\mystuffand put the object files intmp\src\mystuff. Substitute.cppfor.cin your case.Note that the first character on the second line should be a tab, not spaces.
Also,
$(CC)is predefined by nmake to becl, and you can add any compiler flags you need to$(CFLAGS), hard-code them in the rule or add a different variable there, as you prefer. -
.cpp.obj: $(CC) $(CFLAGS) $*.cppis a default rule that will automatically resolve .obj dependencies from .cpp files...
-
One possibility is to wrap the make in a script.
Either use a for loop, calling make on each .cpp file or construct a list of cpp files and use it as a parameter to the makefile.
0 comments:
Post a Comment