Use NMAKE to create all sources in a directory?

Using nmake, is it possible for the makefile to fully compile all .cpp files in the current directory without specifying separately?

So, instead of something like:

O = $(OBJ_DIR)/main.obj
{$(SOURCE_DIR)}.cpp{$(OBJ_DIR)}.obj:
    ---COMPILE $< HERE---

I would like not to specify every obj object. It can be done?

+1
source share
5 answers
.cpp.obj:
    $(CC) $(CFLAGS) $*.cpp

is the default rule that will automatically resolve .obj dependencies on .cpp files ...

+3
source

You can run the shell command during preprocessing of nmakefile and then the !includeoutput. Naturally, the output should be in nmake format. Sort of:

!if [bash -c "echo O = *.cpp" >sources.mak]
!error Failed to generate source list
!endif
!include sources.mak

all: $(O:.cpp=.obj)

.cpp.obj:
    ---COMPILE $< HERE---

, bash sources.mak, .

+1

:

{src\mystuff}.c{tmp\src\mystuff}.obj::
    $(CC) /nologo $(CFLAGS) /c /Fotmp\src\mystuff\ $<

.c src\mystuff tmp\src\mystuff. .cpp .c .

, , .

, $(CC) nmake cl, , , $(CFLAGS), , .

0

, make script.

Use a for loop, call make in each .cpp file, or create a list of cpp files and use it as a parameter in the make file.

0
source

I think this can be done using wildcards in GNU make (and IIRC you can run it on windows). Other than that, I'm sorry, but I don't know nmake.

-2
source

Source: https://habr.com/ru/post/1725990/


All Articles