在 bobbogo 对 Stack Overflow 问题的回答中How to write loop in makefile? ,展示了如何在 makefile 中编写与以下伪代码等效的代码:
For i in 1, ..., n:
Add the following rule "job_$i: ; ./a.out $i > output_$i"
正如答案本身所指出的,bobbogo 解决方案的优点在于,如果您指定“-j num_threads”,作业将并行运行。其他明显且更简单的解决方案不具有此属性。
我的问题:我怎么能做同样的事情,但对于嵌套循环,即:
For i in 1, ..., n:
For j in 1, ..., m:
Add the following rule "job_$i_$j: ; ./a.out $i $j > output_$i_$j"
我只期望使用 GNU Make。提前致谢!