无法在Makefile中调用bash函数 [英] Cannot call bash function inside makefile
问题描述
我有一个印象,我可以在GNU makefile中调用bash函数,但似乎是错误的.这是一个简单的测试,我已经定义了此功能:
I have an impression that I can call bash function inside GNU makefile, but seems wrong. Here is a simple test, I have this function defined:
>type lsc
lsc is a function
lsc ()
{
ls --color=auto --color=tty
}
这是我的Makefile:
Here is my Makefile:
>cat Makefile
all:
lsc
这是我运行make的结果:
Here is what I get in running make:
>make
lsc
make: lsc: Command not found
make: *** [all] Error 127
我的印象不对吗?还是有任何环境设置问题?我可以在命令行中运行"lsc".
Is my impression wrong? Or is there any env setup issue? I can run "lsc" at the command line.
推荐答案
您不能调用Makefile中的bash函数或别名,只能调用二进制文件和脚本.但是,您可以做的是调用交互式bash,并指示它调用您的函数或别名:
You cannot call bash functions or aliases in a Makefile, only binaries and scripts. What you can do however, is calling an interactive bash and instruct it to call your function or alias:
all:
bash -i -c lsc
例如,如果在.bashrc
中定义了lsc
.
if lsc
is defined in your .bashrc
, for example.
这篇关于无法在Makefile中调用bash函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!