• Sam Ravnborg's avatar
    kbuild: Separate output directory · 5a808876
    Sam Ravnborg authored
    Separate output directory support enables the following (at least):
    o Building several configurations from the same SRC base, and in parrallel
    o Building from a RO media
    o More efficient build if files are retreived via NFS (files stored locally)
    
    Usage is simple:
    cd /path/to/kernel/src
    mkdir ~/build/kernel
    make O=~/build/kernel [Make options]
    Please note: The O= syntax must be used for ALL invocations of make.
    
    As an alternative you may set KBUILD_OUTPUT to the directory where
    to put the output files.
    
    The patch works for me, and I have tried with various configurations,
    including allnoconfig and defconfig.
    
    How it works:
    If the O= option is used, or KBUILD_OUTPUT is set then a second invocation
    of make happens in the output directory.
    The second invocation of make uses VPATH to tell make where to locate
    the files. Furthermore include options for gcc is modifyied to point
    both in the directory where the kernel src is located, and in the
    directory where the output files are located. The latter is used for
    generated .h files.
    
    When building the kernel the asm symlink is created. To support this
    a new 'include2' directory is created. Within include2/ asm is a symlink to
    the asm-$(ARCH) directory in the kernel src.
    Also when building the kernel the asm-offset.h file is created, and
    located in the include/asm-$(ARCH) directory, but included via
    <asm/asm-offset.h>.
    Therefore within include/ another asm symlink is created pointing to
    the asm-$(ARCH) directory located in the output directory.
    
    In Makefile.build the output directory is created if not already present.
    This was needed to support xfs, and oprofile.
    
    The patch is loosly based on ideas from Kai G. Roman Zippel
    introduced support for this in kconfig long time ago
    5a808876
README 14.4 KB