[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Rules with multiple outputs
From: |
Lane Schwartz |
Subject: |
Rules with multiple outputs |
Date: |
Mon, 12 Apr 2010 09:22:35 -0500 |
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
When command 'foo' is run, it generates files a, b, and c. The problem here is
that if the make file is run with -j, there is a good chance that foo will be
run multiple times, since make treats the above command as equivalent to the
three commands below:
a: d
foo d
b: d
foo d
c: d
foo d
If a command produces multiple outputs that share a common pattern in their
name, the solution below becomes possible, and make handles this properly when
-j is used.
%.x %.y %.z: %.q
bar $<
This is the solution described in section 10.5.2 of the GNU Make manual, as
well as at
http://www.cmcrossroads.com/ask-mr-make/12908-rules-with-multiple-outputs-in-gnu-make.
Is anyone aware of a general solution for this problem, where running a
command produces multiple output files that do not share a common pattern in
their names?
I suspect that no elegant general solution exists. If that is the case, I would
be interested in proposing an extension to make to allow for this
functionality, and would be willing to help implement it. I'm not familiar with
the GNU make developer community, so any pointers to the appropriate person or
persons to discuss such ideas would be greatly appreciated.
Thanks,
Lane
- Rules with multiple outputs,
Lane Schwartz <=