How can I force Make to execute a recipe all the time

折月煮酒 提交于 2019-12-05 14:32:15
Etan Reisner

I think a Force Target is what you are looking for here.

lib1.a: FORCE
        $(MAKE) -C sub_dir all

FORCE: ;

As compared to a .PHONY rule (as suggested by @MadScientist here) this will not in-and-of-itself force all the targets that depend on lib1.a to rebuild all the time. It will only do that if lib1.a actually changes.

A better solution though is likely to get rid of the sub-make entirely and actually have the dependency information for lib1.a available to this makefile (either directly or via an included makefile in sub_dir) because that avoids this entire "force this recipe because I can't tell you how to tell if the target needs updating" problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!