Nmake gets a list of all .o files from .cpp files

I use nmake to compile multiple source files into an elf. However, I do not want to list .o files in a long list as follows:

OBJS = file1.o file2.o file3.o

I would prefer to use a wildcard that indicates all .o files in the current directory as dependencies for .elf. However .o files do not exist until I compiled them from .cpp files. Is there a way to get a list of cpp files using a wildcard extension and then do a line replacement to replace .cpp with .o.

+3
source share
3 answers

NMAKE. , GNU Make , Windows .

NMAKE, make, , NMAKE . , .

, .

+4

Unix make gmake, :

OBJS = $(SOURCES:.cpp=.o)

(, )

0

- , .

, .cpp "",

 del listoffiles.txt
 echo SOURCES= \ >> listoffiles.txt
 for %i in (*.dll) do @echo %i \ >>listoffiles.txt
 echo. >> listoffiles.txt

Then you can try using this with the INCLUDE preprocessor macro in nmake:

 !INCLUDE listoffiles.txt 

(I am sure this will not work from scratch, but the general idea should be clear).

0
source

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


All Articles