我正在尝试使用multiline variable definition in my Makefile,但它似乎对我不起作用:
$ cat Makefile
define foo =
I'm a little teapot
short and stout
here is my handle
here is my spout
endef
all:
echo "$(foo)"
$ make all
echo ""
$ make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
我做错了什么?
答案 0 :(得分:2)
试试这个:
define foo
I'm a little teapot
short and stout
here is my handle
here is my spout
endef
$(info $(foo))
all:
echo the shell dislikes multiline variables
正在定义的变量名称后面的=
似乎不适用于3.81中的define
语句,如果 echo 是多行变量, shell会将第一行之后的行解释为命令。