> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On 
> Behalf Of Lane Schwartz
> Sent: Monday, April 12, 2010 9:23 AM
> To: [email protected]
> Subject: Rules with multiple outputs
> 
> Hi,
> 
> I am trying to solve an issue regarding rules with multiple 
> outputs. I would like my makefile to correctly handle these 
> rules, so that the generating commands are only run once, 
> even when make is run with -j (for parallel). I am aware that 
> a solution to handle this is using pattern rules, as in the 
> case when generating files using bison (section 10.5.2 GNU 
> Make manual). But, in my case the targets that are generated 
> tend not to share named patterns.
> 
> Here's an example of what I would like to do:
> 
> a b c: d
>       foo d


What I have done before is to make sure to only explicitly list the
commands for one target, and then list the others as a dependency.
Something like this.


OUTPUTS:=a b c

$(firstword $(OUTPUTS)):
        foo d

$(OUTPUTS): d
$(firstword $(OUTPUTS)): $(filter-out $(firstword
$(OUTPUTS)),$(OUTPUTS))


This will make sure the commands are run only once with make -j and
keeps the proper dependencies for all the outputs.


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to