Recursive make and variations on the theme
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Feb 23, 2011, 09:56 UTC
- Message-ID
- <20110223095650.GE30485@elie>
- In-Reply-To
- <20110223084329.GA10738@sigill.intra.peff.net>
Jeff King wrote:
Show 9 quoted lines
> The problem is that no single make was > allowed to see the whole dependency tree. > > I know GNU make does have some magic for communicating between recursive > makes. Does it handle this situation? > > You can fix this with a rule like "only invoke recursive makes on > directories _below_ you, never above or to the side". But then you can't > run "make" from inside cmds/.
In that story, commands/Makefile would make commands/built-in.a and various commands/foo.o. The toplevel makefile would pass "make -C commands" a long list of targets to build, presumably deduced from $(MAKECMDGOALS). Not pleasant, I agree.
Show 5 quoted lines
>> - keep careful track of what directory "make" was run from; [*] >> [...] >> [*] is a little hazy and sounds hackish. > > Yeah, you have to be careful with paths.
It could be pretty simple by maintaining a $(prefix_) variable representing the path from the cwd to the directory containing the makefile. Might try it out.
> I think a more sane way would > be a single top-level Makefile that [...] contains everything
That sounds best to me in the short term, too.
> A dummy Makefile in each subdir that cd's to the toplevel and runs a > specific target. So from the top-level, "make" would build everything, > "make lib" would build stuff in the lib directory, and the Makefile in > lib/ would just do "cd .. && make lib".
Yes, reasonable.
Ciao, Jonathan