From: Julian Seward Date: Thu, 2 Mar 2006 13:48:21 +0000 (+0000) Subject: Build system hacks to build and install the MPI wrappers library when X-Git-Tag: svn/VALGRIND_3_2_0~240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1d729480cda486f24ecddc2bd3a8769417374f4;p=thirdparty%2Fvalgrind.git Build system hacks to build and install the MPI wrappers library when a suitable mpi.h is found at configure time. This also adds the configure flag --with-mpi=/path/to/mpi/install so that libmpiwrap.so can be built against any given MPI installation. libmpiwrap.so is built and installed for the primary target only. As usual this all involves various unsavoury build-system hacks. Fortunately they are all in auxprogs/Makefile.am and configure.in don't interact with any of our existing build-system hacks :-) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5707 --- diff --git a/auxprogs/Makefile.am b/auxprogs/Makefile.am index 119cd8036c..5f637f498a 100644 --- a/auxprogs/Makefile.am +++ b/auxprogs/Makefile.am @@ -23,3 +23,27 @@ valgrind_listener_LDFLAGS = $(AM_CFLAGS_PRI) #---------------------------------------------------------- +#------------------------- 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 +# +#---------------------------------------------------------- + diff --git a/auxprogs/mpiwrap.c b/auxprogs/mpiwrap.c index dbb68e645a..0d1d0f2143 100644 --- a/auxprogs/mpiwrap.c +++ b/auxprogs/mpiwrap.c @@ -75,7 +75,6 @@ #include /* pthread_mutex_{lock,unlock} */ /* Include Valgrind magic macros for writing wrappers. */ -#include "../include/valgrind.h" #include "../memcheck/memcheck.h" @@ -84,7 +83,8 @@ /*------------------------------------------------------------*/ /* 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? diff --git a/configure.in b/configure.in index a9b466d5b6..c2c6ea6693 100644 --- a/configure.in +++ b/configure.in @@ -596,6 +596,39 @@ AC_TYPE_SIGNAL 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 @@ -652,7 +685,7 @@ AC_OUTPUT( cat<