在我的项目中,我对makefile有以下要求

  • 我们有一个makefile,它包含定义许多宏的常见makefile和许多规则* .c和* .o(如果它们不存在) .

  • 在我的makefile中,应检查依赖关系是否存在给定目标

  • 如果依赖项(时间戳)中有更新,则应更新目标 .

  • 但是在任何情况下(虽然依赖项不存在),不应该从常见的makefile为我的依赖项执行特殊规则(在步骤1中定义) . 我想跳过常见makefile中定义的规则 . 只需检查依赖关系,时间戳,永远不要执行任何指定依赖关系的规则 .

  • 仅订购先决条件在这里没有帮助,因为如果依赖项中有更新,则不会更新目标 .

all: bin
bin: a.o
a.o: a.c ---->(check existance and timestamp, but never to go to target a.c at any case. Error is ok if file is not present)
    echo building a.o
    touch a.o
a.c:   ---> (Assume that this rule is included from common makefile)
    touch a.c
    enter code here