For B&I-style builds, tweak build_llvm script to prefer LLVM-G++ if
authorStuart Hastings <stuart@apple.com>
Mon, 28 Sep 2009 22:17:53 +0000 (22:17 +0000)
committerStuart Hastings <stuart@apple.com>
Mon, 28 Sep 2009 22:17:53 +0000 (22:17 +0000)
available.  Override by setting CC and CXX in the environment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83024 91177308-0d34-0410-b5e6-96231b3b80d8

utils/buildit/build_llvm

index 1c2b48091efffa886ef2b57b7bcce31952efb539..8d8c755b6091df00e671621a7b8fd0cbee62aa7d 100755 (executable)
@@ -56,9 +56,6 @@ DIR=`pwd`
 DARWIN_VERS=`uname -r | sed 's/\..*//'`
 echo DARWIN_VERS = $DARWIN_VERS
 
-# If the user has CC set in their environment unset it now
-unset CC
-
 if [ "x$RC_ProjectName" = "xllvmCore_Embedded" ]; then
     DT_HOME=$DEST_DIR/Developer/Platforms/iPhoneOS.platform/Developer/usr
     DEST_ROOT="/Developer/Platforms/iPhoneOS.platform/Developer$DEST_ROOT"
@@ -90,6 +87,15 @@ ln -s $ORIG_SRC_DIR/* $SRC_DIR/ || exit 1
 mkdir -p $DIR/obj-llvm || exit 1
 cd $DIR/obj-llvm || exit 1
 
+# If the user has set CC or CXX, respect their wishes.  If not,
+# compile with LLVM-GCC/LLVM-G++ if available; if LLVM is not
+# available, fall back to usual GCC/G++ default.
+XTMPCC=$(which llvm-gcc)
+if [ x$CC  = x -a x$XTMPCC != x ] ; then export CC=$XTMPCC  ; fi
+XTMPCC=$(which llvm-g++)
+if [ x$CXX = x -a x$XTMPCC != x ] ; then export CXX=$XTMPCC ; fi
+unset XTMPCC
+
 if [ \! -f Makefile.config ]; then
     $SRC_DIR/configure --prefix=$DT_HOME/local \
         --enable-targets=arm,x86,powerpc,cbe \
@@ -152,7 +158,7 @@ make $JOBS_FLAG $OPTIMIZE_OPTS UNIVERSAL=1 UNIVERSAL_ARCH="$TARGETS" \
     CXXFLAGS="-DLLVM_VERSION_INFO='\" Apple Build #$LLVM_VERSION\"'" \
     VERBOSE=1
 
-if ! test $? == 0 ; then
+if [ $? != 0 ] ; then
     echo "error: LLVM 'make' failed!"
     exit 1
 fi