[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Pattern rule executed multiple times with multiple jobs
From: |
Kevin Locke |
Subject: |
Re: Pattern rule executed multiple times with multiple jobs |
Date: |
Sat, 09 Aug 2014 16:45:29 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0 |
Hi Philip,
Thank you very much for the response and explanation, that explains a lot.
On 08/09/2014 04:15 PM, Philip Guenther wrote:
On Sat, Aug 9, 2014 at 2:24 PM, Kevin Locke <address@hidden
<mailto:address@hidden>> wrote:
[...]
For example, consider the following Makefile:
all: foo1 foo2
foo%:
sleep 2
touch foo1 foo2
...
Demonstrating that the recipe is executed twice, once for each target.
Is this the expected behavior? Am I misinterpreting the sentence from
the manual?
Yep. That pattern rule only has a single target "foo%", not multiple
targets. An example of the latter can be found a little further down
in the manual:
Ah yes, you are correct, I was misinterpreting what a "target" is. I had
assumed it was the thing which is matched against the pattern in the
rule rather than the pattern itself. My mistake.
Is there any way to specify that the rule should be run
once to make both files, even when running with multiple jobs, without
resorting to one of the hacks in the oft-cited CMCrossroads article on
Rules with Multiple Outputs in GNU Make[2]?
An example closer to yours would be
%1 %2:
sleep 2
touch $*1 $*2
$ make -j3 foo1 foo2
sleep 1
touch foo1 foo2
make: Nothing to be done for 'foo2'.
$
Thanks, that works for me. It's not quite so simple in the makefile
which provoked the question, but I was able to create a pattern for each
generated file through some function calls and it seems to be working well.
Thanks again,
Kevin