+ case $with_gm in
+ no) ENABLE_GM=0
+ ;;
+ *) ENABLE_GM=1
+ GM_SRC="$with_gm"
+ ;;
+ esac
+ ],[
+ ENABLE_GM=0
+ ])
+AC_ARG_WITH([gm-install],
+ AC_HELP_STRING([--with-gm-install=path-to-gm-install-tree],
+ [say where GM has been installed]),
+ [
+ GM_INSTALL=$with_gm_install
+ ],[
+ GM_INSTALL="/opt/gm"
+ ])
+if test $ENABLE_GM -eq 0; then
+ AC_MSG_RESULT([no])
+else
+ AC_MSG_RESULT([yes])
+
+ GMLND="gmlnd"
+ GMCPPFLAGS="-I$GM_SRC/include -I$GM_SRC/drivers -I$GM_SRC/drivers/linux/gm"
+
+ if test -f $GM_INSTALL/lib/libgm.a -o \
+ -f $GM_INSTALL/lib64/libgm.a; then
+ GMLIBS="-L$GM_INSTALL/lib -L$GM_INSTALL/lib64"
+ else
+ AC_MSG_ERROR([Cant find GM libraries under $GM_INSTALL])
+ fi
+
+ EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
+ EXTRA_KCFLAGS="$GMCPPFLAGS -DGM_KERNEL $EXTRA_KCFLAGS"
+
+ AC_MSG_CHECKING([that code using GM compiles with given path])
+ LB_LINUX_TRY_COMPILE([
+ #define GM_STRONG_TYPES 1
+ #ifdef VERSION
+ #undef VERSION
+ #endif
+ #include "gm.h"
+ #include "gm_internal.h"
+ ],[
+ struct gm_port *port = NULL;
+ gm_recv_event_t *rxevent = gm_blocking_receive_no_spin(port);
+ return 0;
+ ],[
+ AC_MSG_RESULT([yes])
+ ],[
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([Bad --with-gm path])
+ ])
+
+ AC_MSG_CHECKING([that GM has gm_register_memory_ex_phys()])
+ LB_LINUX_TRY_COMPILE([
+ #define GM_STRONG_TYPES 1
+ #ifdef VERSION
+ #undef VERSION
+ #endif
+ #include "gm.h"
+ #include "gm_internal.h"
+ ],[
+ gm_status_t gmrc;
+ struct gm_port *port = NULL;
+ gm_u64_t phys = 0;
+ gm_up_t pvma = 0;
+
+ gmrc = gm_register_memory_ex_phys(port, phys, 100, pvma);
+ return 0;
+ ],[
+ AC_MSG_RESULT([yes])
+ ],[
+ AC_MSG_RESULT([no.
+Please patch the GM sources as follows...
+ cd $GM_SRC
+ patch -p0 < $PWD/lnet/klnds/gmlnd/gm-reg-phys.patch
+...then rebuild and re-install them])
+ AC_MSG_ERROR([Can't build GM without gm_register_memory_ex_phys()])
+ ])
+
+ EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
+fi
+AC_SUBST(GMCPPFLAGS)
+AC_SUBST(GMLIBS)
+AC_SUBST(GMLND)
+])
+
+
+#
+# LN_CONFIG_MX
+#
+AC_DEFUN([LN_CONFIG_MX],
+[AC_MSG_CHECKING([whether to enable Myrinet MX support])
+# set default
+MXPATH="/opt/mx"
+AC_ARG_WITH([mx],
+ AC_HELP_STRING([--with-mx=path],
+ [build mxlnd against path]),
+ [
+ case $with_mx in
+ yes) ENABLEMX=2
+ ;;
+ no) ENABLEMX=0
+ ;;
+ *) MXPATH=$with_mx
+ ENABLEMX=3
+ ;;
+ esac
+ ],[
+ ENABLEMX=1
+ ])
+if test $ENABLEMX -eq 0; then
+ AC_MSG_RESULT([disabled])
+elif test ! \( -f ${MXPATH}/include/myriexpress.h -a \
+ -f ${MXPATH}/include/mx_kernel_api.h -a \
+ -f ${MXPATH}/include/mx_pin.h \); then
+ AC_MSG_RESULT([no])
+ case $ENABLEMX in
+ 1) ;;
+ 2) AC_MSG_ERROR([Myrinet MX kernel headers not present]);;
+ 3) AC_MSG_ERROR([bad --with-mx path]);;
+ *) AC_MSG_ERROR([internal error]);;
+ esac
+else
+ MXCPPFLAGS="-I$MXPATH/include"
+ EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
+ EXTRA_KCFLAGS="$EXTRA_KCFLAGS $MXCPPFLAGS"
+ MXLIBS="-L$MXPATH/lib"
+ LB_LINUX_TRY_COMPILE([
+ #define MX_KERNEL 1
+ #include <mx_extensions.h>
+ #include <myriexpress.h>
+ ],[
+ mx_endpoint_t end;
+ mx_status_t status;
+ mx_request_t request;
+ int result;
+
+ mx_init();
+ mx_open_endpoint(MX_ANY_NIC, MX_ANY_ENDPOINT, 0, NULL, 0, &end);
+ mx_register_unexp_handler(end, (mx_unexp_handler_t) NULL, NULL);
+ mx_wait_any(end, MX_INFINITE, 0LL, 0LL, &status, &result);
+ mx_iconnect(end, 0LL, 0, 0, 0, NULL, &request);
+ return 0;
+ ],[
+ AC_MSG_RESULT([yes])
+ MXLND="mxlnd"
+ ],[
+ AC_MSG_RESULT([no])
+ case $ENABLEMX in
+ 1) ;;
+ 2) AC_MSG_ERROR([can't compile with Myrinet MX kernel headers]);;
+ 3) AC_MSG_ERROR([can't compile with Myrinet MX headers under $MXPATH]);;
+ *) AC_MSG_ERROR([internal error]);;
+ esac
+ MXLND=""
+ MXCPPFLAGS=""
+ ])
+ EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
+fi
+AC_SUBST(MXCPPFLAGS)
+AC_SUBST(MXLIBS)
+AC_SUBST(MXLND)
+])
+
+
+
+#
+# LN_CONFIG_O2IB
+#
+AC_DEFUN([LN_CONFIG_O2IB],[
+AC_MSG_CHECKING([whether to enable OpenIB gen2 support])
+# set default
+AC_ARG_WITH([o2ib],
+ AC_HELP_STRING([--with-o2ib=path],
+ [build o2iblnd against path]),
+ [
+ case $with_o2ib in
+ yes) O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+ ENABLEO2IB=2
+ ;;
+ no) ENABLEO2IB=0
+ ;;
+ *) O2IBPATHS=$with_o2ib
+ ENABLEO2IB=3
+ ;;