如果我在 GNU Make 3.81 / RHEL5 下运行以下 makefile:
all: A1B/C A1B/D A2B/C A2B/D
A%B/C A%B/D: E.%
@echo "Creating '$@' from '$^' with stem '$*'"
E.1 E.2:
@echo "Generate '$@'"
我得到以下输出:
Generate 'E.1'
Creating 'A1B/C' from 'E.1' with stem '1'
Generate 'E.2'
Creating 'A2B/C' from 'E.2' with stem '2'
为什么没有生成文件 A1B/D 和 A2B/D?(我的测试用例中不存在具有此类名称的文件)
如果我通过命令行指定目标,则显示“无事可做”:
make A1B/C A1B/D A2B/C A2B/D
Generate 'E.1'
Creating 'A1B/C' from 'E.1' with stem '1'
make: Nothing to be done for `A1B/D'.
Generate 'E.2'
Creating 'A2B/C' from 'E.2' with stem '2'
make: Nothing to be done for `A2B/D'.
如果我将隐式规则复制到他们的目标中,它会起作用:
all: A1B/C A1B/D A2B/C A2B/D
A%B/C: E.%
@echo "Creating '$@' from '$^' with stem '$*'"
A%B/D: E.%
@echo "Creating '$@' from '$^' with stem '$*'"
E.1 E.2:
@echo "Generate '$@'"
Generate 'E.1'
Creating 'A1B/C' from 'E.1' with stem '1'
Creating 'A1B/D' from 'E.1' with stem '1'
Generate 'E.2'
Creating 'A2B/C' from 'E.2' with stem '2'
Creating 'A2B/D' from 'E.2' with stem '2'
根据文档,这不应该有所作为。
提前致谢。
迈克尔