Commit e09e5886 authored by Sam Ravnborg's avatar Sam Ravnborg

kbuild: Introduce source symlink in /lib/modules/.../

                                                                                                     
Traditionally when building a kernel the source and the
output files are mixed.
                                                                                                     
When building a kernel using the O= syntax to save output
files in a separate directory a way is needed to locate
the kernel source.
The implemented solution is a new symlink 'source' being
added to /lib/modules/.../
used to locate source for an installed kernel.
The original symlink build points to the directory
containing the output files.
                                                                                                     
Please note that when the kernel is build with source and
output files mixed the two symlinks 'build' and 'source'
will point to the same directory, thus no changes
compared to before.
                                                                                                     
Two options was considered:
                                                                                                      a) Adding a new symlink pointing to the output files "object"
        => All external modules have to specify O= to build
        => External modules grepping in .config or .h files
           in include/asm needs to be updated
        => External modules that do grep in source code and
           ordinary header files just works
                                                                                                     
b) Let the build symlink point to the output files and introduce a new
   symlink "source" pointing to the kernel source
        => External module can be build without specifying O=
        => External modules grepping in .config or .h files
           in include/asm just works
        => External modules that do grep in source code and
           ordinary header files needs to be updated
                                                                                                     
Based on the above option b) is considered the least painfull alternative.
                                                                                                     
So to sum up:
- If a distro does not use separate output dir => no change
- If a distro uses separate output dir =>
        - Trivial external module just builds
        - Non-trivial (build-wise) external modules are probarly broken
                                                                                                     
Without this patch
- If a distro does not use separate output dir => no change
- If a distro uses separate output dir =>
        - Trivial external modules had to specify O= to build,
          and the directory being pointed at was not obvious
        - grep in .config or include files in asm/ required
          knowledge where to locate output files
                                                                                                     
Preferred syntax for building external modules are the following:

       make -C /lib/modules/`uname -r`/build M=`pwd`

[Substituting 'M=...' with 'SUBDIRS=... modules' give same effect].
                                                                                                     
When the kernel is built using separate output directory the above
invocation of make will invoke the generated Makefile located in the output
directory - that again will invoke the Makefile located in the kernel
source tree root.
                                                                                                     
Patch includes contributions from:
        Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent e321b2ec
...@@ -769,9 +769,13 @@ _modinst_: ...@@ -769,9 +769,13 @@ _modinst_:
sleep 1; \ sleep 1; \
fi fi
@rm -rf $(MODLIB)/kernel @rm -rf $(MODLIB)/kernel
@rm -f $(MODLIB)/build @rm -f $(MODLIB)/source
@mkdir -p $(MODLIB)/kernel @mkdir -p $(MODLIB)/kernel
@ln -s $(TOPDIR) $(MODLIB)/build @ln -s $(srctree) $(MODLIB)/source
@if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
rm -f $(MODLIB)/build ; \
ln -s $(objtree) $(MODLIB)/build ; \
fi
$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
# If System.map exists, run depmod. This deliberately does not have a # If System.map exists, run depmod. This deliberately does not have a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment