[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Parallel make not working the way I expect...
From: |
David Wuertele |
Subject: |
Re: Parallel make not working the way I expect... |
Date: |
Fri, 9 Feb 2007 23:54:11 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Thanks for the help!
Philip Guenther <guenther <at> gmail.com> writes:
> It might look like it tells make that to build $(LOTS_OF_FILES),
> invoke $(CWBLOF) just once, but that's not correct. A (non-pattern)
> rule with multiple targets is *exactly* the same as if each target was
> listed separately, ala:
>
> one: Makefile
> $(COMMAND_WHICH_BUILDS_LOTS_OF_FILES)
> two: Makefile:
> $(COMMAND_WHICH_BUILDS_LOTS_OF_FILES)
> ...etc
OK.
> Choice 2) use a pattern rule with multiple targets so that make knows
> that one command builds all of them. You should arrange for the files
> to have names that follow some sort of pattern (all have the same
> prefix, of suffix, or *something* in common) so that the patterns you
> give use to match them make some sense.
There are hundereds of times when I have to build someone else's code by running
"$(MAKE) -C $(SOMEONE_ELSES_DIR)", and it spits out multiple files that I
require. For example, the subdir might be "portmap_4" and it makes "portmap",
"pmap_dump", and "pmap_set". I don't have any control over their makefile, so I
can't arrange for the files to have a common prefix. Except: maybe I could use
the subdirectory as a prefix? I tried this:
LOTS_OF_FILES := dir/one dir/two dir/three dir/four dir/five dir/six
all: $(LOTS_OF_FILES)
COMMAND_WHICH_BUILDS_LOTS_OF_FILES := for file in $(LOTS_OF_FILES); do mkdir -p
`dirname $$file` && echo hello >> $$file; done
$(LOTS_OF_FILES): dir/%: Makefile
$(COMMAND_WHICH_BUILDS_LOTS_OF_FILES)
clean:
rm -rf $(LOTS_OF_FILES)
Is that what you mean by a pattern rule? It had the same problem as before:
$ make -j 10
for file in dir/one dir/two dir/three dir/four dir/five dir/six; do mkdir -p
`dirname $file` && echo hello >> $file; done
for file in dir/one dir/two dir/three dir/four dir/five dir/six; do mkdir -p
`dirname $file` && echo hello >> $file; done
for file in dir/one dir/two dir/three dir/four dir/five dir/six; do mkdir -p
`dirname $file` && echo hello >> $file; done
for file in dir/one dir/two dir/three dir/four dir/five dir/six; do mkdir -p
`dirname $file` && echo hello >> $file; done
for file in dir/one dir/two dir/three dir/four dir/five dir/six; do mkdir -p
`dirname $file` && echo hello >> $file; done
for file in dir/one dir/two dir/three dir/four dir/five dir/six; do mkdir -p
`dirname $file` && echo hello >> $file; done
$
Dave