Makefile question

I have 2 libraries in 2 different directories that I build with Makefiles.

library B depends on library A. If I modify a .cpp file in library A and run lib B's Makefile can I have B's makefile to automatically rebuild library A?

I am now rebuilding A, followed by B... but I'd like B to rebuild A automatically if it needs rebuilding. This is a streamlined example, but my real situation is
more complicated. I'd like the makefile for the final application to cause all
dependent libraries to build, if necessary so that I don't have to manually build them in the correct order.

I've tried "include ../A/Makefile" in B's Makefile, but I get errors. I think its because the directory doesn't change to ../A

Makefile:81: warning: overriding commands for target `all'
../A/Makefile:78: warning: ignoring old commands for target `all'
Makefile:98: warning: overriding commands for target `clean'
../A/Makefile:99: warning: ignoring old commands for target `clean'
make: *** No rule to make target `tinystr.o', needed by `A.a'. Stop.


Does anyone know how to make this work?

William
If I modify a .cpp file in library A and run lib B's Makefile can I have B's makefile to automatically rebuild library A?


Generally, there is a top-level Makefile that you could build that will check all dependancies and build any libraries and/or re-link them as necessary. Building B and expecting A to rebuild sounds a little nuts.
of course, if you specify the make file properly.

libraries, conceptually, don't change, so generally
one doesn't use them as a dependency.

If they are so closely coupled can they not be merged?


I agree with moorecm. I would make a top-level Makefile to determine which of the libraries needed rebuilding.
Topic archived. No new replies allowed.