首页 > 解决方案 > Make:动态子目录的静态配方

问题描述

给定(简化)表格的层次结构

A
  source
  target
B  
  source
  target
...

target每个子目录中都有一个专门从其中的子目录构建的子目录source。我想通过make来实现这一点。

当然,一个makefile如

%target: %source
    ...

可以完成这项工作,但这也可以匹配A/wrong_target. 但是,删除%'s 不起作用;似乎targetthen 只匹配.但不匹配子目录。

有什么好的方法来实现这一点吗?

标签: gnu-make

解决方案


When you say "a hierarchy" do you mean a directory hierarchy?

Why don't you just enforce the directory by including the "/", like this:

%/target: %/source
         ....

推荐阅读