I've read (and use the recipes from) the automake manual section "Handling Tools that Produce Many Outputs". However, these recipes require a lot of boilerplate code which annoyingly obscures the actual rule they are protecting - a two line rule is swamped by a dozen lines of boilerplate.
It's just struck me that automake is good at inserting lots of boilerplate code into makefiles! Has anyone considered adding some sort of support to automake to allow such rules to get rewritten automatically? I don't have a concrete proposal, but it seems that this would need to be controllable rather than automatically adjusting any rule with multiple targets, if only to avoid messing with rules which are already protected. Two initial ideas - either a new automake option, or special handling for a rule which is written with some other token instead of a ":" (or perhaps both?). GNU make support "::" rules, but ":::" could be used perhaps. The multiple colons are mnemonic for multiple outputs. So this in Makefile.am would mean "automatically protect this rule for me": data.c data.h::: data.foo foo data.foo The main difficulty I see is what to name the auxiliary files (witnesses, locks, etc) so as avoid clashing with user files. Perhaps creating a subdirectory for them would be best - it would make it easy to ignore them in a VCS. Thoughts? Cheers, Olly