Building Only a Portion of the Kernel
For example, to build the files in the drivers/usb/serial
directory, enter:
$ make drivers/usb/serial
Using this syntax, however, will not build the final module images in that directory.
To do that, you can use the M= argument:
$ make M=drivers/usb/serial
which will build all the needed files in that directory and link the final module
images.
When you build a single directory in one of the ways shown, the final kernel
image is not relinked together. Therefore, any changes that were made to the
subdirectories will not affect the final kernel image, which is probably not what
you desire. Execute a final:
$ make
to have the build system check all changed object files and do the final kernel
image link properly.
To build only a specific file in the kernel tree, just pass it as the argument to make.
For example, if you wish to build only the drivers/usb/serial/visor.ko kernel
module, enter:
$ make drivers/usb/serial/visor.ko
The build system will build all needed files for the visor.ko kernel module, and do
the final link to create the module.
Source in One Place, Output in Another
Sometimes it is easier to have the source code for the kernel tree in a read-only
location (such as on a CD-ROM, or in a source code control system), and place
the output of the kernel build elsewhere, so that you do not disturb the original
source tree. The kernel build system handles this easily, by requiring only the
single argument O= to tell it where to place the output of the build. For example, if
the kernel source is located on a CD-ROM mounted on /mnt/cdrom/ and you wish
to place the built files in your local directory, enter:
$ cd /mnt/cdrom/linux-2.6.17.11
$ make O=~/linux/linux-2.6.17.11
All of the build files will be created in the ~/linux/linux-2.6.17.11/ directory.
Please note that this O= option should also be passed to the configuration options of the
build so that the configuration is correctly placed in the output directory and not
in the directory containing the source code.
The kernel build system allows you to
specify a different architecture from the current system with the ARCH= argument.
The build system also allows you to specify the specific compiler that you wish to
use for the build by using the CC= argument or a cross-compile toolchain with the
CROSS_COMPILE argument.
For example, to get the default kernel configuration of the x86_64 architecture,
you would enter:
$ make ARCH=x86_64 defconfig
To build the whole kernel with an ARM toolchain located in /usr/local/bin/, you
would enter:
$ make ARCH=arm CROSS_COMPILE=/usr/local/bin/arm-linux-
It is useful even for a non-cross-compiled kernel to change what the build system
uses for the compiler. Examples of this are using the distcc or ccache programs,
both of which help greatly reduce the time it takes to build a kernel. To use the
ccache program as part of the build system, enter:
$ make CC="ccache gcc"
To use both distcc and ccache together, enter:
$ make CC="ccache distcc"
===
installkernel
===
If you have built any modules and want to use use this method to install a kernel,
first enter:
# make modules_install
After the modules have been successfully installed, the main kernel image must be
installed:
# make install
This will kick off the following process:
1. The kernel build systemwill verify that the kernel has been successfully built
properly.
2. The build systemwill install the static kernel portion into the /boot directory
and name this executable file based on the kernel version of the built kernel.
3. Any needed initial ramdisk images will be automatically created, using the
modules that have just been installed during the modules_install phase.
4. The bootloader programwill be properly notified that a new kernel is
present, and it will be added to the appropriate menu so the user can select it
the next time the machine is booted.
5. After this is finished, the kernel is successfully installed, and you can safely
reboot and try out your new kernel image. Note that this installation does not
overwrite any older kernel images, so if there is a problem with your new
kernel image, the old kernel can be selected at boot time.
-----
Installing by Hand
# make modules_install
The static kernel image must be copied into the /boot directory. For an i386-based
kernel, do the following:
# make kernelversion
2.6.17.11
Note that the kernel version will probably be different for your kernel. Use this
value in place of the text KERNEL_VERSION in the following steps:
# cp arch/i386/boot/bzImage /boot/bzImage-KERNEL_VERSION
# cp System.map /boot/System.map-KERNEL_VERSION
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.