This is a condensed version of the notes in a previous post.
From a fresh install
First – Install the necessary packages:
sudo apt-get install git-core gnupg flex bison gperf dpkg-dev gcc-multilib build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 libgl-dev
Second – Grab the source (http://source.android.com/source/downloading.html)
Third – Download and apply the patch (https://haven.ecs.syr.edu/~lok/AndroidGingerbread_GCC47.diff)
Fourth – Either do an update on QEMU to get to version 12 (http://source.android.com/source/known-issues.html) or download and apply the patch (https://haven.ecs.syr.edu/~lok/AndroidGingerbread_QEMU_12.diff)
Fifth – Build the source according to the directions (http://source.android.com/source/building.html)