Rules with Multiple Outputs in GNU Make

Written by: Electric bee

I recently wrote an article for CM Crossroads exploring various strategies for handling rules that generate multiple output files in GNU make. If you've ever struggled with this problem, you should check out the article . I don't want to spoil the exciting conclusion, but it turns out that the only way to really correctly capture this relationship in GNU make syntax is with pattern rules. That's great if your input and output files share a common stem (eg, "parser" in parser.i, parser.c and parser.h), but if your files don't adhere to that convention, you're stuck with one of the alternatives, each of which have some strange caveats and limitations.

Here's a question for you: if CloudBees Accelerator had an extension that allowed you to explicitly mark a non-pattern rule as having multiple outputs, would you use it? For example:

<font color="red">#pragma multi</font> 
something otherthing: input
	@echo Generating something and otherthing from input...

What do you think? Comments encouraged.

Stay up to date

We'll never share your email address and you can opt out at any time, we promise.