2004-06-15 19:20:26

by Jari Ruusu

[permalink] [raw]
Subject: Re: [PATCH 5/5] kbuild: external module build doc

Sam Ravnborg wrote:
> --- /dev/null Wed Dec 31 16:00:00 196900
> +++ b/Documentation/kbuild/extmodules.txt 2004-06-14 22:25:21 +02:00
[snip]
> +A more advanced example
> +- - - - - - - - - - - -
> +This example shows a setup where a distribution has wisely decided
> +to separate kernel source and output files:
> +
> +Kernel src:
> +/usr/src/linux-<kernel-version>/
> +
> +Output from a kernel compile, including .config:
> +/lib/modules/linux-<kernel-version>/build/
^^^^^
Wrong! The 'build' symlink has always pointed to kernel source dir in
separate source and object directory case. Maybe you meant:

Output from a kernel compile, including .config:
/lib/modules/linux-<kernel-version>/object/
^^^^^^
> +External module to be compiled:
> +/home/user/module/src/
> +
> +To compile the module located in the directory above use the
> +following command:
> +
> + cd /home/user/module/src
> + make -C /usr/src/linux-<kernel-version> \
> + O=/lib/modules/linux-<kernel-version>/build \
^^^^^
O=/lib/modules/linux-<kernel-version>/object
^^^^^^
> + M=`pwd`
> +
> +Then to install the module use the following command:
> +
> + make -C /usr/src/linux-<kernel-version> \
> + O=/lib/modules/linux-<kernel-version>/build \
^^^^^
O=/lib/modules/linux-<kernel-version>/object
^^^^^^
> + M='pwd` modules_install
[snip]
> +Prepare the kernel for building external modules
> +------------------------------------------------
> +When building external modules the kernel is expected to be prepared.
> +This includes the precense of certain binaries, the kernel configuration
> +and the symlink to include/asm.
> +To do this a convinient target is made:
> +
> + make modules_prepare
> +
> +For a typical distribution this would look like the follwoing:
> +
> + make modules_prepare O=/lib/modules/linux-<kernel version>/build
^^^^^
make modules_prepare O=/lib/modules/linux-<kernel version>/object
^^^^^^
Sam, You don't seem to have any idea how much breakage you introduce if you
insist on redirecting the 'build' symlink from source tree to object tree.

--
Jari Ruusu 1024R/3A220F51 5B 4B F9 BB D3 3F 52 E9 DB 1D EB E3 24 0E A9 DD


2004-06-15 19:47:09

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH 5/5] kbuild: external module build doc

On Tue, Jun 15, 2004 at 10:21:44PM +0300, Jari Ruusu wrote:
> Sam Ravnborg wrote:
> > --- /dev/null Wed Dec 31 16:00:00 196900
> > +++ b/Documentation/kbuild/extmodules.txt 2004-06-14 22:25:21 +02:00
> [snip]
> > +A more advanced example
> > +- - - - - - - - - - - -
> > +This example shows a setup where a distribution has wisely decided
> > +to separate kernel source and output files:
> > +
> > +Kernel src:
> > +/usr/src/linux-<kernel-version>/
> > +
> > +Output from a kernel compile, including .config:
> > +/lib/modules/linux-<kernel-version>/build/
> ^^^^^
> Wrong! The 'build' symlink has always pointed to kernel source dir in
> separate source and object directory case.

This document was written before Andreas posted his patch - I just never
came around updating it.
^^^^^^
> Sam, You don't seem to have any idea how much breakage you introduce if you
> insist on redirecting the 'build' symlink from source tree to object tree.

No - and I still do not see it. Please explain how we can be backward
compatible when vendors start utilising separate directories for src and output.

Anyway, after I gave it some extra thoughs I concluded that
/lib/modules/kernel-<version>/ was the wrong place to keep
info about where to src for a given build is located.
This information has to stay in the output directory.

So what I will implement is that during the kernel build process
(not the install part) a symlink named 'source' is placed
in the root of the output directory - and links to the root of
the kernel src used for building the kernel.

Then /lib/modules/kernel-<version>/build/source will be where
the source is located.
And /lib/modules/kernel-<version>/build will point to the output files.

If the vendor does not utilise separate src and output directories
they will point to the same directory.
If the vendor utilises separate output and source directories
then thay will point in two different places.

Comments?

Sam

2004-06-15 23:01:09

by Martin Schlemmer

[permalink] [raw]
Subject: Re: [PATCH 5/5] kbuild: external module build doc

On Tue, 2004-06-15 at 21:55, Sam Ravnborg wrote:

> > Sam, You don't seem to have any idea how much breakage you introduce if you
> > insist on redirecting the 'build' symlink from source tree to object tree.
>
> No - and I still do not see it. Please explain how we can be backward
> compatible when vendors start utilising separate directories for src and output.
>
> Anyway, after I gave it some extra thoughs I concluded that
> /lib/modules/kernel-<version>/ was the wrong place to keep
> info about where to src for a given build is located.
> This information has to stay in the output directory.
>
> So what I will implement is that during the kernel build process
> (not the install part) a symlink named 'source' is placed
> in the root of the output directory - and links to the root of
> the kernel src used for building the kernel.
>
> Then /lib/modules/kernel-<version>/build/source will be where
> the source is located.
> And /lib/modules/kernel-<version>/build will point to the output files.
>
> If the vendor does not utilise separate src and output directories
> they will point to the same directory.
> If the vendor utilises separate output and source directories
> then thay will point in two different places.
>

Please have a look at any package out there (or 99% of them) that need
to figure out where the kernel _source_ is ... they all use something
like:

KERNEL_SRC="/lib/modules/`uname -r`/build"

or

KERNEL_SRC="$(readlink /lib/modules/`uname -r`/build)"

If you now change it to /lib/modules/`uname -r`/build/source, many will
break (depending if they might try things like looking if /usr/src/linux
is around), and all will have to add _another_ kludge to figure things
out.

Its a bad idea IMHO.


Cheers,

--
Martin Schlemmer


Attachments:
signature.asc (189.00 B)
This is a digitally signed message part