I have a package written by someone else; I can't change the files in that package. In that package there's a Makefile with a rule like this:
$(BIN)/progA: <long list of .o files>
$(LINK.cc) $^ -o $@
I want to write a GNU make "wrapper" around that Makefile to build a library instead of a binary from the same list of .o files. Ideally I'd like something like this:
include package/Makefile
$(LIB)/progA.so: <magically copy the prerequisites for $(BIN)/progA>
$(LD) -shared $(LDFLAGS) $^ $(LIBS) -o $@
Of course, I could just copy-n-paste the list from the package's Makefile to mine, but that package is updated frequently; I prefer it if my build process would auto-magically pick up any changes to the package's changes in its Makefile.
My only other solution is something complex: Use sed or awk or perl to scan the package's Makefile, pull out that list of .o files, and assign it to a variable in my wrapper make file. I'd like to avoid that if I can.