在 makefile 中使用大括号进行变量扩展不起作用 [英] Using curly brackets for variable expansion in makefile doesn't work
问题描述
当我在 shell 上运行下面的命令时,它工作正常.但是如果我把它写在一个 Makefile 中并用make"命令调用它就行不通了.
When I run below command on shell, it works properly. but if I write it in a Makefile and call it with "make" command it doesn't work.
cp wpa_{cli,supplicant,passphrase,event}/usr/local/bin/
cp wpa_{cli,supplicant,passphrase,event} /usr/local/bin/
make"命令后的错误:
error after "make" command:
cp: 无法统计 `wpa_{cli,supplicant,passphrase,event}': 没有这样的文件或目录
cp: cannot stat `wpa_{cli,supplicant,passphrase,event}': No such file or directory
我该怎么做才能让它与 Makefile 一起工作?我使用 Ubuntu 12.04.相同的 Makefile 适用于其他 Linux 发行版.
What can i do to make it work with Makefile? I use Ubuntu 12.04. Same Makefile works on other linux distributions.
推荐答案
Make 默认使用不支持大括号扩展的老式 Bourne shell (/bin/sh).如果尚未设置,请将 makefile 中的 SHELL 变量设置为/bin/bash.
Make uses old-school Bourne shell (/bin/sh) by default which does not support brace expansion. Set the SHELL variable in your makefile to /bin/bash if it's not already set.
只需在 makefile 的顶部添加一行:
Just add a line in the top of your makefile with:
SHELL=/usr/bin/bash
(请确认您的 bash 路径).
(please confirm your bash path).
这篇关于在 makefile 中使用大括号进行变量扩展不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!