#------------------------- mpi wrappers -----------------------
# Build libmpiwrap.so for the primary target only.
+#
+# This is really horrible.
+#
# Don't let automake install this, since it puts it in the
# wrong place. Instead install it ourselves in the right
# place using the install-exec-local target below.
#
+# Also, automake isn't good at supporting non-$(CC) compilers.
+# But we need to use $(MPI_CC) here. Hence the nasty hack of
+# directly saying how to build libmpiwrap.so, instead of
+# using automake's standard gunk.
+#
if BUILD_MPIWRAP
noinst_PROGRAMS = libmpiwrap.so
-libmpiwrap_so_SOURCES = mpiwrap.c
-libmpiwrap_so_CFLAGS = $(AM_FLAG_M3264_PRI) \
- -g -O -fpic -fno-omit-frame-pointer \
- -I../include -I@MPI_PREFIX@/include
-libmpiwrap_so_LDFLAGS = $(AM_FLAG_M3264_PRI) -g -shared
+#libmpiwrap_so_SOURCES = mpiwrap.c
+#libmpiwrap_so_CFLAGS = $(AM_FLAG_M3264_PRI) \
+# -g -O -fpic -fno-omit-frame-pointer \
+# -I../include -I@MPI_PREFIX@/include
+#libmpiwrap_so_LDFLAGS = $(AM_FLAG_M3264_PRI) -g -shared
+libmpiwrap.so: mpiwrap.c
+ $(MPI_CC) -g -O -fno-omit-frame-pointer -fpic -shared \
+ -I../include -I@MPI_PREFIX@/include \
+ $(AM_FLAG_M3264_PRI) \
+ -o libmpiwrap.so mpiwrap.c
install-exec-local:
# convert (eg) X86_LINUX to x86-linux
AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr semtimedop])
+# Do we have a useable mpicc (MPI-ised C compiler) ?
+MPI_CC="mpicc"
+AC_ARG_WITH(mpicc,
+ [ --with-mpicc= Specify name of MPI-ised C compiler],
+ MPI_CC=$withval
+)
+AC_MSG_CHECKING([for usable mpicc])
+saved_CC=$CC
+CC=$MPI_CC
+AC_TRY_COMPILE(, [
+int main ( ) { return 0; }
+],
+[
+ac_have_mpicc=yes
+AC_MSG_RESULT([$MPI_CC])
+], [
+ac_have_mpicc=no
+AC_MSG_RESULT([no])
+])
+CC=$saved_CC
+
+
# First consider --with-mpi=..., then check for mpi.h
+saved_CC=$CC
+CC=$MPI_CC
MPI_PREFIX="/usr"
AC_ARG_WITH(mpi,
[ --with-mpi=/path/to/mpi/install Specify location of MPI],
ac_have_mpi_h=no
AC_MSG_RESULT([no])
])
+CC=$saved_CC
#if test x$ac_have_mpi_h = xyes ; then
# AC_DEFINE(HAVE_MPI_H, 1, [Define to 1 if mpi.h is available.])
AM_CONDITIONAL(BUILD_MPIWRAP, test x$ac_have_mpi_h = xyes)
AC_SUBST(MPI_PREFIX)
+AC_SUBST(MPI_CC)
# -------------------- ok. We're done. --------------------