gpt4 book ai didi

gnu-make - GNU Make : disable all built-in rules, 除了所需的

转载 作者:行者123 更新时间:2023-12-02 21:47:50 27 4
gpt4 key购买 nike

过去两次,GNU make 毁掉了我的工作,因为它的一些内置规则以 .c 文件作为目标。

如果您有一个名为 foo.c 的文件,还有一个 foo.l Lex 扫描器或 foo.y Yacc 解析器,请观看出去! GNU make 假设 .c 文件是由这些文件组成的目标(这显然是 POSIX 要求!),并且它将执行类似 mv y.tab.c foo.c< 的操作lex -t foo.l > foo.c

如何禁用所有这些隐藏的危险规则(无论已知或未知),同时保留有用的规则?

具体来说,我们如何向 GNU Make 提出此请求:“请保留与(例如).c 和 .o 文件相关的所有规则,并禁用涉及任何其他文件类型的所有规则”?

最佳答案

来自the manual :

Many of the predefined implicit rules are implemented in make as suffix rules, so which ones will be defined depends on the suffix list... If you modify the suffix list, the only predefined suffix rules in effect will be those named by one or two of the suffixes that are on the list you specify; rules whose suffixes fail to be on the list are disabled... If you wish to eliminate the default known suffixes instead of just adding to them, write a rule for .SUFFIXES with no prerequisites. By special dispensation, this eliminates all existing prerequisites of .SUFFIXES. You can then write another rule to add the suffixes you want.

.SUFFIXES:            # Delete the default suffixes
.SUFFIXES: .c .o # Define a new suffix list

关于gnu-make - GNU Make : disable all built-in rules, 除了所需的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19204772/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com