To build for x86-64, check this article:
http://tic-le-polard.blogspot.fr/2015/06/android-building-android-kernel-for_6.html
Get the goldfish kernel.
git clone https://android.googlesource.com/kernel/goldfish
The master branch is empty, you need to find a commit where arch/x86/configs/goldfish_defconfig exist because the CONFIG options you need to build the kernel correctly for the emulation platform are in it.
Let's list all the different branch of the kernel
git branch -a
master
remotes/origin/HEAD -> origin/master
remotes/origin/android-3.10
remotes/origin/android-3.4
remotes/origin/android-goldfish-2.6.29
remotes/origin/android-goldfish-3.10
remotes/origin/android-goldfish-3.4
remotes/origin/linux-goldfish-3.0-wip
remotes/origin/master
Now check what version of the kernel the emulator is running:
Follow the android guide to get android studio :
http://developer.android.com/tools/studio/index.html
Create a hello world app and run it in the emulator and create an x86 avd.
(You can also directly use the sdk tools to create them, but here everything is pretty much automated and the configuration is done for you.)
Use adb to connect to the emulator.
Add to your path the platform-tools and tools directory from the sdk directory.
adb devices # list all emulator instances
adb shell dmesg| grep "Linux version"
<5>[ 0.000000] Linux version 3.4.67+ (digit@tyrion.par.corp.google.com) (gcc version 4.8 (GCC) ) #3 PREEMPT Tue Sep 16 19:46:22 CEST 2014
Let's get the 3.4 version of the goldfish kernel. It is proved to work :)
git checkout remotes/origin/android-goldfish-3.4 -b emu_x86
ls arch/x86/configs
goldfish_defconfig i386_defconfig x86_64_defconfig
Yeah, there is a goldfish config
export ARCH=x86
make goldfish_defconfig
make -j`nproc`
That's it you should have a working kernel for the emulator
to test it:
emulator -list-avds
emulator -kernel arch/x86/bzImage -avd $your_avd -qemu -enable-kvm
You are now using your own kernel, you can compile your own modules for it, etc.