Kernel compilation

Go to the /usr/src directory
Unpack the source code with tar -xvzf linux-2.x.x.tag.gz.
Move to the /usr/src/linux sub-directory.

make mrproper
make menuconfig
make all     — make vmlinux
— make modules
— make bzimage
make modules_install
make install
cp /usr/src/linux/arch/i386/boot/zImage /zImage

——————————————————————
Making an initrd Image

An initrd image is needed for loading your SCSI module at boot time or if you are compiling the kernel with ext3 support as a module. If you do not need an initrd image, do not make one and do not edit lilo.conf or grub.conf to include this image.

Use the /sbin/mkinitrd shell script to build an initrd image for your machine. To use this command, the loopback block device must be available.

To build the new initrd image, run /sbin/mkinitrd with parameters such as this:

/sbin/mkinitrd /boot/initrd-2.4.18-0.12-jul2001.img 2.4.18-0.12-jul2001

In the above example, /boot/initrd-2.4.18-0.12-jul2001.img is the file name of the new initrd image. 2.4.18-0.12-jul2001 is the kernel whose modules (from /lib/modules) should be used in the initrd image. This is not necessarily the same as the version number of the currently running kernel.

——————————————————————

Cleaning targets:

clean           – Remove most generated files but keep the config and
enough build support to build external modules
mrproper        – Remove all generated files + config + various backup files
distclean       – mrproper + remove editor backup and patch files

Configuration targets:
config          – Update current config utilising a line-oriented program
menuconfig      – Update current config utilising a menu based program
xconfig         – Update current config utilising a QT based front-end
gconfig         – Update current config utilising a GTK based front-end
oldconfig       – Update current config utilising a provided .config as base
silentoldconfig – Same as oldconfig, but quietly
randconfig      – New config with random answer to all options
defconfig       – New config with default answer to all options
allmodconfig    – New config selecting modules when possible
allyesconfig    – New config where all options are accepted with yes
allnoconfig     – New config where all options are answered with no

Other generic targets:
all             – Build all targets marked with [*]
* vmlinux         – Build the bare kernel
* modules         – Build all modules
modules_install – Install all modules to INSTALL_MOD_PATH (default: /)
dir/            – Build all files in dir and below
dir/file.[ois]  – Build specified target only
dir/file.ko     – Build module including final link
rpm             – Build a kernel as an RPM package
tags/TAGS       – Generate tags file for editors
cscope          – Generate cscope index
kernelrelease   – Output the release version string
kernelversion   – Output the version stored in Makefile
headers_install – Install sanitised kernel headers to INSTALL_HDR_PATH                    (default: /usr/src/linux-2.6.24.3/usr)

Static analysers
checkstack      – Generate a list of stack hogs
namespacecheck  – Name space analysis on compiled kernel
export_report   – List the usages of all exported symbols
headers_check   – Sanity check on exported headers

Kernel packaging:
rpm-pkg         – Build the kernel as an RPM package
binrpm-pkg      – Build an rpm package containing the compiled kernel
and modules
deb-pkg         – Build the kernel as an deb package
tar-pkg         – Build the kernel as an uncompressed tarball
targz-pkg       – Build the kernel as a gzip compressed tarball
tarbz2-pkg      – Build the kernel as a bzip2 compressed tarball

Documentation targets:
Linux kernel internal documentation in different formats:
htmldocs        – HTML
installmandocs  – install man pages generated by mandocs
mandocs         – man pages
pdfdocs         – PDF
psdocs          – Postscript
xmldocs         – XML DocBook

Architecture specific targets (i386):
* bzImage       – Compressed kernel image (arch/x86/boot/bzImage)
install       – Install kernel using
(your) ~/bin/installkernel or
(distribution) /sbin/installkernel or
install to $(INSTALL_PATH) and run lilo
bzdisk       – Create a boot floppy in /dev/fd0
fdimage      – Create a boot floppy image
isoimage     – Create a boot CD-ROM image

make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build
make V=2   [targets] 2 => give reason for rebuild of target
make O=dir [targets] Locate all output files in “dir”, including .config
make C=1   [targets] Check all c source with $CHECK (sparse by default)
make C=2   [targets] Force check of all c source with $CHECK

Execute “make” or “make all” to build all targets marked with [*]
For further info see the ./README file

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s