[General Topics] #buzz:
This is a general open source linux development thread!

Android's kernel is a derivative of linux's kernel. Its good to know how to build both of these kernels. You might be already familiar with building kernels for various devices from sources. So I have made a new thread for guiding people on how to compile linux kernel from source (example taken as ubuntu kernel).

Requirements:

Any linux os x64 bit(example here: ubuntu 14.04)

Git (sudo apt-get install git)

Minimum of 4GB RAM and some reasonable linux-swap

To get the currently running kernel image, type the following:

apt-get source linux-image-$(uname -r)

Now we need to obtain Ubuntu Kernel Sources from its repositories. Make a new directory and inside it, initialise the git and clone the repository.

git clone git://kernel.ubuntu.com/ubuntu/ubuntu-<release>.git

<release> : Type in the required source. It can be lucid, precise, trusty, utopic etc.

Setting up the build environment. There are lots of tools and packages that are very much essential for building a kernel. These tools can be downloaded as a whole bundle and can be installed easily. Here's the code to set it up:

sudo apt-get build-dep linux-image-$(uname -r)

NOTE: The above comand can be executed only after you obtain the currently running kernel image. I have already given the code to obtain it above.

Now, change directory to the root of the kernel and type the following:

chmod -R a+x *

The above code will set the required permissions for building and executing the kernel.

Now, run these two commands:

fakeroot debian/rules clean
fakeroot debian/rules editconfigs

The first command cleans up the code automatically.

The slightly tricky part is with the second line of the code. When you execute it, you will have to edit a series of menuconfigs. To make changes to the configuration file we need to edit the configuration file. The kernel developers have created a script to edit kernel configurations which has to be called through the debian/rules makefile, unfortunately you will have to go through all the flavors for this script to work properly. The script will ask you if you want to edit the particular configuration. You should not make changes to any of the configurations until you see your wanted flavour configuration

We have now covered about 70% of progress. The rest is building the kernel and testing it.

Building the kernel is quite easy. Change your working directory to the root of the kernel source tree and then type the following commands:

fakeroot debian/rules clean
fakeroot debian/rules binary-headers binary-generic

If the build is successful, a set of three .deb binary package files will be produced in the directory above the build root directory. For example after building a kernel with version "3.13.-0.35" on an amd64 system, these three .deb packages would be produced:

cd ..
ls *.deb
linux-headers-3.13.0-35_3.13.0-35.37_all.deb
linux-headers-3.13.0-35-generic_3.13.0-35.37_amd64.deb
linux-image-3.13.0-35-generic_3.13.0-35.37_amd64.deb

Testing the new kernel

Install the three-package set (on your build system, or on a different target system) with dpkg -i and then reboot:

sudo dpkg -i linux*3.13.0-35.37*.deb
sudo reboot

Guys, I hope I have made an easy tutorial. You are always welcome to ask doubts (even on PM). Thank You.