tech-toolchain archive

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

Re: (b)make: generating multiple targets at once



On Tue, Oct 22, 2019 at 06:09:39PM +0200, Edgar Fu? wrote:
 > Is there a way to sanely express the following in a Makefile?
 > 
 > dst/foo depends on src/foo, dst/bar depends on src/bar etc.
 > 
 > gen foo bar will generate dst/foo from src/foo and dst/bar from src/bar (etc)
 > 
 > gen has a large one-time overhead, so gen foo bar ... is hugely preferrable 
 > to gen foo; gen bar; gen ...
 > 
 > It may be tolerable to call gen foo bar if only dst/foo is out-of-date, but 
 > it's not tolerable to call gen in case nothing is out-of-date.

The traditional, correct way is

	dst/foo dst/bar: src/foo src/bar
		gen foo bar

but that doesn't work with bmake -j (this comes up periodically and I
have a real solution, but haven't had time to implement it) so you
need to write

	dst/foo: src/foo src/bar
		gen foo bar
	dst/bar: dst/foo
		@true

but this constitutes lying to make about what's happening, so it's a
hack, not a solution :-|

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index