build/clang-plugin/configure
author Ehsan Akhgari <ehsan@mozilla.com>
Sat, 31 May 2014 09:13:32 -0400
changeset 206301 288387f37b70025dfe935370864187d46b633ce9
parent 137257 cf75954e488fa602bf19de0b44a710066d0a5c5d
child 220458 112cf093670bc0e955da224b2738a80a68656293
permissions -rwxr-xr-x
Bug 861425 - Build the clang plugin on Mac; r=jcranmer

#!/bin/sh

PLATFORM=`uname`

# Default srcdir to this directory
srcdir=

for option; do
  case "$option" in
  -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  *) optarg= ;;
  esac

  case "$option" in
  --srcdir=*) srcdir="$optarg";;
  esac
done

if test -z "$CXX"; then
  CXX=`which clang++`
fi

echo -n "checking for llvm-config... "

if test -z "$LLVMCONFIG"; then
  LLVMCONFIG=`which llvm-config`
fi

if test -z "$LLVMCONFIG"; then
  LLVMCONFIG=`dirname $CXX`/llvm-config
fi

if test ! -x "$LLVMCONFIG"; then
  echo "configure: error: Cannot find an llvm-config binary for building a clang plugin" 1>&2
  exit 1
fi

echo "$LLVMCONFIG"

LLVMLIBS="core mc analysis asmparser mcparser bitreader"
LLVMCXXFLAGS=`$LLVMCONFIG --cxxflags`
LLVMLDFLAGS=`$LLVMCONFIG --ldflags`
LLVMLDFLAGS="$LLVMLDFLAGS `$LLVMCONFIG --libs $LLVMLIBS`"

if [ $PLATFORM == Darwin ]; then
  DSO_LDOPTS="-dynamiclib -shared"
  CLANGLDFLAGS="-lclangFrontend -lclangDriver -lclangSerialization \
                 -lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST \
                 -lclangLex -lclangBasic -lclangASTMatchers"
  DLL_SUFFIX="dylib"
else
  DSO_LDOPTS="-shared"
  CLANGLDFLAGS=-lclangASTMatchers
  DLL_SUFFIX="so"
fi

CXXFLAGS="$CXXFLAGS $LLVMCXXFLAGS -fno-rtti -fno-exceptions"
LDFLAGS="$LDFLAGS $LLVMLDFLAGS $CLANGLDFLAGS"

cat $srcdir/Makefile.in | sed \
  -e "s%@CXX@%$CXX%" \
  -e "s%@CXXFLAGS@%$CXXFLAGS%" \
  -e "s%@LDFLAGS@%$LDFLAGS%" \
  -e "s%@srcdir@%$srcdir%" \
  -e "s%@DSO_LDOPTS@%$DSO_LDOPTS%" \
  -e "s%@DLL_SUFFIX@%$DLL_SUFFIX%" \
  > Makefile