Link against libffi if available, fall back to "no external calls from
[oota-llvm.git] / autoconf / configure.ac
index 9b852d970ff372c4edd786d18a417ca04252af53..6441eaa621f3f2e4039f1d8d63cc675c53e50783 100644 (file)
@@ -255,13 +255,13 @@ else
   AC_SUBST(LLVM_CROSS_COMPILING, [0])
 fi
 
-dnl Check to see if there's a "CVS" (or .svn) directory indicating that this
-dnl build is being done from a checkout. This sets up several defaults for the
-dnl command line switches. When we build with a CVS directory, we get a
-dnl debug with assertions turned on. Without, we assume a source release and we
-dnl get an optimized build without assertions. See --enable-optimized and
-dnl --enable-assertions below
-if test -d "CVS" -o -d "${srcdir}/CVS" -o -d ".svn" -o -d "${srcdir}/.svn"; then
+dnl Check to see if there's a "CVS" (or .svn or .git) directory indicating
+dnl that this build is being done from a checkout. This sets up several
+dnl defaults for the command line switches. When we build with a CVS directory,
+dnl we get a debug with assertions turned on. Without, we assume a source
+dnl release and we get an optimized build without assertions.
+dnl See --enable-optimized and --enable-assertions below
+if test -d "CVS" -o -d "${srcdir}/CVS" -o -d ".svn" -o -d "${srcdir}/.svn" -o -d ".git" -o -d "${srcdir}/.git"; then
   cvsbuild="yes"
   optimize="no"
   AC_SUBST(CVSBUILD,[[CVSBUILD=1]])
@@ -636,9 +636,12 @@ AC_PATH_PROGS(OCAMLDEP, [ocamldep])
 AC_PATH_PROGS(OCAMLDOC, [ocamldoc])
 AC_PATH_PROGS(GAS, [gas as])
 
-dnl Determine if the linker supports the -R option.
+dnl Determine whether the linker supports the -R option.
 AC_LINK_USE_R
 
+dnl Determine whether the linker supports the -export-dynamic option.
+AC_LINK_EXPORT_DYNAMIC
+
 dnl Check for libtool and the library that has dlopen function (which must come
 dnl before the AC_PROG_LIBTOOL check in order to enable dlopening libraries with
 dnl libtool).
@@ -734,8 +737,9 @@ AC_SEARCH_LIBS(dlopen,dl,AC_DEFINE([HAVE_DLOPEN],[1],
                AC_MSG_WARN([dlopen() not found - disabling plugin support]))
 
 dnl libffi is optional; used to call external functions from the interpreter
-AC_CHECK_LIB(ffi,ffi_call,[have_libffi=1],
-             AC_MSG_WARN([libffi not found - disabling external calls from interpreter]))
+AC_SEARCH_LIBS(ffi_call,ffi,AC_DEFINE([HAVE_FFI_CALL],[1],
+               [Define if libffi is available on this platform.]),
+               AC_MSG_WARN([libffi not found - disabling external calls from interpreter]))
 
 dnl mallinfo is optional; the code can compile (minus features) without it
 AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],
@@ -799,10 +803,8 @@ else
   AC_SUBST(HAVE_PTHREAD, 0)
 fi
 
-dnl Once we know we have libffi, try to find ffi.h.
-if test -n "$have_libffi" ; then
-  AC_CHECK_HEADERS([ffi.h ffi/ffi.h], [AC_SUBST(HAVE_FFI, 1)])
-fi  
+dnl Try to find ffi.h.
+AC_CHECK_HEADERS([ffi.h ffi/ffi.h])
 
 dnl===-----------------------------------------------------------------------===
 dnl===
@@ -839,8 +841,6 @@ AC_FUNC_RAND48
 
 dnl Check for variations in the Standard C++ library and STL. These macros are
 dnl provided by LLVM in the autoconf/m4 directory.
-AC_CXX_HAVE_HASH_MAP
-AC_CXX_HAVE_HASH_SET
 AC_CXX_HAVE_STD_ITERATOR
 AC_CXX_HAVE_BI_ITERATOR
 AC_CXX_HAVE_FWD_ITERATOR
@@ -1013,9 +1013,25 @@ if test "$binding_prereqs_failed" = 1 ; then
   AC_MSG_ERROR([Prequisites for bindings not satisfied. Fix them or use configure --disable-bindings.])
 fi
 
-dnl Determine if the compiler supports -fvisibility-inlines-hidden.
+dnl Determine whether the compiler supports -fvisibility-inlines-hidden.
 AC_CXX_USE_VISIBILITY_INLINES_HIDDEN
 
+dnl Determine linker rpath flag
+if test "$llvm_cv_link_use_r" = "yes" ; then
+  RPATH="-Wl,-R"
+else
+  RPATH="-Wl,-rpath"
+fi
+AC_SUBST(RPATH)
+
+dnl Determine linker rdynamic flag
+if test "$llvm_cv_link_use_export_dynamic" = "yes" ; then
+  RDYNAMIC="-Wl,-export-dynamic"
+else
+  RDYNAMIC=""
+fi
+AC_SUBST(RDYNAMIC)
+
 dnl===-----------------------------------------------------------------------===
 dnl===
 dnl=== SECTION 10: Specify the output files and generate it
@@ -1029,8 +1045,6 @@ dnl contains the same list of files as AC_CONFIG_HEADERS below. This ensures the
 dnl files can be updated automatically when their *.in sources change.
 AC_CONFIG_HEADERS([include/llvm/Config/config.h])
 AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h])
-AC_CONFIG_HEADERS([include/llvm/ADT/hash_map.h])
-AC_CONFIG_HEADERS([include/llvm/ADT/hash_set.h])
 AC_CONFIG_HEADERS([include/llvm/ADT/iterator.h])
 
 dnl Configure the makefile's configuration data