Description: Try to find mpich with pkg-config if pkg-config did not find openmpi
Author: Adrian Bunk <bunk@debian.org>

--- rmpi-0.7-2.orig/configure.ac
+++ rmpi-0.7-2/configure.ac
@@ -96,6 +96,11 @@ if test -z "$MPI_ROOT" ; then
 fi
 
 if test -z "$MPI_ROOT" ; then
+	#Use pkg-config to find mpich
+	PKG_CHECK_MODULES([MPICH],[mpich],[MPITYPE="MPICH" MPI_ROOT="NONEED"],[:])
+fi
+
+if test -z "$MPI_ROOT" ; then
   for d in /opt/lib /usr/lib /usr /usr/lib/x86_64-linux-gnu/openmpi \
           /usr/local/lib /usr/local /usr/lib64/mpi/gcc/openmpi; do
     if test -f $d/include/mpi.h && test -d $d/lib/openmpi; then
@@ -303,7 +308,12 @@ case "$MPITYPE" in
     PKG_LIBS="-L${MPI_LIBPATH} -lmpi -llam ${MPI_LIBS}"
     ;;
   MPICH)
-    PKG_LIBS="-L${MPI_LIBPATH} -lmpich -lmpl -lopa ${MPI_LIBS}"
+    if test "$MPI_ROOT" = "NONEED"; then
+		PKG_CPPFLAGS="${MPICH_CFLAGS}"
+		PKG_LIBS="${MPICH_LIBS}"
+    else
+		PKG_LIBS="-L${MPI_LIBPATH} -lmpich -lmpl -lopa ${MPI_LIBS}"
+    fi
     ;;
   MPICH2)
     PKG_LIBS="-L${MPI_LIBPATH} -lmpich -lmpl -lopa ${MPI_LIBS}"
