From 0dc452445af65ea5840389623d0bfc2d79846fdf Mon Sep 17 00:00:00 2001
From: Thimo Neubauer <thimo@dune-project.org>
Date: Tue, 26 Oct 2004 12:33:16 +0000
Subject: [PATCH] new LAM-release 7.1 features a new mpiCC which knows -show
 like the MPICH-one does. This broke the identification...

On the other hand the new mpiCC offers parameters to extract the flags
without passing dummy-names which is used if LAM >= 7.1 is found

[[Imported from SVN: r990]]
---
 m4/dune_mpi.m4 | 59 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 37 insertions(+), 22 deletions(-)

diff --git a/m4/dune_mpi.m4 b/m4/dune_mpi.m4
index 959050ec4..9a3282ce3 100644
--- a/m4/dune_mpi.m4
+++ b/m4/dune_mpi.m4
@@ -53,10 +53,13 @@ AC_DEFUN([DUNE_MPI],[
 
 # somehow variables like $1, $2 seem to disappear after m4... Quote them...
 dune_mpi_getflags () {
-    # call mpiCC, remove compiler name
+    # -- call mpiCC, remove compiler name
+    # compiler-name is first word in line _if_ it doesn't start with a dash!
+    # needed because mpiCC sometimes does not include compiler (newer LAM)
+
     # the additional brackets keep m4 from interpreting the brackets
     # in the sed-command...
-    retval=[`$MPICOMP ${1} ${2} 2>/dev/null | sed -e 's/^[^ ]\+ //'`]
+    retval=[`$MPICOMP ${1} ${2} 2>/dev/null | sed -e 's/^[^-][^ ]\+ //'`]
     # remove dummy-parameter (if existing)
     if test ${#} = 2 ; then
       retval=`echo $retval | sed -e "s/${2}//"`
@@ -77,38 +80,50 @@ dune_mpi_getflags () {
     with_mpi="no"
 
     AC_MSG_CHECKING([MPI-package])
-    # the MPICH mpiCC knows a -show parameter
-    dune_mpi_getflags "-show"
+    # the LAM mpiCC knows a -showme parameter
+    dune_mpi_getflags "-showme"
     if test x"$retval" != x ; then
-      with_mpi="MPICH"
+      with_mpi="LAM"
 
-      # use special commands to extract options      
+      # try new -showme:xxx function
+      dune_mpi_getflags "-showme:compile"
+      if test x"$retval" != x ; then
+        # seems like LAM >= 7.1 which supports extraction of parameters without
+        # dummy files
+        AC_MSG_RESULT([LAM >= 7.1])
+        MPI_CPPFLAGS="$retval"
 
-      dune_mpi_getflags "-compile_info"
-      MPI_CPPFLAGS="$retval"
-      # hack in option to disable MPICH-C++-bindings...
-      AC_LANG_CASE([C++], [MPI_CPPFLAGS="$MPI_CPPFLAGS -DMPICH_SKIP_MPICXX"])
+        dune_mpi_getflags "-showme:link"
+        MPI_LDFLAGS="$retval"
+      else
+        AC_MSG_RESULT([LAM <= 7.0])
+        # use -showme and dummy parameters to extract flags        
+        AC_LANG_CASE([C], [MPISOURCE="dummy.c"],
+	  [C++], [MPISOURCE="dummy.cc"])
 
-      dune_mpi_getflags "-link_info"
-      MPI_LDFLAGS="$retval"
+        dune_mpi_getflags "-showme" "-c $MPISOURCE"
+        MPI_CPPFLAGS="$retval"
 
-      AC_MSG_RESULT([MPICH])
+        dune_mpi_getflags "-showme" "dummy.o -o dummy"
+        MPI_LDFLAGS="$retval"
+      fi
     else
-      # the LAM mpiCC knows a -showme parameter
-      dune_mpi_getflags "-showme"
+      # the MPICH mpiCC knows a -show parameter
+      dune_mpi_getflags "-show"
       if test x"$retval" != x ; then
-        AC_MSG_RESULT([LAM])
-        with_mpi="LAM"
+        with_mpi="MPICH"
 
-        # use -showme and dummy parameters to extract flags        
-	AC_LANG_CASE([C], [MPISOURCE="dummy.c"],
-	[C++], [MPISOURCE="dummy.cc"])
+        # use special commands to extract options      
 
-        dune_mpi_getflags "-showme" "-c $MPISOURCE"
+        dune_mpi_getflags "-compile_info"
         MPI_CPPFLAGS="$retval"
+        # hack in option to disable MPICH-C++-bindings...
+        AC_LANG_CASE([C++], [MPI_CPPFLAGS="$MPI_CPPFLAGS -DMPICH_SKIP_MPICXX"])
 
-        dune_mpi_getflags "-showme" "dummy.o -o dummy"
+        dune_mpi_getflags "-link_info"
         MPI_LDFLAGS="$retval"
+
+        AC_MSG_RESULT([MPICH])
       else
         # neither MPICH nor LAM....
         AC_MSG_RESULT([unknown])
-- 
GitLab