Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 gretl (2017d-2) unstable; urgency=medium
 .
   * debian/control: Add 'mpi-default-dev, mpi-default-bin, pkg-config' to
     Build-Depends
   * configure: Applied upstream patch
Author: Dirk Eddelbuettel <edd@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2017-11-27

--- gretl-2017d.orig/configure
+++ gretl-2017d/configure
@@ -2856,6 +2856,7 @@ have_json_glib="no"
 try_odbc="no"
 have_odbc="no"
 try_mpi="yes"
+have_mpi="no"
 try_libR="yes"
 have_libR="no"
 try_libsvm="yes"
@@ -16202,28 +16203,11 @@ fi
 
     else
 
-ARCH=`uname -m`
-if test "${ARCH}" = "i386" -o "${ARCH}" = "i686" -o "${ARCH}" = "ppc" -o "${ARCH}" = "sparcv9" ; then
-   MODE=32
-elif test "${ARCH}" = "ia64" ; then
-   MODE=64
-elif test "${ARCH}" = "s390" ; then
-   MODE=31
-elif test "${ARCH}" = "s390x" ; then
-   MODE=64
-elif test "${ARCH}" = "x86_64" -o "${ARCH}" = "ppc64" -o "${ARCH}" = "sparc64" ; then
-   MODE=64
-fi
-
-#
-# Set up configure script macros
-#
+# mpi-lib not used, just retained for backward compatibility
 
 # Check whether --with-mpi-lib was given.
 if test "${with_mpi_lib+set}" = set; then :
-  withval=$with_mpi_lib; MPI_lib_check="$with_mpi_lib $with_mpi_lib/lib${MODE} $with_mpi_lib/lib $with_mpi_lib/lib${MODE}/openmpi $with_mpi_lib/lib/openmpi"
-else
-  MPI_lib_check="/usr/lib /usr/lib/openmpi /usr/lib64/openmpi/lib /usr/lib/openmpi/lib"
+  withval=$with_mpi_lib;
 fi
 
 
@@ -16232,86 +16216,47 @@ fi
 if test "${with_mpi_include+set}" = set; then :
   withval=$with_mpi_include; MPI_inc_check="$with_mpi_include $with_mpi_include/include $with_mpi_include/include/openmpi"
 else
-  MPI_inc_check="/usr/include /usr/include/openmpi /usr/include/openmpi-${ARCH} /usr/local/include /usr/local/include/openmpi-${ARCH} /opt/openmpi/include /usr/include/openmpi /usr/lib/openmpi/include"
+  MPI_inc_check="/usr/include /usr/local/include /usr/include/openmpi /opt/openmpi/include /usr/lib/openmpi/include"
 fi
 
 
-#
-# Look for MPI library
-#
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MPI library" >&5
-$as_echo_n "checking for MPI library... " >&6; }
-MPI_libdir=
-for m in ${MPI_lib_check} ; do
-  if test -d "$m" ; then
-    if (test -f "$m/libmpi.so" || test -f "$m/libmpi.a" || test -f "$m/libmpi.dylib"); then
-      MPI_libdir=$m
-      break
-    fi
-  fi
-done
-
-#
-# if not found, try for the MPICH library instead
-#
-if test -z "$MPI_libdir" ; then
-  for m in ${MPI_lib_check} ; do
-    if test -d "$m" ; then
-      if (test -f "$m/libmpich.so" || test -f "$m/libmpich.a" || test -f "$m/libmpich.dylib"); then
-        MPI_libdir=$m
-        break
-      fi
-    fi
-  done
+# can we find the header just using the default search paths?
+ac_fn_c_check_header_mongrel "$LINENO" "mpi.h" "ac_cv_header_mpi_h" "$ac_includes_default"
+if test "x$ac_cv_header_mpi_h" = xyes; then :
+  have_mpi="yes"
 fi
 
-if test -z "$MPI_libdir"
-then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: Couldn't find MPI library" >&5
-$as_echo "Couldn't find MPI library" >&6; }
-  have_mpi=no
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MPI_libdir" >&5
-$as_echo "$MPI_libdir" >&6; }
-  if test "$MPI_libdir" = "/usr/lib" ; then
-    MPI_LIBS="-lmpi"
-  else
-    MPI_LIBS="-L$MPI_libdir -lmpi"
-  fi
-  #
-  # Look for MPI headers
-  #
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MPI include directory" >&5
-$as_echo_n "checking for MPI include directory... " >&6; }
+
+
+# if not, try our own search
+if test $have_mpi = no ; then
+  ARCH=`uname -m`
+  ARCHPATHS="/usr/include/openmpi-${ARCH} /usr/lib/${ARCH}-linux-gnu/openmpi/include /usr/local/include/openmpi-${ARCH}"
   MPI_incdir=
-  for m in $MPI_inc_check ; do
+  for m in $MPI_inc_check $ARCHPATHS ; do
     if test -d "$m" && test -f "$m/mpi.h" ; then
       MPI_incdir=$m
       break
     fi
   done
-
   if test -z "$MPI_incdir" ; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: couldn't find mpi.h" >&5
 $as_echo "couldn't find mpi.h" >&6; }
-    have_mpi=no
   else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MPI_incdir" >&5
-$as_echo "$MPI_incdir" >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: found mpi.h in $MPI_incdir" >&5
+$as_echo "found mpi.h in $MPI_incdir" >&6; }
     have_mpi=yes
-    $as_echo "#define HAVE_MPI 1" >>confdefs.h
-
-    if test "$MPI_incdir" = "/usr/include" ; then
-      MPI_CFLAGS=""
-    else
+    if test "$MPI_incdir" != "/usr/include" ; then
       MPI_CFLAGS="-I${MPI_incdir}"
     fi
-    if test x"${MPICC}" = x ; then
-      MPICC=mpicc
-    fi
-
+  fi
+fi
 
+if test $have_mpi = yes ; then
+  $as_echo "#define HAVE_MPI 1" >>confdefs.h
 
+  if test x"${MPICC}" = x ; then
+    MPICC=mpicc
   fi
 fi
 
