Simply following google's official online documentation can't build the android kernel source easily, here are some notes to build it succeed, all is from my own experiments and testing.
1. "elf xxx" error as below:
The solution is about adding a "elf.h" file, and some slight changes on another 2 files:
Step1: add a file: "elf.h" to /kernel repository/scripts/mod/
Step2: change #include <elf.h> to #include "elf.h" in the following files in /kernel repository/scripts/mod/: mk_elfconfig.c and modpost.h
2. Toolchan issue, the google's doc says we should use "export PATH=$(pwd)/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH
" before building, but it doesn't say it is for linux:) Luckly, if you look into the source code folder structure "prebuilts", you'll find something about "darwin", that's about mac os!!!, so we should replace the "linux-x86" with "darwin-x86".
Finally the compiler is happy, and we get the goldfish emulator work with my kernel: