Reputation: 30216
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.
Upvotes: 0
Views: 89
Reputation: 1598
As a quick hack you could add a simple shell based check for a gcc4 bin inside your makefile. For example:
CC := $(shell gcc4 -dumpversion >/dev/null 2>&1; if [ "$$?" -eq 0 ]; then echo "gcc4"; else echo "gcc"; fi)
<...>
$(CC) -c myprogram.c -o myprogram.o
<...>
However, for more mature projects I would recommend consider tools designed for such task in mind (autoconf).
Upvotes: 1