define target
echo $0
echo $1
echo $2
endef
all:
$(call target,hello, world)
clean:
$(call target,clean)
.PHONY: all clean
执行make 或者make all
执行的结果是:
echo target
target
echo hello
hello
echo world
world
本文介绍了一个简单的Makefile示例,展示了如何定义目标和规则,使用make命令执行特定任务,如打印传递给target的参数。通过这个例子,读者可以了解Makefile的基本语法和工作原理。
define target
echo $0
echo $1
echo $2
endef
all:
$(call target,hello, world)
clean:
$(call target,clean)
.PHONY: all clean
执行make 或者make all
执行的结果是:
echo target
target
echo hello
hello
echo world
world

被折叠的 条评论
为什么被折叠?