2 # --------------------------------------------------------------
3 # Should we used libffi? (yes or no)
6 # - UseSystemLibFFI: [YES|NO]
7 # - FFILibDir: optional path
8 # - FFIIncludeDir: optional path
9 AC_DEFUN([FP_FIND_LIBFFI],
13 AC_ARG_WITH([system-libffi],
14 [AS_HELP_STRING([--with-system-libffi],
15 [Use system provided libffi for RTS [default=no]])
18 AS_IF([test "x$with_system_libffi" = "xyes"],
19 [UseSystemLibFFI="YES"],
20 [UseSystemLibFFI="NO"]
23 AC_ARG_WITH([ffi-includes],
24 [AS_HELP_STRING([--with-ffi-includes=ARG],
25 [Find includes for libffi in ARG [default=system default]])
28 if test "x$UseSystemLibFFI" != "xYES"; then
29 AC_MSG_WARN([--with-ffi-includes will be ignored, --with-system-libffi not set])
31 FFIIncludeDir="$withval"
32 LIBFFI_CFLAGS="-I$withval"
36 AC_ARG_WITH([ffi-libraries],
37 [AS_HELP_STRING([--with-ffi-libraries=ARG],
38 [Find libffi in ARG [default=system default]])
41 if test "x$UseSystemLibFFI" != "xYES"; then
42 AC_MSG_WARN([--with-ffi-libraries will be ignored, --with-system-libffi not set])
44 FFILibDir="$withval" LIBFFI_LDFLAGS="-L$withval"
48 AS_IF([test "$UseSystemLibFFI" = "YES"], [
50 CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
52 LDFLAGS="$LIBFFI_LDFLAGS $LDFLAGS"
54 if test "$HostOS" = "openbsd";
56 # OpenBSD's libffi is not directly linked to the libpthread but
57 # still requires pthread functionality. This means that any client
58 # binary which links with libffi also needs to link with
59 # libpthread. If it does not, then linking fails with unresolved
61 LDFLAGS="$LDFLAGS -lpthread"
64 AC_CHECK_LIB(ffi, ffi_call,
68 [AC_MSG_ERROR([Cannot find ffi.h for system libffi])]
70 [AC_MSG_ERROR([Cannot find system libffi])]