[XPERIA X8 General] sgt. meow:
Second thread in a week. Read on, young dev, for you are about to enter a world of Android goodness soon.

WHAT IS A KERNEL?

A kernel, as explained by viper001 in his thread, is the software layer between the ROM and the hardware. It contains the crucial init process of the boot sequence. So an Android phone with a faulty kernel may mean a very expensive paperweight. But fear not I have compiled several kernels for my phone (released a few of them too) and I have never ever bricked my phone (not even a bootloop, strange right?).

WHY THE NEW THREAD AND WHY YOU SHOULD COMPILE A KERNEL?

viper001's thread is pretty outdated (it was published in 2010, it's nearly 2013 now) and uses the FXP source (which is also pretty old). Therefore if you compile a kernel following that guide, you'll only be able to use it with FXP ROM (which is almost ancient by now). That is why I decided, after considering Rohin's suggestion, to write a new kernel building guide, for members who wish to step into the dev world by compiling a kernel. Keep in mind, neither the XDA-ians nor I am to be held responsible if you do brick your phone (even if you pee on it due to sheer excitement, though I am pretty sure you'll handle it....LIKE A BOSS).

THE ACTUAL GUIDE

Okay so you want to compile your kernel, huh? Well, you're gonna need some packages and toolchains and sources and blah blah. In short these are the requirements:

1. An Ubuntu build (Linux Mint will do too but I haven't tried using it) on a fast computer (preferably a quad core but a dual core 2.4GHz will do too, 2GB of RAM) or a virtual installation (Google installing ubuntu on vbox).

2. Some packages that you can get by typing this in the Terminal:

sudo apt-get install git unrar libncurses5-dev qt3-dev-tools

3. A kernel source

4. A toolchain

5. Flashtool in your Windows installation (you must have one)

KERNEL SOURCES AND TOOLCHAINS

nAa GB (L)

nAa ICS (L)

nAa JB (L)

Alfs GB (use master branch; test has problems) (L)

LINARO (L sources only)

LINUX GNU Compiler for ARM

INSTRUCTIONS

Make a folder where you'll be working for the time being. Name it conveniently. Unpack a source there and a toolchain (use the Linaro one, it makes the kernel slightly faster and each of the sources I mentioned is compatible with it). Rename the toolchain folder, and the source folder too, to something simpler. It's better if all this is done without root, because that may screw your Ubuntu installation beyond recovery. Even so I did it in root. You, however, should do it in any place other than root, and make sure you can easily navigate to the place through Terminal.

Now for the tough Terminal bit. Navigate to the source folder and type in this:

export ARCH=arm

export CROSS_COMPILE=/path/to/toolchain/folder/bin/arm-linux-gnueabihf-

This will tell Terminal to build the kernel for the ARM platform using the Linaro toolchain.

Then type in:

make xxxx_shakira_defconfig

Where xxxx is the part of the name before _shakira. Check the /arch/arm/configs directory for either semc_ (for Alfs kernels) or nAa_ (for nAa kernels). Or you can make your own defconfig if you're up to the challenge.

Then type in:

make menuconfig

This will display a GUI version of your defconfig. Edit anything you want to there or directly in the defconfig.

Then type in:

make -j#

Where # is the number of cores your CPU has + 1.

If all goes well, you should have your kernel image. Grab the Image file form /arch/arm/boot.

You do have Windows installed, right? Good, because you're gonna need it now. Download the bootloader unlocking tool (not Flashtool, the one posted by the_laser).

You have to copy your Image file and a ramdisk, check my other guide, to the sinTools folder of the bootloader unlock tool. A suitable ramdisk, not a GB one for an ICS kernel and vice versa. Then rename the Image file to image and double-click on example_build.cmd. You should get a result.zip. Exatract it and rename result.sin to kernel.sin. Copy it over to a folder and place a loader.sin from a working kernel there too. Open up Flashtool. Go to Advanced > Bundle creation. Navigate to the folder and select both files and move them over to the right-side (by clicking the > button). Give it a proper name and branding and click OK. FLASH! FLASH! You are done with your kernel. First ever, huh? Wish to know more.

If your build failed, type in

make mrproper

or

make clean

Coming soon, TIPS AND TRICKS and more.

P.S.

It is pretty obvious that I'm not a RD, or any D for that matter, this guide may have petty mistakes. Therefore I request any member to let me know if there are any mistakes should he/she find any.

Stay safe and pray that your PC doesn't explode while you're doing this.

If any of the Forum Mods are reading this, you may wonder why I posted this when there already was a guide. viper001's thread is a bit outdated although some users have compiled kernels following it. Therefore to help users who are quite new to this, I wrote this. I sincerely hope I do not get warned for posting a guide twice, just to help people compile newer kernels.

NEITHER THE XDA-IANS NOR I AM TO BE HELD RESPONSIBLE FOR ANY DAMAGE THAT THIS MAY CAUSE TO YOUR PHONE. YOU ARE SOLELY RESPONSIBLE FOR WHATEVER YOU DO TO YOUR PHONE.

But do ask for help if you need it.

EDIT: You can also use the zImage file (you have to rename it to image) as pilu1978 said in his post (check second page and thank him). If you use this, you can attach a larger ramdisk.