I have a list of objects in a Makefile variable named OBJECTS that is too large for the command buffer. Therefore, I use the following method to create a file listing objects (to go to ar):
objects.lst:
$(foreach OBJ,$(OBJECTS),$(shell echo "$(OBJ)">>$@))
While this works, it is very slow (at least by Cygwin), and I don't like relying on shell commands and redirection.
Complementary foreach is not intended for this purpose - it is evaluated before any commands are run, which means that I cannot, for example, rm -f objects.lst
before adding.
Is there a better way? I do not want to use incremental archiving, as this causes problems with multiple jobs.
The only thing I can think of is parsing the Makefile using a separate script to read a list of objects or store a list of objects in a separate file. Both solutions have their own problems.
source
share