Ross C Mcilroy | 12 Jan 2005 23:39
Picon
Picon
Favicon

Compile external module with seperate source and object directories


Hi

I am working on porting an external kernel module to the 2.6 kernel.  As such the modules makefile has to be changed to the new format for compiling external modules, however I am having trouble with this. 

The problem is that the project I'm working on has both a user-mode version and a linux module version.  It has a number of common files, which use pre-processor commands to differentiate between the versions.  The object files of these common files are compiled to a different directory from their source, so that both versions can be compiled at once.  For example, if there is lib/packet.c, it will be compiled as userlevel/packet.o by the makefile in the userlevel directory, and linuxkernel/packet.o by the linuxkernel makefile.  No .o files are compiled in the lib directory.

The dependancies between these files and the created object files were handled using the VPATH variable in the previous makefile, however this doesn't seem to work with the 2.6 kernel (I assume because VPATH is already defined in the root kernel makefile).  The linux kernel module make therefore doesn't find the required source files.  Is this possible with the new external module build process?

I would be grateful for any help.

Thanks

Ross

Sam Ravnborg | 13 Jan 2005 20:41
Gravatar

Re: Compile external module with seperate source and object directories

On Wed, Jan 12, 2005 at 10:39:56PM -0000, Ross C Mcilroy wrote:
> 
> The dependancies between these files and the created object files were handled using the
> VPATH variable in the previous makefile, however this doesn't seem to work with the
> 2.6 kernel (I assume because VPATH is already defined in the root kernel makefile).
> The linux kernel module make therefore doesn't find the required source files.
> Is this possible with the new external module build process?

kbuild does not support storing output files in a separate directory for
external modules so the answer is no.

The request has been few - and the solution has not been obvoius. So
there is niether plan to add this to kbuild. But if someone can come
with a nice minimal patch it will be considered.

	Sam

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Michael S. Tsirkin | 16 Jan 2005 16:22
Picon

changing local version requires full rebuild

Hi!
Is it just me, or does changing the local version always require
a full kernel rebuild?

If so, I'd like to fix it, since I like copying
my kernel source with --preserve and changing the
local version, then going back to the old version in case of
a crash.
Its important to change the local version to force 
make install and make modules_install to put things in a separate
directory.

Any ideas on why is that and whether its possible to fix it?

mst
Sam Ravnborg | 16 Jan 2005 17:16
Gravatar

Re: changing local version requires full rebuild

On Sun, Jan 16, 2005 at 05:22:42PM +0200, Michael S. Tsirkin wrote:
> Hi!
> Is it just me, or does changing the local version always require
> a full kernel rebuild?
> 
> If so, I'd like to fix it, since I like copying
> my kernel source with --preserve and changing the
> local version, then going back to the old version in case of
> a crash.
> Its important to change the local version to force 
> make install and make modules_install to put things in a separate
> directory.

Just tried it out here.
After cp -Ra only a limited part of the kernel rebuilds.
o oiu.c in ieee directory - because it dependson the shell script
o A number of drivers that include version.h
	- This should be changed so local version does not affect
	  the reast of version.h.
o Other stuff that is always build if kernel has changed

Do you use "echo -mylocalver > localversion" to change the local version?

	Sam
Michael S. Tsirkin | 16 Jan 2005 17:28
Picon

Re: changing local version requires full rebuild

Hello!
Quoting r. Sam Ravnborg (sam <at> ravnborg.org) "Re: changing local version requires full rebuild":
> On Sun, Jan 16, 2005 at 05:22:42PM +0200, Michael S. Tsirkin wrote:
> > Hi!
> > Is it just me, or does changing the local version always require
> > a full kernel rebuild?
> > 
> > If so, I'd like to fix it, since I like copying
> > my kernel source with --preserve and changing the
> > local version, then going back to the old version in case of
> > a crash.
> > Its important to change the local version to force 
> > make install and make modules_install to put things in a separate
> > directory.
> 
> Just tried it out here.
> After cp -Ra only a limited part of the kernel rebuilds.
> o oiu.c in ieee directory - because it dependson the shell script
> o A number of drivers that include version.h
> 	- This should be changed so local version does not affect
> 	  the reast of version.h.
> o Other stuff that is always build if kernel has changed
> 
> Do you use "echo -mylocalver > localversion" to change the local version?
> 
> 	Sam

No, I do makemenuconfig to edit the version. Is that right?

