• Sam Ravnborg's avatar
    kbuild: Introduce source symlink in /lib/modules/.../ · e09e5886
    Sam Ravnborg authored
                                                                                                         
    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>
    e09e5886
Makefile 37.3 KB