kbuild: Separate output directory
authorSam Ravnborg <sam@mars.ravnborg.org>
Thu, 11 Sep 2003 14:01:32 +0000 (16:01 +0200)
committerSam Ravnborg <sam@mars.ravnborg.org>
Thu, 11 Sep 2003 14:01:32 +0000 (16:01 +0200)
commit5a808876e2f204cefdca16040d1d3662f4a503c3
treed4d6e5b46ffcfec1a33d8ae8dcecaf1518504203
parent7bc26fada41338caf7ff83732e137c0c967e06df
kbuild: Separate output directory

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
Makefile
README
arch/i386/boot/Makefile
scripts/Makefile.build
scripts/Makefile.clean
scripts/Makefile.lib
scripts/Makefile.modpost