Add to top of list

I have a makefile that lists the source files: (shortened to appropriate)

SRCFOLDER=src/ SOURCES= main.cpp OBJECTS=$(SOURCES:.cpp=.o) 

and I would like to combine the lines together, but for each in SOURCES . As you can see above, I am doing this for OBJECTS , but I want to do it like this: (pseudocode)

 foreach(src in SOURCES) src = concate(SRCFOLDER, src) 

so if SOURCES was main.cpp window.cpp , the result would be src/main.cpp src/window.cpp .

I tried this:

 SOURCES=$(SOURCES:*=$(SRCFOLDER)/*) 

but I get this error:

 makefile:12: *** Recursive variable `SOURCES' references itself (eventually). Stop. 
+6
source share
1 answer
 SRCFOLDER := src SOURCES := main.cpp window.cpp SOURCES := $(addprefix $(SRCFOLDER)/, $(SOURCES)) 
+11
source

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


All Articles