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 ;-)
(I'm not saying generating the rules from code in a real build system wouldn't be a good idea, jut that it isn't with make.)