Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
162 lines (120 sloc) 4.01 KB
AC_INIT(src/Rllvm.h)
AC_ARG_WITH(llvm-config, [ --with-llvm-config full path to executable for llvm-config], LLVM_CONFIG="${withval}")
if test -z "${LLVM_CONFIG}" ; then
AC_PATH_PROG(LLVM_CONFIG, llvm-config)
if test -z "${LLVM_CONFIG}" ; then
echo "cannot find llvm-config in your path. Make certain it is installed and in your path"
exit 1;
fi
fi
${LLVM_CONFIG} --system-libs &> /dev/null
#LLVM_HAS_SYS_LIBS=$?
if test "$?" = "0" ; then
LLVM_SYS_LIBS="--system-libs"
else
LLVM_SYS_LIBS=""
fi
AC_SUBST(LLVM_SYS_LIBS)
echo "LLVM_HAS_SYS_LIBS = ${LLVM_SYS_LIBS}"
LLVM_VERSION_NUMBER=`${LLVM_CONFIG} --version | sed -e 's/svn//'`
dnl LLVM_VERSION=`${LLVM_CONFIG} --version | sed -e 's/\.[[0-9].]*//' | sed -e 's/svn//'`
dnl LLVM_MINOR_VERSION=`${LLVM_CONFIG} --version | sed -e 's/[[0-9]]\.//' | sed -e 's/svn//'`
LLVM_VERSION=`${LLVM_CONFIG} --version | sed -Ee 's/\.[[0-9]]*(\.[[0-9]]*)?//' | sed -e 's/svn//'`
LLVM_MINOR_VERSION=`${LLVM_CONFIG} --version | sed -Ee 's/[[0-9]]\.//' | sed -Ee 's/\.[[0-9]]*//' | sed -e 's/svn//'`
echo "LLVM_VERSION_NUMBER = ${LLVM_VERSION_NUMBER}, VERSION = ${LLVM_VERSION}, MINOR = ${LLVM_MINOR_VERSION}"
CXXFLAGS=`${LLVM_CONFIG} --cxxflags`
AC_LANG(C++)
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(
#include <llvm/LLVMContext.h>
void foo() {
}
)], [echo "Successfully include LLVMContext.h"],
[CHECK_IR_DIR=1])
if test -z $CHECK_IR_DIR ; then
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(
#include <llvm/LLVMContext.h>
void foo() {
}
)], [echo "Successfully include LLVMContext.h"],
AC_MSG_FAILURE("cannot include llvm/LLVMContext.h. Check that you have a suitable version of llvm installed."))
fi
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(
#include <llvm/IR/Attributes.h>
void foo() {
int i = (int) llvm::Attribute::NoUnwind;
}
)], [echo "New Attribute setup (> 3.2)"; NEW_LLVM_ATTRIBUTES_SETUP="-DNEW_LLVM_ATTRIBUTES_SETUP=1"],
[echo "Using old Attributes (<= 3.2)"; NEW_LLVM_ATTRIBUTES_SETUP=""];)
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(
#include <llvm/IR/Attributes.h>
void foo() {
int i = (int) llvm::Attribute::NoUnwind;
}
)], [echo "DataLayout.h in IR/"; LLVM_DATALAYOUT_H_IN_IR="-DLLVM_DATALAYOUT_H_IN_IR=1"],
[echo "Using old Attributes (<= 3.2)"; LLVM_DATALAYOUT_H_IN_IR=""];)
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(
#include <llvm/IR/Attributes.h>
void foo() {
llvm::TargetOptions dflt;
dflt.LessPreciseFPMADOption = true;
}
)], [echo "LessPreciseFPMADOption available"; LLVM_CFLAGS="$LLVM_CFLAGS -DLLVM_HAS_LESSPRECISEFPMADOPTION=1"],
[echo "LessPreciseFPMADOption NOT available" ];)
LLVM_TARGETS="`${LLVM_CONFIG} --targets-built`"
echo "version: $LLVM_VERSION, minor = $LLVM_MINOR_VERSION"
AC_SUBST(LLVM_CONFIG)
AC_SUBST(LLVM_VERSION_NUMBER)
AC_SUBST(LLVM_VERSION)
AC_SUBST(LLVM_MINOR_VERSION)
AC_SUBST(LLVM_TARGETS)
AC_SUBST(NEW_LLVM_ATTRIBUTES_SETUP)
AC_SUBST(LLVM_DATALAYOUT_H_IN_IR)
AC_SUBST(LLVM_CFLAGS)
echo ""
echo "*** llvm-config ${LLVM_CONFIG}"
echo ""
if test -r R/targets.R ; then
chmod +w R/targets.R
fi
dnl #########################################################################################
if test -z "$FFI_LIB" ; then
# pkgconfig
#
AC_PATH_PROG(PKG_CONFIG, pkg-config)
if test -r /usr/local/lib/libffi.a ; then
FFI_LIB="-L/usr/local/lib -lffi"
fi
if test -n "$PKG_CONFIG" ; then
TMP=`$PKG_CONFIG --libs libffi`
if test "$?" = 0 ; then
echo "found libffi via pkg-config"
FFI_LIB=$TMP
fi
fi
else
echo "FFI_LIB set $FFI_LIB"
if test -d "$FFI_LIB" ; then
if test -r "$FFI_LIB/libffi.a" ; then
echo "Found libffi in $FFI_LIB"
FFI_LIB="-L$FFI_LIB -lffi"
else
echo "Cannot find libffi.a in $FFI_LIB"
fi
else
TMP=`echo "$FFI_LIB" | cut -c -1-2`
if ! test "$TMP" = "-L" ; then
echo "****** $FFI_LIB is set but is not a directory and does not start with -L. This may cause problems!"
fi
fi
fi
AC_SUBST(FFI_LIB)
AC_OUTPUT(src/Makevars)
AC_OUTPUT(R/targets.R)
AC_OUTPUT(R/llvmVersion.R)
chmod -w R/targets.R
echo "Compile & Link flags: `${LLVM_CONFIG} --cxxflags --ldflags`"