如果 makefile 更改,如何强制 make 运行干净的目标
如果makefile发生变化,make会重建所有目标,对吗?
但是如何告诉 make 如果在 makefile 更改后,它应该运行 make clean
然后运行 make
呢?
或者在这种情况下如何指示 make 运行其他命令?我必须写一种特殊的目标吗?
If makefile changes, make rebuilds all targets right?
But how to tell make that if after makefile changed, it shall run make clean
and then make
?
Or how to instruct make to run some other command in that situation? Do I have to write a special kind of target?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以尝试一下:
我不是
make
专家,所以我不知道这是否是一个可怕的黑客,但它在我有限的测试中有效;-)You could try this:
I'm not a
make
expert so I don't know if that's a horrible hack, but it worked in my limited tests ;-)粗糙但有效(我想不出更优雅的东西):
Crude but effective (I can't think of anything more elegant):
我相信您希望自动运行 clean,因为您希望在调用 make 时重建某些目标。这可以通过将名为
FORCE
的依赖项添加到要始终构建其目标的规则中来实现,然后像这样定义FORCE
:即没有规则,也没有依赖项。请参阅 http://www.gnu.org/software/make /manual/make.html#Force-Targets
如果您希望重新编译所有文件,请将以下内容添加到 makefile 中:
I believe that you want to run clean automatically because you want certain targets to be rebuilt whenever make is called. This can be achieved by adding a dependency named
FORCE
to the rule whose target you want to build always and then defineFORCE
like this: ie no rule and no dependency.Please see http://www.gnu.org/software/make/manual/make.html#Force-Targets
If you want all files to be recompiled, you add the following to the makefile: