help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Rules with multiple outputs


From: Steve Deiters
Subject: RE: Rules with multiple outputs
Date: Mon, 12 Apr 2010 11:47:31 -0500

> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden On 
> Behalf Of Lane Schwartz
> Sent: Monday, April 12, 2010 9:23 AM
> To: address@hidden
> 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]