autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking for and setting compiler to use


From: Bill Wendling
Subject: Re: Checking for and setting compiler to use
Date: Thu, 25 Apr 2002 10:37:15 -0500
User-agent: Mutt/1.2.5.1i

Also sprach Adam Tee:
} Hi,
} 
} I'm wondering how I can check for and set a compiler version??
} The reason I want to do this is because I have both gcc 2.95 and gcc3
} installed and want to be able to choose between them when I configure 
} the project.
} 
} Thanks in advance
} 
This bit of code might work to determine which is a 2.95 gcc compiler and
which is a 3.0.x gcc compiler. It's what we use, anyway :-):


cc_version="`$CC $CFLAGS -v 2>&1 |grep 'gcc version' |\
                sed 's/.*gcc version \([-a-z0-9\.]*\).*/\1/'`"
cc_vendor=`echo $cc_version |sed 's/\([a-z]*\).*/\1/'`
cc_version=`echo $cc_version |sed 's/[-a-z]//g'`

if test X = "X$cc_vendor" -a X != "X$cc_version"; then
        cc_vendor=gcc
fi

if test "-" != "$cc_vendor-$cc_version"; then
        echo "compiler '$CC' is GNU $cc_vendor-$cc_version"
fi

# Some version numbers
cc_vers_major=`echo $cc_version | cut -f1 -d.`
cc_vers_minor=`echo $cc_version | cut -f2 -d.`
cc_vers_patch=`echo $cc_version | cut -f3 -d.`
test -n "$cc_vers_major" || cc_vers_major=0
test -n "$cc_vers_minor" || cc_vers_minor=0
test -n "$cc_vers_patch" || cc_vers_patch=0
cc_vers_all=`expr $cc_vers_major '*' 1000000 + $cc_vers_minor '*' 1000 + 
$cc_vers_patch`

-- 
|| Bill Wendling                        address@hidden
|| Coding Simian



reply via email to

[Prev in Thread] Current Thread [Next in Thread]