aboutsummaryrefslogtreecommitdiff
path: root/utils/getg++vray.sh
diff options
context:
space:
mode:
Diffstat (limited to 'utils/getg++vray.sh')
-rw-r--r--utils/getg++vray.sh106
1 files changed, 106 insertions, 0 deletions
diff --git a/utils/getg++vray.sh b/utils/getg++vray.sh
new file mode 100644
index 0000000..ed226b7
--- /dev/null
+++ b/utils/getg++vray.sh
@@ -0,0 +1,106 @@
+#!/bin/sh
+
+# Shave and a Haircut
+# (c) 2019 Epic Games
+# US Patent 6720962
+
+returnVersion=n
+returnDTS=n
+vray=
+
+while [ "$1" != "" ]; do
+ if [ "$1" = "-v" ]; then
+ returnVersion=y
+ elif [ "$1" == "-dts" ]; then
+ returnDTS=y
+ else
+ vray=$1
+ fi
+ shift
+done
+
+if [ "${vray}" = "" ]; then
+ echo "Usage: $0 vrayVersion" >&2
+ echo "Where vrayVersion is 31, 36, 40, etc"
+ echo ""
+ exit
+fi
+
+gpp=
+utilsDir=`dirname $0`
+os=`${utilsDir}/getos.sh`
+
+if [ "${os/.*/}" = "ce6" ]; then
+ isCentOS6=y
+else
+ isCentOS6=n
+fi
+
+case ${os} in
+ ce*|deb*|fc*|rh*)
+ gppVerNeeded=
+ case $vray in
+ 30|31|36)
+ if [ "${returnDTS}" = "y" ]; then
+ echo n
+ exit
+ fi
+
+ gppVerNeeded=4.4.7
+ ;;
+
+ 40) # On CentOS 6 we need to use DTS for gcc 4.8.2 builds.
+ if [ "${returnDTS}" = "y" ]; then
+ echo ${isCentOS6}
+ exit
+ fi
+
+ if [ ${isCentOS6} = y ]; then
+ source /opt/rh/devtoolset-2/enable
+ fi
+
+ gppVerNeeded=4.8.2
+ ;;
+ esac
+
+ if [ "${gppVerNeeded}" != "" ]; then
+ if [ "${returnVersion}" = "y" ]; then
+ echo ${gppVerNeeded}
+ exit
+ fi
+
+ # Does the native g++ command give us the correct version?
+ nativeVer=`g++ -v 2>&1 | grep "gcc version" | sed 's/^[^0-9]*\([0-9.]*\).*$/\1/'`
+
+ if [ "${nativeVer}" = "${gppVerNeeded}" ]; then
+ gpp=g++
+ else
+ # 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}"
+ 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}