I have a makefile that lists the source files: (shortened to relevant)
SRCFOLDER=src/
SOURCES= main.cpp
OBJECTS=$(SOURCES:.cpp=.o)
and I would like to concate the strings together, but for each one in SOURCES
. As you can see above, I do it for OBJECTS
, but I want to do it like this: (pseudocode)
foreach(src in SOURCES)
src = concate(SRCFOLDER, src)
so that 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.
The append() method adds an item to the end of the list.
insert(index, value)this inserts an item at a given position. The first argument is the index of the element before which you are going to insert your element, so array. insert(0, x) inserts at the front of the list, and array. insert(len(array), x) is equivalent to array.
There are four methods to add elements to a List in Python. append() : append the element to the end of the list. insert() : inserts the element before the given index. extend() : extends the list by appending elements from the iterable.
An English dictionary defines the words append and extend as: append: add (something) to the end of a written document.
SRCFOLDER := src
SOURCES := main.cpp window.cpp
SOURCES := $(addprefix $(SRCFOLDER)/, $(SOURCES))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With