diff --git a/configure.ac b/configure.ac index 3a308a996c..ac7d2468b8 100644 --- a/configure.ac +++ b/configure.ac @@ -173,6 +173,11 @@ AC_OUTPUT if test "$enable_llvm" = "yes" && test "$subdirfailed" != "no"; then AC_MSG_ERROR([Failed to configure LLVM, and LLVM was explicitly requested]) fi +if test "$enable_llvm" = "auto" && test "$subdirfailed" != "no"; then + system_llvm="MIA" + llvm_linking="" +fi + AM_CONDITIONAL([ENABLE_LLVM], [test "$subdirfailed" != "yes" && test "$enable_llvm" != "no"]) no_recursion="yes"; @@ -216,7 +221,11 @@ have_jit="no" if test "$subdirfailed" = "no"; then have_jit="yes" fi -CL_MSG_STATUS([llvm ],[$have_jit, from $system_llvm],[$enable_llvm]) +if test "x$llvm_linking" = "x"; then + CL_MSG_STATUS([llvm ],[$have_jit, from $system_llvm],[$enable_llvm]) +else + CL_MSG_STATUS([llvm ],[$have_jit, from $system_llvm ($llvm_linking)],[$enable_llvm]) +fi CL_MSG_STATUS([mempool ],[$have_mempool],[$enable_mempool]) AC_MSG_NOTICE([Summary of engine detection features]) diff --git a/libclamav/c++/configure.ac b/libclamav/c++/configure.ac index 102478cff5..7fb58aabf3 100644 --- a/libclamav/c++/configure.ac +++ b/libclamav/c++/configure.ac @@ -77,6 +77,26 @@ AC_ARG_WITH([system-llvm], AC_HELP_STRING([--with-system-llvm], fi ]) +llvm_linking= +AC_ARG_WITH([llvm-linking], [AC_HELP_STRING([--with-llvm-linking], +[specifies method to linking llvm @<:@static|dynamic@:>@, only valid with --with-system-llvm])], +[ +if test "x$llvmconfig" = "x"; then + AC_MSG_ERROR([Failed to configure LLVM, and LLVM linking was specified without valid llvm-config]) +else +case "$withval" in + static) + llvm_linking="static" + ;; + dynamic) + llvm_linking="dynamic" + ;; + *) + AC_MSG_ERROR([Invalid argument to --with-llvm-linking]) +esac +fi +], []) + AC_MSG_CHECKING([for supported LLVM version]) if test "x$llvmconfig" = "x"; then dnl macro not available in older autotools @@ -112,16 +132,24 @@ fi dnl aquire the required flags to properly link in external LLVM if test "x$llvmconfig" != "x"; then AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`]) - if test $llvmver_test -ge 350; then - dnl LLVM 3.5.0 and after splits linker flags into two sets - ldflags=`$llvmconfig --ldflags` - syslibs=`$llvmconfig --system-libs` - AC_SUBST(LLVMCONFIG_LDFLAGS, ["$ldflags $syslibs"]) - else + + if test "x$llvm_linking" = "xdynamic"; then AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`]) + AC_SUBST(LLVMCONFIG_LIBS, [-lLLVM-$llvmver]) + AC_SUBST(LLVMCONFIG_LIBFILES, []) + else + if test $llvmver_test -ge 350; then + dnl LLVM 3.5.0 and after splits linker flags into two sets + ldflags=`$llvmconfig --ldflags` + syslibs=`$llvmconfig --system-libs` + AC_SUBST(LLVMCONFIG_LDFLAGS, ["$ldflags $syslibs"]) + else + AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`]) + fi + AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs jit nativecodegen scalaropts ipo`]) + AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles jit nativecodegen scalaropts ipo`]) fi - AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs jit nativecodegen scalaropts ipo`]) - AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles jit nativecodegen scalaropts ipo`]) + AC_MSG_NOTICE([CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS]) AC_MSG_NOTICE([LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS]) AC_MSG_NOTICE([LIBS from llvm-config: $LLVMCONFIG_LIBS]) diff --git a/m4/reorganization/llvm.m4 b/m4/reorganization/llvm.m4 index 0c7590c243..ec2bbda206 100644 --- a/m4/reorganization/llvm.m4 +++ b/m4/reorganization/llvm.m4 @@ -13,6 +13,31 @@ AC_ARG_WITH([system-llvm], [AC_HELP_STRING([--with-system-llvm], esac ], [system_llvm="built-in"]) +AC_ARG_WITH([llvm-linking], [AC_HELP_STRING([--with-llvm-linking], +[specifies method to linking llvm @<:@static|dynamic@:>@, only valid with --with-system-llvm])], +[ +if test "x$system_llvm" = "xbuilt-in"; then + AC_MSG_ERROR([Failed to configure LLVM, and LLVM linking was specified without specifying system-llvm]) +else +case "$withval" in + static) + llvm_linking="static" + ;; + dynamic) + llvm_linking="dynamic" + ;; + *) + AC_MSG_ERROR([Invalid argument to --with-llvm-linking]) +esac +fi +], [ +if test "x$system_llvm" = "xbuilt-in"; then + llvm_linking="" +else + llvm_linking="auto" +fi +]) + AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm], [enable 'llvm' JIT/verifier support @<:@default=auto@:>@]), [enable_llvm=$enableval], @@ -29,4 +54,5 @@ if test "$enable_llvm" != "no"; then AC_CONFIG_SUBDIRS_OPTIONAL([libclamav/c++]) else system_llvm="none" + llvm_linking="" fi