If you have ever faced the challenge of running your code on different platforms with need to support different system libs (glibc/uClibc), you probably know it's not a simple task building the toolchains. Very simplistically, a toolchain is what makes up the tools that compile, assemble and link the code being developed.
For this case, crosstool-NG comes to your rescue. It's a versatile toolchain generator that is very simple to configure. You simply fill in the appropriate values with the adequate options in a configuration file. Then point your compiler option in the Makefiles to the right compiler.
There is a decent tutorial on how to use crosstool-NG here, but it has not been updated for the newer releases. The current release is version 1.5.2.