I have two makefiles, named Makefile4MyClassA and Makefile4MyClassBC, which I include in a makefile (see attachments):
Sorrowly, when running “make clean” I get the following error:
Makefile4MyClassBC:76: warning: overriding commands for target .cxx.o' Makefile4MyClassA:76: warning: ignoring old commands for target.cxx.o’
clean-MyClassA
make: clean-MyClassA: Command not found
make: *** [clean] Error 12
Why is clean-MyClassA not recognized?
How can I avoid the two warnings?
Thank you, but sorrowly this results in the following error:
Makefile4MyClassBC:76: warning: overriding commands for target `.cxx.o'
Makefile4MyClassA:77: warning: ignoring old commands for target `.cxx.o'
make: *** No rule to make target `clean-MyClassBC', needed by `clean'. Stop.
Interestingly, libMyClassBC is always cleaned but not libMyClassA. Probably, because “include Makefile4MyClassBC” is called after “include Makefile4MyClassA”.
Meanwhile, I have found the following solution, but I think that this solution is not the way it should be done in a makefile:
clean::
make -f Makefile4MyClassBC clean
make -f Makefile4MyClassA clean
Yes indeed … the problem is that both of your makefile use the exact same variables … hence their over-ridden by the 2nd include … and your clean target are written using those variables … so clean-MyClassA is called but does not do what you expect.
Conclusion do NOT really on doing
include Makefile4MyClassA
include Makefile4MyClassBC