我有一个像这样的makefile:
install:
@somecommand
#some explanation for next command
@lastcommand
发生的情况是,当我执行
#some explanation for next command
时,会打印注释make install
。如何在 makefile 中做出不被打印的注释?也许我正在寻找 windowsy 的 unix 等效项 echo off
?
(实际上,与这个问题相反。)
不要缩进注释 - 当该行以制表符开头时,它是由 shell 执行的命令(并且 shell 将注释视为注释)。
概念证明 (
ss.mk
):
all:
echo "This is the first command"
# This comment is echoed
# This comment is not echoed
echo "This is the second command"
输出示例:
$ make -f ss.mk
echo "This is the first command"
This is the first command
# This comment is echoed
echo "This is the second command"
This is the second command
$
只需在行首使用
@
。
all:
@echo "test 1"
@# echo "test 2"
echo "test 3"
$ make
test 1
echo "test 3"
test 3