Home | History | Annotate | Download | only in gcc-sdk
      1 #!/bin/bash
      2 
      3 HOST_OS=`uname -s | tr '[:upper:]' '[:lower:]'`
      4 if [ "$HOST_OS" != "linux" ] ; then
      5   echo "ERROR: The gcc this script points to can only run on linux"
      6   exit 1
      7 fi
      8 
      9 PROGNAME=`basename $0`
     10 
     11 #PREFIX32=../../gcc/linux-x86/host/i686-linux-glibc2.7-4.4.3/bin/i686-linux  # previous version
     12 PREFIX32=../../gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/i686-linux
     13 PREFIX64=../../gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/bin/x86_64-linux
     14 
     15 options=" ${@} "   # sentinel prefix/suffix space to simplify pattern match below
     16 
     17 suffix_m32=${options##* -m32 }    # suffix after the last -m32
     18 suffix_m64=${options##* -m64 }    # suffix after the last -m64
     19 
     20 len_m32=${#suffix_m32}            # length of suffix after the last -m32
     21 len_m64=${#suffix_m64}            # length of suffix after the last -m64
     22 
     23 if [ $len_m32 -ge $len_m64 ] ; then
     24   # Choose 64-bit if -m64 only, -m64 appears after -m32, or neither exist (-eq)
     25   MY_TOOL=`dirname $0`/${PREFIX64}-${PROGNAME}
     26   # Make sure host is running 64-bit OS.
     27   # Note that "uname -m" only show host CPU is capable of.  Use the following technique
     28   # from ndk/build/core/ndk-common.sh instead
     29   file -L "$SHELL" | grep -q "x86[_-]64"
     30   if [ $? != 0 ]; then
     31     # $SHELL is not a 64-bit executable, so assume our userland is too.
     32     echo "ERROR: $MY_TOOL only run on 64-bit linux"
     33     exit 1
     34   fi
     35 else
     36   # Otherwise, choose 32-bit
     37   MY_TOOL=`dirname $0`/${PREFIX32}-${PROGNAME}
     38 fi
     39 
     40 $MY_TOOL "$@"
     41