取决于make文件本身
如果 Makefile 本身发生更改,安全的做法是认为所有目标都已过时。
有没有聪明的方法来添加这种依赖关系?还有其他选择吗?
In the event that a Makefile itself is changed, a safe bet would be to consider all targets out of date.
Is there a clever way to add this dependency? Are there any alternatives?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
确保目标文件依赖于 makefile:
其中
Makefile
是 make 文件的名称。Make sure the object files depend on the makefile:
Where
Makefile
is the name of the make file.这是一个安全的赌注,但却是一个糟糕的主意。示例:您正在使用 automake 并更新
Makefile.am
以添加单个源文件。正确的响应是仅编译新文件并将其链接到其中。在您的方案中,所有内容都将被重建。此外,添加依赖项不会执行任何操作,除非您触摸该文件,例如:
这将使使用 mtime 来检测并发修改的编辑器出错(emacs 就是一个例子)。
如果您正在做一些重大的事情,只需在进行更改后运行
make clean all
即可。A safe bet, but a terrible idea. Example: you're using automake and update
Makefile.am
to add a single source file. The correct response is to compile just the new file and link it in. In your scheme everything would be rebuilt.Moreover, adding the dependency isn't going to do anything unless you touch the file, something like:
This will then trip up editors that use the mtime to detect concurrent modification (emacs is one example).
If you're doing something major, just run
make clean all
after doing the change.自 GNU make 4.3 版本以来,现在可以使用这两个 特殊变量:
让每个目标都依赖于当前的 make 文件:
将以下行放在文件顶部附近(在任何包含之前,因为它会影响 MAKEFILE_LIST):
让每个目标都依赖于当前的 make 文件以及包含的 make 文件
将以下行放在文件末尾:
Since GNU make version 4.3 it is now possible with the use of those two special variable:
To have every target depend on the current make file:
Put near the top of the file (before any include since it would affect the MAKEFILE_LIST) the following line:
To have every target depend on the current make file and also the make files which were included
Put the following line at the end of your file: