Before starting to compile, you must determine your host system, your target system and the aliases you want to use for the last two. It is also useful to determine the object file format you use. Of course you must also download the sources.
Querying for system names
If you have GCC installed (and if not, you should read another document altogether), you have a default target installed, which is very probable the same as your current system. One way to find it, is to call gcc with the -v flag. On my system, the output was as follows:
Reading specs from /usr/lib/gcc-lib/i486-linux/184.108.40.206/specs
gcc version 220.127.116.11
This tells you that you use version 18.104.22.168 of gcc, and your system is called i486-linux. But, for the newer versions of gcc, the name has probably changed. A better way is to unpack the gcc source you want to install (remember, version 22.214.171.124 or better!) and to run config.guess (which can be found in the main directory of the package):
This is also known as the canonical configuration name. There are several aliases for it, and one way to translate an abbreviation to a canonical name is to run config.sub with the alias:
(bash) ./config.sub i486-linux
This should output something like:
Note that the above configuration, as of gcc 126.96.36.199, is a linux system with glibc-2 installed; which will be our target system, but is not our host system!
A canonical name consists of several parts, separated by dashes. The first part is the cpu type, the second part is the company which made the system (we will use pc for that), and the third part is the system. A fourth part can be present to differentiate setups in a way the first three can not.
New host system
One of the things we will do is update your compiler to the newest version. If you have a version older than gcc 2.7.0 installed, this is very important (it may contain some nasty bugs).
When we are going to recompile gcc, we must know for what default target we will configure it. This is the target that will be used if we do not cross-compile, but want to compile applications with old libc-5. The target you should choose is very probable that which config.guess returns. You can safely change the i?86 part; all ix86 targets are compatible, the only difference is the way code is optimised. Write this target (which corresponds to your host system) down somewhere now. Note that it must end with -gnulibc1.
Now we want to find the name of the libc-6 target. If you have determined the new host system name in the previous paragraph, all you have to do is remove the -gnulibc1 part and replace it with -gnu. After all, your host and target system are the same, and only differ in the use of libc-5 or libc-6. Write this name down, too.
Host and target aliases
Personally, I find the names gcc recognizes not very nice. They can be confusing, too, as for example the alias i486-linux has changed its meaning between versions 188.8.131.52 and 184.108.40.206. Fortunately, it is relatively easy to choose your own names. I will show you a method of compiling gcc and other programs that allows you to freely choose these names. It is of course sensible to use names that are easy to recognize. Choose now your alias names for both host and target systems.
These are the canonical names and their aliases used throughout this document. You should decide upon your own names before progressing.