summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-11-05 03:45:27 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-11-08 19:35:12 -0500
commit3f103b1ae4018cf35dabc00d4c9f77eaf8a35ff0 (patch)
tree6d79bc36c41b142edfd912c1daba5ae6eab58225 /m4
parent28334b475a109bdeb8d53d58c48adb1690e2c9b4 (diff)
downloadhaskell-3f103b1ae4018cf35dabc00d4c9f77eaf8a35ff0.tar.gz
Factor out GHC_ADJUSTORS_METHOD m4 macro
Diffstat (limited to 'm4')
-rw-r--r--m4/ghc_adjustors_method.m448
1 files changed, 48 insertions, 0 deletions
diff --git a/m4/ghc_adjustors_method.m4 b/m4/ghc_adjustors_method.m4
new file mode 100644
index 0000000000..3371c3d11d
--- /dev/null
+++ b/m4/ghc_adjustors_method.m4
@@ -0,0 +1,48 @@
+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])
+ AC_MSG_RESULT([$UseLibffiForAdjustors])
+ 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
+ ;;
+ native)
+ UseLibffiForAdjustors=NO
+ ;;
+ *)
+ AC_MSG_ERROR([Internal error: Invalid AdjustorType])
+ exit 1
+ esac
+])