[Android Q&A, Help & Troubleshooting] swm5126:
Since I don't know what kind of experience you have exactly (other than using Linux, which is good :)) I'll just go all out. Don't be offended if it seems like I'm being too explicit, I'm just copying and pasting a couple things from guides I used when I was trying to figure this **** out a couple weeks ago. Most of this is assuming you have no build environment set up at all, and should work with any Linux builds of the Debian variant (Ubuntu...and thats all I can think of :p).

Make sure you have the Android SDK tools installed so you have ADB and stuff. If you don't, Google it. The install steps from Google work fine.

Fire up a terminal. Add this first so you don't error out trying to install the jdk.

sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner"

Assuming you're on an x86/32 bit version of linux, run:

sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk pngcrush schedtool

If using x64, run the above command as well as this one:

sudo apt-get install g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline5-dev gcc-4.3-multilib g++-4.3-multilib

NOTE: gcc-4.3-multilib g++-4.3-multilib is no longer available for Ubuntu 11.04 64-bit, but should still build without issue.

Now you'll need to grab the ARM toolchain to be able to cross compile code for ARM devices.

Make a directory in your home folder (I just used android, so ~/android) and go into it on your terminal after all that **** up there is done.

Now do:

git clone git://github.com/CyanogenMod/android_prebuilt.git

or if you have a github account and to avoid a couple prompts:

git clone git@github.com:CyanogenMod/android_prebuilt.git

Assuming you did the first command, it'll ask for your name and email. You can give them, or just hit enter and ignore it. It'll take a while to download the whole package, and then a good amount of time to unpackage and check out the files. In reality, there's more there than you need for compiling a kernel, but as you do more you may find it helpful to already have some of the things in there.

Now you have the toolchain. The next thing to do is to add the ARM toolchain path to your .bashrc file so make can easily call it when you compile the kernel. Back on your terminal:

nano ~/.bashrc

Scroll alll the way down. On the end of the file, add:

export CCOMPILER=~/android/android_ prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-

Where ~/android/ is the name of the folder you used git to clone the android_prebuilt repo from CM.

Then, to reload your .bashrc you just edited:

source ~/.bashrc

The last thing you need is the kernel source. I suggest using the kernel source that's used for CM7 for your device. If you don't which repo to use, you can go to [LINK]http://wiki.cyanogenmod.com/index.php[/LINK], find your device, and on the right hand side look who the maintainers are. Usually a quick google of their name + github on Google will land you in the right place.

Back on the terminal, go into your android folder you created, and run:

git clone git://[MAINTAINER USERNAME]/[whatever their kernel is called].git

Wait for it to finish. You should have a a kernel source folder with about a bazillion files in it now taking up way more space than it needs to to create a 2MB kernel :p

On your trusty terminal again (make sure you're in the kernel source folder you just cloned):

cp arch/arm/configs/[device name]_defconfig .

Don't forget the period at the end to copy it to the root of the source folder. I'm not sure what the device name will be, if its coming from a CM kernel, sometimes the maintainers put cyanogenmod_ in front. For example, for me its cyanogenmod_incrediblec_defconfig.

Finally.

The last part is easy(make sure you're still in the root of your source dir):

make ARCH=arm CROSS_COMPILE=$CCOMPILER

To run it with multiple threads (much faster on multicore setups) run this instead (the number after j is the number of threads that will run):

make -j4 ARCH=arm CROSS_COMPILE=$CCOMPILER

Then wait till it's done. If you did a multithread build and the compiler didn't like something, the error probably went by a while ago and you didn't catch it. The other threads run even after the error, until they can't run anymore without the missing peiece that errored out. If this happens, just hit the up key on your keyboard ans run the same make command again. The compiler will print the error right away since none of tgr threads can continue until the error is fixed. The last few lines of Make's output should tell you where its stashed the zImage file (your finished product!).

And there you have it. I think! Let me know how it goes.