我需要导出a user-defined GNU make function (即 a recursively expanded makefile variable )到子品牌。然而,make 似乎将所有此类变量扩展为简单扩展变量,这使得它们毫无用处。
这是一个例子:
“parent.make”的内容:
export myfunc = my arg is $1
$(info parent testing myfunc: $(call myfunc,parent))
all: ; $(MAKE) -f child.make
“child.make”的内容:
$(info child testing myfunc: $(call myfunc,child))
nullrule: ; @true
运行“make -fparent.make”会产生以下输出:
parent testing myfunc: my arg is parent
make -f child.make
child testing myfunc: my arg is
Parent 将 myfunc 作为包含“my arg is”的简单扩展变量导出到子 make,使其作为函数无用。
最佳答案
是否有原因导致公共(public)变量和函数无法放入父 makefile 和子 makefile 都包含的单独 makefile 中?
关于recursion - 将递归 makefile 变量导出到子 make,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7789389/