给定这个非常简单的Makefile:
- all:
- @mkdir -pv test/{a,b}
我在OS X 10.6.8和CentOS 5.5上得到这个输出:
- mkdir: created directory `test'
- mkdir: created directory `test/a'
- mkdir: created directory `test/b'
但是在Ubuntu 11.04我得到这个:
- mkdir: created directory `test'
- mkdir: created directory `test/{a,b}'
在所有平台的shell中手动运行命令mkdir -pv test / {a,b}可以获得预期的结果.
所有平台上的GNU Make版本相同:
- 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 is built for [PLATFORM]
在Ubuntu下有什么不同,为什么shell扩展在那里工作?
问题可能是Make spawns / bin / sh.它通常是系统默认shell的符号链接.
选项1
你可以确定它指向bash(因为这是一个bashism).可能现在是/ bin / dash或/ bin / sh,具体取决于您的Ubuntu版本.
选项2
更容易选择:
- SHELL=/bin/bash
- all:
- @echo a{3,4}
- @bash -c 'echo a{3,4}'
除非您注释掉SHELL =行,否则打印两次相同的输出
选项3
- make SHELL=/bin/bash
注意与子生成文件或包含的交互.您可能需要查看make -e选项和make export关键字:http://www.gnu.org/s/hello/manual/make/Variables_002fRecursion.html