需要一个可以处理丢失文件的makefile依赖规则 [英] Need a makefile dependency rule that can handle missing files
问题描述
有没有办法生成这些依赖性的.d文件,还是包含这些依赖性的.d文件,它将优雅地处理文件删除或重定位?
编辑:例如:我有serial.cc和makefile生成一个serial.d文件,它对buffer.h有一个依赖,但是我改变它,所以我不需要buffer.h,我删除了buffer.h。下一次运行make时,它会阻塞,因为它包含仍然使serial.o依赖于buffer.h的.d文件。
http://make.paulandlesley.org/autodep.html 有一个描述这个确切的问题,以及几种方法。第一个有点误导,但高级基本上是发生的。
We use GNU Make for our system. At the end of our makefiles, we have an include called Makedepends which generates a bunch of .d files using -MM switch on gcc. We then include the .d file for each .cc file using an include $(CXXFILES:.cc=.d) line. But when we delete file or move files, the dependancies step breaks and we have to manually delete the .d files (even a make clean doesn't work because the dependencies fail)
Is there a way to generate these dependency .d files or include these dependency .d files which will gracefully handle a file deletion or relocation?
EDIT: For example: I have serial.cc and the makefiles generate a serial.d file which has a dependency on buffer.h but then I change it so I don't need buffer.h any more and I delete buffer.h. Next time I run make, it will choke because it includes the .d file which still makes serial.o depend on buffer.h.
http://make.paulandlesley.org/autodep.html has a description of this exact problem, and a couple of ways around it. The first is a bit misguided, but the "advanced" is essentially spot on.
这篇关于需要一个可以处理丢失文件的makefile依赖规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!