Summary:ASTERISK-02610: [patch] Makefile tweak to point to kernel build in /lib/modules/VERSION/build
Reporter:djflux (djflux)Labels:
Date Opened:2004-10-14 16:21:01Date Closed:2004-11-17 22:42:35.000-0600
Versions:Frequency of
Environment:Attachments:( 0) asterisk-20041014-zaptel-Makefile.patch
( 1) asterisk-20041014-zaptel-Makefile.patch.txt
Description:I believe that in all 2.6 kernels the kernel build environment is installed at /lib/modules/VERSION/build.  If this is the case, then the check in the zaptel Makefile for /usr/src/linux-2.6 should be changed.

Attached is a patch that changes the check and the make for the linux26 portion of the Makefile.  This change also allows one to specify a kernel from which to build the zaptel modules against without having to change a symlink by specifying a make command as such:

make KVER=2.6.5


Comments:By: Brian West (bkw918) 2004-10-14 18:13:06

Please attach diffs in the future with .txt so we can view them online.


By: Brian West (bkw918) 2004-10-14 18:14:56

HOLD up what distro is this for?  Sounds debian to me.

By: Brian West (bkw918) 2004-10-14 18:18:35

Can you double check this.

in /lib/modules/linux-2.6.8-gentoo-r6 I have:

build -> /usr/src/linux-2.6.8-gentoo-r6

then in /usr/src I have

linux -> /usr/src/linux-2.6.8-gentoo-r6
linux-2.6 -> linux

So I suspect yours is too a symlink can you check that please.

By: pfn (pfn) 2004-10-14 18:20:56

[pfnguyen@sip pfnguyen]$ ls /lib/modules/2.6.8-1.521/build/
arch     fs       ipc     Makefile        net       sound
crypto   include  kernel  mm              scripts   usr
drivers  init     lib     Module.symvers  security

This is what shows up in FC2

EDIT:  They are not symlinks (neither build nor anything underneath).

edited on: 10-14-04 18:22

By: djflux (djflux) 2004-10-15 09:39:58

My apologies about the patch.  I'll add them as text next time.

I don't have a symlink in /usr/src called linux-2.6.  I do have have /lib/modules/KERNEL_VERSION/build.  This directory exists on Fedora Core 2 with no symlinks as pfn stated.  

I also saw this thread that made me believe that the build environment is in the /lib/modules directory:


Maybe it's just a Red Hat thing, but if it isn't I believe the patch to be appropriate.

By: Brian West (bkw918) 2004-10-15 11:13:01

Well on gentoo its a symlink to /usr/src/linux


By: purplehat (purplehat) 2004-10-17 21:37:54

make -C /lib/modules/${KVER}/build is indeed the correct way to build modules under 2.6. If Gentoo links this to /usr/src/linux then that is a bug in that distro, because this directory is supposed to be a suitable build environment for installed kernel version ${KVER} and not a link to whatever kernel source is currently installed at /usr/src/linux.

I made a patch similar this to the Makefile for zaptel in the FC1/FC2 rpms I released, so having this patch will make it easier to build zaptel packages.

By: Kevin P. Fleming (kpfleming) 2004-10-18 10:14:57

purplehat's comments are correct; according to the kernel docs, and the kernel mailing list, the correct way to build external modules against a 2.6 kernel is by using the /lib/modules/VERSION/build symlink to find the sources that were used to build that specific kernel.

Distros are _supposed_ to provide the kernel sources in a pre-configured, ready-to-use form that matches the provided kernel binary, and there's no reason for it to be located at /usr/src/linux. In fact, expecting it to be at /usr/src/linux means you can't build the modules against different kernel versions (or configurations), because each build will try to use the same source directory.

By: Brian West (bkw918) 2004-10-18 10:31:58

Thats what symlinks exist for ... Thats what I see in gentoo and many others it will still have the build in /lib/modules/VERSION/build which is a link to /usr/src/linux or the like which is a link to the current installed kernel src.  SO I guess this patch is fine.


By: Mark Spencer (markster) 2004-11-01 15:49:05.000-0600

I'll only merge this if it looks in /usr/src/linux-2.6 first, then looks in the build directory (no need to senselessly break backwards compatibility)

By: petersv (petersv) 2004-11-02 00:32:38.000-0600

Under 2.6 you are supposed to use the kernel build environment from /lib/modules/.... The headers from /usr/src/... should not be used. Those will be broken if another kernel has been compiled (or even configured) there. That is why the copy of the correct build environment in /lib/modules was added.

By: Mark Spencer (markster) 2004-11-16 18:17:11.000-0600

This fucntionality is already in CVS head.