#----------------------------------------------------------
+#------------------------- mpi wrappers -----------------------
+# Build libmpiwrap.so for the primary target only.
+# 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.
+#
+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
+
+install-exec-local:
+# convert (eg) X86_LINUX to x86-linux
+# really should use sed here, rather than assume tr is available
+ pD=`echo @VG_PLATFORM_PRI@ | tr A-Z_ a-z-` ; \
+ $(mkinstalldirs) $(DESTDIR)$(valdir)/$$pD; \
+ $(INSTALL_PROGRAM) ./libmpiwrap.so $(DESTDIR)$(valdir)/$$pD
+endif
+#
+#----------------------------------------------------------
+
#include <pthread.h> /* pthread_mutex_{lock,unlock} */
/* Include Valgrind magic macros for writing wrappers. */
-#include "../include/valgrind.h"
#include "../memcheck/memcheck.h"
/*------------------------------------------------------------*/
/* Include headers for whatever MPI implementation the wrappers are to
- be used with. */
+ be used with. The configure system will tell us what the path to
+ the chosen MPI implementation is, via -I.. to the compiler. */
#include "mpi.h"
/* Where are API symbols?
AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr semtimedop])
+
+# First consider --with-mpi=..., then check for mpi.h
+MPI_PREFIX="/usr"
+AC_ARG_WITH(mpi,
+ [ --with-mpi=/path/to/mpi/install Specify location of MPI],
+ MPI_PREFIX=$withval
+)
+
+AC_MSG_CHECKING([for $MPI_PREFIX/include/mpi.h])
+
+AC_TRY_COMPILE(, [
+#include "$MPI_PREFIX/include/mpi.h"
+int main ( int argc, char** argv )
+ { int r = MPI_Init(&argc,&argv); return 0 ; }
+],
+[
+ac_have_mpi_h=yes
+AC_MSG_RESULT([yes])
+], [
+ac_have_mpi_h=no
+AC_MSG_RESULT([no])
+])
+
+#if test x$ac_have_mpi_h = xyes ; then
+# AC_DEFINE(HAVE_MPI_H, 1, [Define to 1 if mpi.h is available.])
+#fi
+
+AM_CONDITIONAL(BUILD_MPIWRAP, test x$ac_have_mpi_h = xyes)
+AC_SUBST(MPI_PREFIX)
+
+
+# -------------------- ok. We're done. --------------------
+
AC_OUTPUT(
Makefile
valgrind.spec
cat<<EOF
Primary build target: ${VG_PLATFORM_PRI}
- Secondary target: ${VG_PLATFORM_SEC}
+ Secondary build target: ${VG_PLATFORM_SEC}
Default supp files: ${DEFAULT_SUPP}
EOF