커널 컴파일 하기 - 1: 사전작업
http://fedora.redhat.com/docs/release-notes/fc4/errata/#sn-kernel
페도라에서 커널을 컴파일 하기 위해서는 먼저 사전작업을 조금 해야 한다.
자세한 사항은 위의 링크에서 보기 바란다.
아래는 그것읠 갈무리다.
The Fedora Core is based on a 2.6.11 kernel. Fedora Core may include additional patches for improvements, bug fixes, or additional features. For this reason, the Fedora Core kernel may not be line-for-line equivalent to the so-called vanilla kernel from thekernel.orgweb site.
You may obtain a list of any such patches by using the command on the Fedora Core package:
rpm-qplkernel-<version>.src.rpmFedora Core includes the following kernel builds:
Native kernel, in both uniprocessor andSMPvarieties.
Configured sources are available in thekernel-devel-<version>.<arch>.rpmpackage.
Virtual kernel for use with theXenemulator package.
Configured sources are available in thekernel-xen0-devel-<version>.<arch>.rpmpackage.
Sources for both kernel flavors may be installed at the same time. The files will be installed into the/usr/src/kernels/<version>[-xen0]-<arch>/tree. Use the command:
rpm-Uvhkernel-devel[-xen0]-<version>.<arch>.rpmas appropriate.
![]() | Following Generic Textbooks |
---|---|
Many of the tutorials, examples, and textbooks about Linux kernel development assume the kernel sources are installed under the/usr/src/linuxdirectory. If you make a symbolic link, as shown below, you should be able to use those learning materials with the Fedora Core packages. Install the appropriate kernel sources, as shown earlier, and then: ln-s/usr/src/kernels/kernel-<all-the-rest>/usr/src/linux |
Fedora Core 4 does not include thekernel-sourcepackage provided by older versions. Instead, configured sources are available as described inSection 7.2.2.2, “Kernel Flavors”. Users that require access to Fedora Core original kernel sources can find them in thekernel.src.rpmpackage. To create an exploded source tree from this file, perform the following steps:
![]() | These Instructions Refer to the Currently-running Kernel! |
---|---|
To simplify the following directions, we have assumed that you want to configure the kernel sources to match your currently-running kernel. In the steps below, you must understand that the phrase<version>refers to the kernel version shown by this command: uname-r |
Obtain thekernel-<version>.src.rpmfile from one of the following sources:
TheSRPMSdirectory on the appropriateSRPMSCDisoimage.
The FTP site where you got the kernel package.
By running the following command:
up2date--get-sourcekernel
Installkernel-<version>.src.rpmusing the command:
rpm-Uvhkernel-<version>.src.rpmThis writes theRPMcontents into/usr/src/redhat/SOURCESand/usr/src/redhat/SPECS.
Prepare the kernel sources using the commands:
cd/usr/src/redhat/SPECSrpmbuild-bp --target $(arch)kernel-2.6.specThe kernel source tree will be located in the/usr/src/redhat/BUILD/kernel-<version>directory. It is common practice to move the resultinglinux-<version>directory to the/usr/srctree; while not strictly necessary, we suggest that you do this to match the generally-available documentation.
cd/usr/src/redhat/BUILD/kernel-<version>/usr/src/mvlinux-<version>/usr/src/cd/usr/srcln-s./linux-<version>linuxcd/usr/src/linuxThe configurations for the specific kernels shipped in Fedora Core 4 are in theconfigs/directory. For example, the i686 SMP configuration file is namedconfigs/kernel-<version>-i686-smp.config. Issue the following command to place the desired configuration file in the proper place for building:
cpconfigs/<desired-config-file>.configYou can also find the.configfile that matches your current kernel configuration in the/lib/modules/<version>/build/.configfile.
Every kernel gets a name based on its version number. This is the value theuname -rcommand displays. The kernel name is defined by the first four lines of the kernelMakefile. To protect the innocent, theMakefilehas been changed to generate a kernel with a different name from that of the running kernel. Before a module can be accepted by the running kernel, that module must have been compiled for a kernel with the correct name. To do this, you must edit the kernelMakefile
For example, if theuname -rreturns the string2.6.11-1.234_FC4, change theEXTRAVERSIONdefinition from this:
EXTRAVERSION = -prepto this:
EXTRAVERSION = -1.234_FC4that is, substitute everything from the final dash onward.
Issue the following command:
make oldconfig
You can then proceed as usual.
An exploded source tree isnotrequired to build a kernel module, such as your own device driver, against the currently in-use kernel.
For example, to build thefoo.komodule, create the followingMakefilein the directory containing thefoo.cfile:
obj-m := foo.oKDIR := /lib/modules/$(shell uname -r)/buildPWD := $(shell pwd)default: $(MAKE) -C $(KDIR) M=$(PWD) modulesIssue themakecommand to build thefoo.komodule.
Fedora Core adds support for clustered systems. This requires a special kernel that works in conjunction with some user-space utilities, such as management daemons. Consequently, to remove such a kernel, perhaps after an update, youcannotsimply use therpm -e kernel-<version>command as in earlier distributions because these user space packages depend on the kernel package. You may either list both the kernel package and its user space dependent packages on therpm -ecommand, or you may wish to use theyum remove kernel-<version>command instead sinceyumautomatically removes dependent packages if necessary.