'what' cannot find ccversion if `which cc` is a symlink to ccache
H.Merijn Brand [Thu, 10 Feb 2005 15:56:04 +0000 (15:56 +0000)]
ccversion is important enough to jump through some hoops to get it

p4raw-id: //depot/perl@23958

hints/hpux.sh

index 8fe7092..c74b66a 100644 (file)
@@ -136,7 +136,28 @@ case `$cc -v 2>&1`"" in
                esac
            ;;
     *)      ccisgcc=''
-           ccversion=`which cc | xargs what | awk '/Compiler/{print $2}/Itanium/{print $6,$7}'`
+           # What cannot be use in combination with ccache links :(
+           cc_found=""
+           for p in `echo $PATH | tr : ' ''` ; do
+               x="$p/cc"
+               if [ -f $x ] && [ -x $x ]; then
+                   if [ -h $x ]; then
+                       l=`ls -l $x | sed 's,.*-> ,,'`
+                       case $l in
+                           /*) x=$l            ;;
+                           *)  x="$p/$l"       ;;
+                           esac
+                       fi
+                   x=`echo $x | sed 's,/\./,/,g'`
+                   case $x in
+                       *ccache*) ;;
+                       *) [ -z "$cc_found" ] && cc_found=$x ;;
+                       esac
+                   fi
+               done
+           [ -z "$cc_found" ] && cc_found=`which cc`
+           what $cc_found >&4
+           ccversion=`which $cc_found | xargs what | awk '/Compiler/{print $2}/Itanium/{print $6,$7}'`
            case "$ccflags" in
                "-Ae "*) ;;
                *)  ccflags="-Ae $cc_cppflags"