#!/bin/sh # Shave and a Haircut # (c) 2019 Epic Games # US Patent 6720962 returnVersion=n returnDTS=n maya= while [ "$1" != "" ]; do if [ "$1" = "-v" ]; then returnVersion=y elif [ "$1" == "-dts" ]; then returnDTS=y else maya=$1 fi shift done if [ "${maya}" = "" ]; then echo "Usage: $0 mayaVersion" >&2 echo "" exit fi gpp= utilsDir=`dirname $0` os=`${utilsDir}/getos.sh` case ${os} in ce*|deb*|fc*|rh*) gppVerNeeded=`${utilsDir}/getMayaVersions.sh | grep "^${maya}[[:space:]]" | head -n 1 | cut -f 3` if [ "${gppVerNeeded}" != "" ]; then if [ "${returnVersion}" = "y" ]; then echo ${gppVerNeeded} exit fi # 4.8.2 builds on CentOS 6 require DTS. if [ "${os/.*/}" = "ce6" -a "${gppVerNeeded}" = "4.8.2" ]; then if [ "${returnDTS}" = "y" ]; then echo y exit fi source /opt/rh/devtoolset-2/enable elif [ "${returnDTS}" = "y" ]; then echo n exit fi # Check to see if there is a directory in /opt containing the # compiler we want. compressedVer=`echo ${gppVerNeeded} | sed 's/\.//g'` shortVer=`echo ${gppVerNeeded} | cut -d. -f-2` if [ -x /opt/gcc${compressedVer}/bin/g++ ]; then gpp="/opt/gcc${compressedVer}/bin/g++" elif [ -x /opt/gcc${compressedVer}/bin/g++${compressedVer} ]; then gpp="/opt/gcc${compressedVer}/bin/g++${compressedVer}" elif [ -x /usr/bin/g++-${shortVer} ]; then gpp="/usr/bin/g++-${shortVer}" else # Nothing in /opt, so see if the native g++ is the correct # version. nativeVer=`g++ -v 2>&1 | grep "gcc version" | sed 's/^[^0-9]*\([0-9.]*\).*$/\1/'` if [ "${nativeVer}" = "${gppVerNeeded}" ]; then gpp=g++ fi fi fi ;; osx*) if [ "${returnDTS}" = "y" ]; then echo n exit fi # getosxvars.sh sets environment variables which control where we find # the compiler, so we can just use 'g++' in all cases. gpp=g++ ;; esac echo ${gpp}