Easily building Clang from source (script)
April 1st, 2012
Here’s a bash script to automatically check out and build the latest LLVM/Clang sources in Release mode:
#!/bin/bash
CURDIR=$(pwd)/
LLVMDIR=${CURDIR}/llvm
CLANGDIR=${LLVMDIR}/tools/clang
BUILDDIR=${CURDIR}/build
mkdir ${BUILDDIR}
if [ ! -d ${LLVMDIR} ]
then
mkdir ${LLVMDIR}
fi
cd ${LLVMDIR}
if [ ! -d .svn ]
then
echo Checking out LLVM source
svn co http://llvm.org/svn/llvm-project/llvm/trunk .
else
echo Updating LLVM source
svn update
fi
if [ ! -d ${CLANGDIR} ]
then
mkdir ${CLANGDIR}
fi
cd ${CLANGDIR}
if [ ! -d .svn ]
then
echo Checking out Clang source
svn co http://llvm.org/svn/llvm-project/cfe/trunk .
else
echo Updating Clang source
svn update
fi
if [ ! -d ${BUILDDIR} ]
then
mkdir ${BUILDDIR}
fi
cd ${BUILDDIR}
${LLVMDIR}/configure
# Release Mode
export ENABLE_OPTIMIZED=1
export DISABLE_ASSERTIONS=1
echo Building LLVM with Clang...
make