需要一个可以处理丢失文件的makefile依赖规则 [英] Need a makefile dependency rule that can handle missing files

查看:148
本文介绍了需要一个可以处理丢失文件的makefile依赖规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在系统中使用GNU Make。在makefile的最后,我们有一个名为Makedepends的包,它使用-MM在gcc上打开一堆.d文件。然后,使用include $(CXXFILES:.cc = .d)行为.cc文件添加.d文件。但是当我们删除文件或移动文件时,依赖步骤中断,我们必须手动删除.d文件(即使是make clean也不起作用,因为依赖关系失败)



有没有办法生成这些依赖性的.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