我有一个像这样的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
$
我试试这个,效果很好:
test:
@echo "test 1"
@# echo "test 2"
输出:
$ make test
test 1