gecko/build/autoconf/clang-plugin.m4
Ehsan Akhgari 02a48f1bce Bug 1112974 - Try to find llvm-config through clang first before looking at $PATH; r=glandium
Right now, if the LLVMCONFIG variable is not set in the .mozconfig, we
first look for the system default llvm-config and only then we ask clang
itself, which breaks building with the clang plugin if you make $CC and
$CXX point to a non-default clang binary.  This patch fixes the issue
by reversing the search order.

--HG--
extra : rebase_source : 23ab716f4e220097e4c31092475dba769f4e7dfc
2014-12-19 13:13:44 -05:00

57 lines
1.8 KiB
Plaintext

dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
AC_DEFUN([MOZ_CONFIG_CLANG_PLUGIN], [
MOZ_ARG_ENABLE_BOOL(clang-plugin,
[ --enable-clang-plugin Enable building with the mozilla clang plugin ],
ENABLE_CLANG_PLUGIN=1,
ENABLE_CLANG_PLUGIN= )
if test -n "$ENABLE_CLANG_PLUGIN"; then
if test -z "$CLANG_CC"; then
AC_MSG_ERROR([Can't use clang plugin without clang.])
fi
AC_MSG_CHECKING([for llvm-config])
if test -z "$LLVMCONFIG"; then
LLVMCONFIG=`$CXX -print-prog-name=llvm-config`
fi
if test -z "$LLVMCONFIG"; then
LLVMCONFIG=`which llvm-config`
fi
if test ! -x "$LLVMCONFIG"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Cannot find an llvm-config binary for building a clang plugin])
fi
AC_MSG_RESULT([$LLVMCONFIG])
if test -z "$LLVMCONFIG"; then
AC_MSG_ERROR([Cannot find an llvm-config binary for building a clang plugin])
fi
LLVM_CXXFLAGS=`$LLVMCONFIG --cxxflags`
LLVM_LDFLAGS=`$LLVMCONFIG --ldflags --system-libs --libs core mc analysis asmparser mcparser bitreader option | xargs`
if test "${OS_ARCH}" = "Darwin"; then
CLANG_LDFLAGS="-lclangFrontend -lclangDriver -lclangSerialization"
CLANG_LDFLAGS="$CLANG_LDFLAGS -lclangParse -lclangSema -lclangAnalysis"
CLANG_LDFLAGS="$CLANG_LDFLAGS -lclangEdit -lclangAST -lclangLex"
CLANG_LDFLAGS="$CLANG_LDFLAGS -lclangBasic -lclangASTMatchers"
else
CLANG_LDFLAGS="-lclangASTMatchers"
fi
AC_DEFINE(MOZ_CLANG_PLUGIN)
fi
AC_SUBST(LLVM_CXXFLAGS)
AC_SUBST(LLVM_LDFLAGS)
AC_SUBST(CLANG_LDFLAGS)
AC_SUBST(ENABLE_CLANG_PLUGIN)
])