GCC 4.2 is out and already in Debian/unstable. While I'm keen to try out the latest and the greatest, I'd like to keep gcc-3.4 around, just in case some weird software cannot be compiled with gcc-4.x (btw, is gcc-2.95 really obsolete by now?). And I only want to have one gcc-4.x on my system - however, that's not yet possible, because various applications are depending on gcc-4.1.x.
OK, fine, I'm gonna have 3 different GCC versions on the box. Luckily Debian comes with update-alternatives and I finally came across a useful post in ubuntuforums.org describing how to actually use it:
$ update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.2 60 \
--slave /usr/bin/cc cc /usr/bin/gcc-4.2 \
--slave /usr/bin/cpp cpp /usr/bin/cpp-4.2 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-4.2 \
--slave /usr/bin/g++ g++ /usr/bin/g++-4.2
$ update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.1 40 \
--slave /usr/bin/cc cc /usr/bin/gcc-4.1 \
--slave /usr/bin/cpp cpp /usr/bin/cpp-4.1 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-4.1 \
--slave /usr/bin/g++ g++ /usr/bin/g++-4.1
$ update-alternatives --config gcc
There are 2 alternatives which provide `gcc'.
*+ 1 /usr/bin/gcc-4.2
Press enter to keep the default[*], or type selection number: 1
Using `/usr/bin/gcc-4.2' to provide `gcc'.
The '40' and '60' are priorities, which are explained in the manpage. I don't really make use of them however.