mst
Michael S. Tsirkin | 16 Jan 2005 18:24
Picon

Re: changing local version requires full rebuild

Hello!
Quoting r. Sam Ravnborg (sam <at> ravnborg.org) "Re: changing local version requires full rebuild":
> On Sun, Jan 16, 2005 at 05:22:42PM +0200, Michael S. Tsirkin wrote:
> > Hi!
> > Is it just me, or does changing the local version always require
> > a full kernel rebuild?
> > 
> > If so, I'd like to fix it, since I like copying
> > my kernel source with --preserve and changing the
> > local version, then going back to the old version in case of
> > a crash.
> > Its important to change the local version to force 
> > make install and make modules_install to put things in a separate
> > directory.
> 
> Just tried it out here.
> After cp -Ra only a limited part of the kernel rebuilds.
> o oiu.c in ieee directory - because it dependson the shell script
> o A number of drivers that include version.h
> 	- This should be changed so local version does not affect
> 	  the reast of version.h.
> o Other stuff that is always build if kernel has changed
> 
> Do you use "echo -mylocalver > localversion" to change the local version?
> 
> 	Sam

Just tried this with the same effect.

Could it be your version was already -mylocalver?

Please note that you have to actually *change* the local
version, otherwise almost nothing is recompiled.
Just a touch does nothing.

Actually, the directory kernel/ is not recompiled (so the subject is a
bit misleading) , but a huge number of files in drivers, filesystems, sound,
lib and net directory - are.

MST
Sam Ravnborg | 16 Jan 2005 18:26
Gravatar

Re: changing local version requires full rebuild

 > 
> > Do you use "echo -mylocalver > localversion" to change the local version?
> > 
> > 	Sam
> 
> No, I do makemenuconfig to edit the version. Is that right?

That is fine too.
When building - do you use separate output dir?

	Sam
Michael S. Tsirkin | 16 Jan 2005 18:55
Picon

Re: changing local version requires full rebuild

Hello!
Quoting r. Sam Ravnborg (sam <at> ravnborg.org) "Re: changing local version requires full rebuild":
>  > 
> > > Do you use "echo -mylocalver > localversion" to change the local version?
> > > 
> > > 	Sam
> > 
> > No, I do makemenuconfig to edit the version. Is that right?
> 
> That is fine too.
> When building - do you use separate output dir?
> 
> 	Sam

nope, just make

Michael S. Tsirkin | 16 Jan 2005 19:11
Picon

Re: changing local version requires full rebuild

Hello!
Quoting r. Sam Ravnborg (sam <at> ravnborg.org) "Re: changing local version requires full rebuild":
> On Sun, Jan 16, 2005 at 05:22:42PM +0200, Michael S. Tsirkin wrote:
> > Hi!
> > Is it just me, or does changing the local version always require
> > a full kernel rebuild?
> > 
> > If so, I'd like to fix it, since I like copying
> > my kernel source with --preserve and changing the
> > local version, then going back to the old version in case of
> > a crash.
> > Its important to change the local version to force 
> > make install and make modules_install to put things in a separate
> > directory.
> 
> Just tried it out here.
> After cp -Ra only a limited part of the kernel rebuilds.
> o oiu.c in ieee directory - because it dependson the shell script
> o A number of drivers that include version.h
> 	- This should be changed so local version does not affect
> 	  the reast of version.h.

We now have:
swlab155:/usr/src/linux-2.6.10-gold # grep version.h -rI . | wc -l
2143
swlab155:/usr/src/linux-2.6.10-gold # grep UTS_RELEASE -rIi .| wc -l
47

So it appears that its much simpler to change all users of
UTS_RELEASE to use some other file, say local_version.h,
and have localversion not affect version.h

Opinions?

mst

Michael S. Tsirkin | 16 Jan 2005 20:42
Picon

Re: changing local version requires full rebuild

Hello!
Quoting r. Sam Ravnborg (sam <at> ravnborg.org) "Re: changing local version requires full rebuild":
>  > 
> > > Do you use "echo -mylocalver > localversion" to change the local version?
> > > 
> > > 	Sam
> > 
> > No, I do makemenuconfig to edit the version. Is that right?
> 
> That is fine too.
> When building - do you use separate output dir?
> 
> 	Sam

First, by design any module includes the full
kernel release name as part of the VERMAGIC_STRING.
So at least one file will have to be rebuilt for each module,
and all modules have to be relinked, if localversion changes.

MST

Gmane