简体   繁体   English

当“$@”不在 Makefile 的规则中时,它是什么意思?

[英]What does ‘$@’ mean when it isn't in a rule of a Makefile?

# Linker scripts preprocessor (.lds.S -> .lds)
# ---------------------------------------------------------------------------
quiet_cmd_cpp_lds_S = LDS     $@
      cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -U$(ARCH) \
                         -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<

$(obj)/%.lds: $(src)/%.lds.S FORCE
    $(call if_changed_dep,cpp_lds_S)

Above is the code in scripts/Makfile.build.I was reading the arch/arm/kernel/vmlinux.lds.S and I couldn't find the 'INPUT' for the linker script.I guessed the 'INPUT' is setted when the vmlinux.lds.S is compiled.Then I found the code above.I've learned that '$@' is the file name of the target of a rule.But this one is not in a rule.So what it represents and where is the 'INPUT'?以上是 scripts/Makfile.build 中的代码。我在阅读 arch/arm/kernel/vmlinux.lds.S 时找不到 linker 脚本的“INPUT”。我猜“INPUT”是在什么时候设置的vmlinux.lds.S被编译了。然后我找到了上面的代码。我了解到'$@'是规则目标的文件名。但是这个不在规则中。那么它代表什么和“输入”在哪里?

You don't show it, but it is almost certainly the case that if_changed_dep is another macro defined elsewhere in that makefile that expands to either $(quiet_cmd_$1) or $(cmd_$1) (probably depending on how make was invoked, or what arguments it was given), so as applied ends up generating one of those two macro definitions as the action for the rule.你没有显示它,但几乎可以肯定的是if_changed_dep是 makefile 中其他地方定义的另一个宏,它扩展为$(quiet_cmd_$1)$(cmd_$1) (可能取决于 make 的调用方式,或者什么arguments 给出),因此应用最终会生成这两个宏定义之一作为规则的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM