Permalink
Browse files

Link against LLVM shared library where possible

  • Loading branch information...
1 parent 693d505 commit eed2d86b4da402ccbe19986d15f0b4b957e77411 @nickg committed Mar 24, 2012
Showing with 21 additions and 0 deletions.
  1. +21 −0 m4/ax_llvm_c.m4
View
@@ -63,6 +63,7 @@ AC_DEFUN([AX_LLVM_C],
LLVM_LIBS="$($ac_llvm_config_path --libs $1)"
LLVM_VERSION="$($ac_llvm_config_path --version)"
LLVM_CONFIG_BINDIR="$($ac_llvm_config_path --bindir)"
+ LLVM_LIBDIR="$($ac_llvm_config_path --libdir)"
llvm_ver_num="$(echo $LLVM_VERSION | sed s/\\.// | sed s/svn//g)"
if test "$llvm_ver_num" -lt "30"; then
@@ -102,6 +103,26 @@ AC_DEFUN([AX_LLVM_C],
succeeded=yes
fi
+ shlib="-Wl,-rpath $LLVM_LIBDIR -lLLVM-$LLVM_VERSION"
+
+ LIBS="$LIBS_SAVED $shlib"
+ export LIBS
+
+ AC_CACHE_CHECK(for LLVM shared library,
+ ax_cv_llvm_shared,
+ [AC_LANG_PUSH([C++])
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[@%:@include <llvm-c/Core.h>]],
+ [[LLVMModuleCreateWithName("test"); return 0;]])],
+ ax_cv_llvm_shared=yes,
+ ax_cv_llvm_shared=no)
+ AC_LANG_POP([C++])])
+
+ if test "x$ax_cv_llvm_shared" = "xyes"; then
+ LLVM_LIBS="$shlib"
+ fi
+
CFLAGS="$CFLAGS_SAVED"
CXXFLAGS="$CXXFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"

0 comments on commit eed2d86

Please sign in to comment.