summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-04-02 12:01:21 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-05 05:42:38 -0400
commit0de2012cc05b12a810d27f5c9009c870cf6fabfd (patch)
treed2d7981348de4a93b667b356908902a2211213cf /m4
parent34452fbdf556919e563ab57df792a1413051a74a (diff)
downloadhaskell-0de2012cc05b12a810d27f5c9009c870cf6fabfd.tar.gz
configure: Move libnuma check to macro
Diffstat (limited to 'm4')
-rw-r--r--m4/fp_find_libnuma.m460
1 files changed, 60 insertions, 0 deletions
diff --git a/m4/fp_find_libnuma.m4 b/m4/fp_find_libnuma.m4
new file mode 100644
index 0000000000..4f55453f8e
--- /dev/null
+++ b/m4/fp_find_libnuma.m4
@@ -0,0 +1,60 @@
+AC_DEFUN([FP_FIND_LIBNUMA],
+[
+ dnl ** Have libnuma?
+ dnl --------------------------------------------------------------
+ AC_ARG_WITH([libnuma-libraries],
+ [AS_HELP_STRING([--with-libnuma-libraries=ARG],
+ [Find libraries for libnuma in ARG [default=system default]])
+ ],
+ [
+ LibNumaLibDir="$withval"
+ LIBNUMA_LDFLAGS="-L$withval"
+ ])
+
+ AC_SUBST(LibNumaLibDir)
+
+ AC_ARG_WITH([libnuma-includes],
+ [AS_HELP_STRING([--with-libnuma-includes=ARG],
+ [Find includes for libnuma in ARG [default=system default]])
+ ],
+ [
+ LibNumaIncludeDir="$withval"
+ LIBNUMA_CFLAGS="-I$withval"
+ ])
+
+ AC_SUBST(LibNumaIncludeDir)
+
+ HaveLibNuma=0
+ AC_ARG_ENABLE(numa,
+ [AS_HELP_STRING([--enable-numa],
+ [Enable NUMA memory policy and thread affinity support in the
+ runtime system via numactl's libnuma [default=auto]])])
+
+ if test "$enable_numa" != "no" ; then
+ CFLAGS2="$CFLAGS"
+ CFLAGS="$LIBNUMA_CFLAGS $CFLAGS"
+ LDFLAGS2="$LDFLAGS"
+ LDFLAGS="$LIBNUMA_LDFLAGS $LDFLAGS"
+
+ AC_CHECK_HEADERS([numa.h numaif.h])
+
+ if test "$ac_cv_header_numa_h$ac_cv_header_numaif_h" = "yesyes" ; then
+ AC_CHECK_LIB(numa, numa_available,HaveLibNuma=1)
+ fi
+ if test "$enable_numa:$HaveLibNuma" = "yes:0" ; then
+ AC_MSG_ERROR([Cannot find system libnuma (required by --enable-numa)])
+ fi
+
+ CFLAGS="$CFLAGS2"
+ LDFLAGS="$LDFLAGS2"
+ fi
+
+ AC_DEFINE_UNQUOTED([HAVE_LIBNUMA], [$HaveLibNuma], [Define to 1 if you have libnuma])
+ if test $HaveLibNuma = "1" ; then
+ AC_SUBST([UseLibNuma],[YES])
+ AC_SUBST([CabalHaveLibNuma],[True])
+ else
+ AC_SUBST([UseLibNuma],[NO])
+ AC_SUBST([CabalHaveLibNuma],[False])
+ fi
+])