summaryrefslogtreecommitdiff
path: root/m4/ghc_adjustors_method.m4
blob: cae941a20e07c73132a09ee3b89c15bc354ce53a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
dnl GHC_ADJUSTORS_METHOD(Platform)
dnl --------------------------------------------------------------
dnl Use libffi for adjustors?
AC_DEFUN([GHC_ADJUSTORS_METHOD],
[
  case [$]{$1[Arch]} in
      i386|x86_64)
          # We have native adjustor support on these platforms
          HaveNativeAdjustor=yes
          ;;
      *)
          HaveNativeAdjustor=no
          ;;
  esac

  AC_ARG_ENABLE(libffi-adjustors,
      [AS_HELP_STRING(
          [--enable-libffi-adjustors],
          [Force use of libffi for adjustors, even on platforms which have support for more efficient, native adjustors.])],
      UseLibffiForAdjustors=$enableval,
      dnl do nothing
  )

  AC_MSG_CHECKING([whether to use libffi for adjustors])
  if test "$UseLibffiForAdjustors" = "yes" ; then
      # Use libffi is the user explicitly requested it
      AdjustorType="libffi"
  elif test "$HaveNativeAdjustor" = "yes"; then
      # Otherwise if we have a native adjustor implementation use that
      AdjustorType="native"
  else
      # If we don't have a native adjustor implementation then default to libffi
      AdjustorType="libffi"
  fi

  case "$AdjustorType" in
  libffi)
      UseLibffiForAdjustors=YES
      AC_MSG_RESULT([yes])
      ;;
  native)
      UseLibffiForAdjustors=NO
      AC_MSG_RESULT([no])
      ;;
  *)
      AC_MSG_ERROR([Internal error: Invalid AdjustorType])
      exit 1
  esac
])