I have a bunch of static libraries and I need to combine into a single file using ar
in Makefile
.
For example,
ar -M <<EOM
CREATE app.a
ADDLIB lib1.a
ADDLIB lib2.a
ADDLIB lib3.a
....
....
....
ADDLIB libN.a
SAVE
END
EOM
This is fine and works as long as I know all the libraries that I need to add as ADDLIB libX.a
.
I want to automate this. I have a variable in Makefile which stores all these libraries.
Inside Makefile target, I want to do,
my_target:
# Get all libraries from the variable $(libraries).
# Combine all of them into a single file using archiver as above
I couldn't find a way to do it since each 'line' or sub-command inside target is run in it's own shell.