Makefile 在奇怪的情况下拒绝匹配目标模式
Makefile refuses to match target patterns under strange circumstances
我在运行时遇到了一些奇怪的行为
make hello-there
makefile 是
hello-%:
@echo hi $*
我明白了
hi there
但是当 makefile 只是
hello-%:
我明白了
make: *** No rule to make target `hello-there'. Stop.
在第二种情况下,您没有为 hello-%
.
定义任何规则
来自 documentation 的第 5 章:
Each line in the recipe must start with a tab, except that the first
recipe line may be attached to the target-and-prerequisites line with
a semicolon in between
你必须有解决这个问题的方法:
在定义目标名称的行末尾添加一个分号:
你好-%:;
在定义目标名称的行下方添加仅包含一个选项卡的行
我在运行时遇到了一些奇怪的行为
make hello-there
makefile 是
hello-%:
@echo hi $*
我明白了
hi there
但是当 makefile 只是
hello-%:
我明白了
make: *** No rule to make target `hello-there'. Stop.
在第二种情况下,您没有为 hello-%
.
来自 documentation 的第 5 章:
Each line in the recipe must start with a tab, except that the first recipe line may be attached to the target-and-prerequisites line with a semicolon in between
你必须有解决这个问题的方法:
在定义目标名称的行末尾添加一个分号:
你好-%:;
在定义目标名称的行下方添加仅包含一个选项卡的行