kbuild - building a module/target from multiple directories
With kbuild in 2.5, how do I specify that a module/target is to be built of object files and sub-directories ?
The "obvious" approach :
obj-$(CONFIG_BLAH) := blah.o
blah-objs := blah_init.o blahstuff/
doesn't work. Is there an example of a module doing this ?
findall Makefile | xargs grep '+=' | grep -- -objs | awk -F: '{print $2}' | grep / isn't promising ...
I'd like to avoid the awkwardness of multiple modules and the unpleasantness of too many files in a single directory
thanks
john
Signature · 2 lines
"Of all manifestations of power, restraint impresses the most." - Thucydides
Hi,
Quoted 10 lines · John Levon
With kbuild in 2.5, how do I specify that a module/target is to be built of object files and sub-directories ?
The "obvious" approach :
obj-$(CONFIG_BLAH) := blah.o
blah-objs := blah_init.o blahstuff/
doesn't work. Is there an example of a module doing this ?
What about:
blah/Makefile:
blah-objs := blah_init.o blahstuff/blahstuff.o
blah/blahstuff/Makefile:
blahstuff-objs := blah_didel.o blah_dadel.o blah_dumm.o
?
Regards, Thunder
Signature · 7 lines
(Use http://www.ebb.org/ungeek if you can't decode) ------BEGIN GEEK CODE BLOCK------ Version: 3.12 GCS/E/G/S/AT d- s++:-- a? C++$ ULAVHI++++$ P++$ L++++(+++++)$ E W-$ N--- o? K? w-- O- M V$ PS+ PE- Y- PGP+ t+ 5+ X+ R- !tv b++ DI? !D G e++++ h* r--- y- ------END GEEK CODE BLOCK------
Quoted 1 line · Thunder from the hill
blah-objs := blah_init.o
blahstuff/blahstuff.o
It won't descend to blahstuff/ directory then
(in fact it tries to build blahstuff/blahstuff.s)
regards
john
Signature · 2 lines
"Of all manifestations of power, restraint impresses the most." - Thucydides
Quoted 2 lines · John Levon
With kbuild in 2.5, how do I specify that a module/target is to be built of object files and sub-directories ?
Short answer: Don't.
Quoted 7 lines
The "obvious" approach :
obj-$(CONFIG_BLAH) := blah.o
blah-objs := blah_init.o blahstuff/
doesn't work. Is there an example of a module doing this ?
Well, first of all I'd rather discourage doing so in general. However, XFS is split into subdirs, so you could probably take a look at their latest CVS to see how it's done.
Basically, use only one Makefile and
blah-objs := blah_init.o blahstuff/blah1.o blahstuff/blah2.o ...
in there.
--Kai
Hi,
Quoted 1 line · John Levon
It won't descend to blahstuff/ directory then
This was not the complete solution then. Of course you still have to descend into blahstuff this way, but you compile all the blahstuff together into blahstuff.o, then include that from the upper directory.
Regards, Thunder
Signature · 7 lines
(Use http://www.ebb.org/ungeek if you can't decode) ------BEGIN GEEK CODE BLOCK------ Version: 3.12 GCS/E/G/S/AT d- s++:-- a? C++$ ULAVHI++++$ P++$ L++++(+++++)$ E W-$ N--- o? K? w-- O- M V$ PS+ PE- Y- PGP+ t+ 5+ X+ R- !tv b++ DI? !D G e++++ h* r--- y- ------END GEEK CODE BLOCK------
Quoted 4 lines · Kai Germaschewski
Quoted 2 lines
With kbuild in 2.5, how do I specify that a module/target is to be built of object files and sub-directories ?
Short answer: Don't.
Why not ? Simply because kbuild can't handle it nicely ?
Quoted 1 line
blah-objs := blah_init.o
blahstuff/blah1.oblahstuff/blah2.o...
Hmmm, that "works" I suppose
thanks
john
Signature · 2 lines
"Of all manifestations of power, restraint impresses the most." - Thucydides
Quoted 8 lines · John Levon
Quoted 4 lines · Kai Germaschewski
Quoted 2 lines
With kbuild in 2.5, how do I specify that a module/target is to be built of object files and sub-directories ?
Short answer: Don't.
Why not ? Simply because kbuild can't handle it nicely ?
Well, if you see the parts of your project as really separate, it probably makes sense to do the modularization also at the module level, i.e. have your project use some number of modules which can be split into subdirs without problems.
If it's all logically only one thing (as linking it all into just one module implies), then why not put it into just one directory - maybe using some prefix to the filenames to distinguish separate entities (e.g. lowlevel ll_* highlevel hl_*). drivers/net has 145 .c files, I doubt you'll have more than that ;)
I made kbuild handle this case (in the way above) for XFS, but in a way it's against the normal way how the source is organized in the kernel tree, and I don't see a good reason to change that. Dirs are used as higher level containers, like "fs" all file system-specific things and then fs/{ext2,nfs,...} with one file system per dir.
--Kai
Quoted 2 lines · [email protected] said:
Basically, use only one
Makefileand
blah-objs := blah_init.oblahstuff/blah1.oblahstuff/blah2.o...
Er, don't the dependencies get screwed then, because it fails to create .blahstuff/blah1.o.flags, etc.?
--
dwmw2
Quoted 5 lines · David Woodhouse
Quoted 2 lines
Basically, use only one
Makefileand
blah-objs := blah_init.oblahstuff/blah1.oblahstuff/blah2.o...Er, don't the dependencies get screwed then, because it fails to create .blahstuff/blah1.o.flags, etc.?
No, just try it ;) (That's what I meant saying that I made it work...)
--Kai