是否应该在 Makefile 中使用局部变量的较长同义词?

Should the longer synonyms for local variables be used in a Makefile?

make 中(我正在使用 OpenBSD 的实现,但我想这个问题也与 GNU make 相关),我们有以下所谓的 局部变量

@    The name of the target
%    The name of the archive member (for library rules)
!    The name of the archive file (for library rules)
?    The list of prerequisites for this target that were deemed out of date
<    The name of the prerequisite from which this target is to be built (for inference rules)
*    The file prefix of the file, containing only the file portion, no suffix or preceding directory components

(大致来自 OpenBSD 上的 make(1)

这些局部变量具有同义词:例如,.IMPSRC 代表 <.TARGET 代表 @。 FreeBSD 中的手册说这些较长的版本是首选。 OpenBSD 的手册页没有提到这样的东西,但说这些较长的名称是一个扩展。

名字越长越好吗?哪个兼容性更好?都是POSIX?

这些变量在 GNU make 中称为 automatic variables,在 POSIX 标准中称为 内部变量

这些长名称纯粹是 BSD make 的发明,它们在任何其他版本的 make(例如 GNU make)中都不存在,并且在 make 的 POSIX standard 中也没有提及。

是否使用它们取决于您,但它们是完全不可移植的。当然,如果你想实现一个兼容层,你总是可以自己定义它们。