Hacker News new | ask | show | jobs
by mturmon 5254 days ago
Using "define" to set up templates for rules is pretty straightforward and very powerful. It allows the set of rules to be augmented at runtime, which can enable new uses of make.

I used this mechanism to automate a pipeline for scientific data. The template (the "define...endef" block) held several rules needed to re-make results for one granule of data. When you ran make, it looked for all source granules, and a foreach() mapping the template across the source granules, just as in the OP, set up rules for each one.

Then you could dump a new source granule in a directory, run make -j 8, and get parallel "builds" of the results for free.

As long as it's documented, it can save a lot of repetition.

Not coincidentally, jgc has a nice article on make debugging ;-)

http://drdobbs.com/article/print?articleId=197003338&sit...