Android NDK comes with a few toolchains under the toolchain directory. We can also build our own toolchain from the source code.
0. Download Latest Android NDK (r8c at the time of writing) from Android NDK website at http://developer.android.com/tools/sdk/ndk/index.html. Extract the downloaded archive.
$ tar xvf android-ndk-r8c-linux-x86.tar.bz2
1. Get into the ndk directory. Download the Android NDK source code to the src directory.
$ cd android-ndk-r8c/
$ ./build/tools/download-toolchain-sources.sh src
2. Install the following libraries
sudo apt-get install libncurses5-dev
sudo apt-get install texinfo
sudo apt-get install bison
sudo apt-get install flex
3. Rebuild the library is just one command. Below are two commands build two different toolchains with different versions of GCC and GDB.
./build/tools/build-gcc.sh –verbose –gdb-version=6.6 $(pwd)/src $(pwd) arm-linux-androideabi-4.6
./build/tools/build-gcc.sh –verbose –gdb-version=7.3.x $(pwd)/src $(pwd) arm-linux-androideabi-4.7
The toolchain built can be found under toolchains directory of the Android NDK folder.
原文http://www.roman10.net/2012/11/19/build-android-ndk-toolchain-from-source-code/