I’m developing on two different machines at the moment. On one gcc maps to gcc 4.6 and there is a gcc3 for whomever needs a really old version of gcc. On the other machine gcc maps to a v3 gcc and there is a gcc4 command for invoking the newer compiler.
The problem should be obvious – I want a single makefile for both machines, which basically means defining CC depending on whether gcc4 can be found or not.
As a quick hack you could add a simple shell based check for a gcc4 bin inside your makefile. For example:
However, for more mature projects I would recommend consider tools designed for such task in mind (autoconf).