2002-07-20 00:22:27

by John Levon

[permalink] [raw]
Subject: 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

--
"Of all manifestations of power, restraint impresses the most."
- Thucydides


2002-07-20 00:44:11

by Thunder from the hill

[permalink] [raw]
Subject: Re: kbuild - building a module/target from multiple directories

Hi,

On Sat, 20 Jul 2002, John Levon wrote:
> 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
--
(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------

2002-07-20 01:20:42

by Kai Germaschewski

[permalink] [raw]
Subject: Re: kbuild - building a module/target from multiple directories

On Sat, 20 Jul 2002, John Levon wrote:

> 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.

> 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


2002-07-20 01:19:58

by John Levon

[permalink] [raw]
Subject: Re: kbuild - building a module/target from multiple directories

On Fri, Jul 19, 2002 at 06:46:57PM -0600, Thunder from the hill wrote:

> 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

--
"Of all manifestations of power, restraint impresses the most."
- Thucydides

2002-07-20 01:49:25

by John Levon

[permalink] [raw]
Subject: Re: kbuild - building a module/target from multiple directories

On Fri, Jul 19, 2002 at 08:23:36PM -0500, Kai Germaschewski wrote:

> > 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 ?

> blah-objs := blah_init.o blahstuff/blah1.o blahstuff/blah2.o ...

Hmmm, that "works" I suppose

thanks
john

--
"Of all manifestations of power, restraint impresses the most."
- Thucydides

2002-07-20 01:45:41

by Thunder from the hill

[permalink] [raw]
Subject: Re: kbuild - building a module/target from multiple directories

Hi,

On Sat, 20 Jul 2002, John Levon wrote:
> 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
--
(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------

2002-07-20 02:06:42

by Kai Germaschewski

[permalink] [raw]
Subject: Re: kbuild - building a module/target from multiple directories

On Sat, 20 Jul 2002, John Levon wrote:

> On Fri, Jul 19, 2002 at 08:23:36PM -0500, Kai Germaschewski wrote:
>
> > > 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


2002-07-24 13:19:21

by David Woodhouse

[permalink] [raw]
Subject: Re: kbuild - building a module/target from multiple directories


[email protected] said:
> Basically, use only one Makefile and
> blah-objs := blah_init.o blahstuff/blah1.o blahstuff/blah2.o ...

Er, don't the dependencies get screwed then, because it fails to create
.blahstuff/blah1.o.flags, etc.?


--
dwmw2


2002-07-24 14:21:09

by Kai Germaschewski

[permalink] [raw]
Subject: Re: kbuild - building a module/target from multiple directories

On Wed, 24 Jul 2002, David Woodhouse wrote:

> > Basically, use only one Makefile and
> > blah-objs := blah_init.o blahstuff/blah1.o blahstuff/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