Commit fe8152ef authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Enable manual definition of MAGMA folder

parent 0940559a
Loading
Loading
Loading
Loading
+153 −57
Original line number Original line Diff line number Diff line
@@ -24832,12 +24832,12 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# Environment setup
# Environment setup
    if test "x$HDF5_INCLUDE$HDF5_LIB" = "x"; then
    if test "x${HDF5_INCLUDE}${HDF5_LIB}" = "x"; then
      pkg-config --version > /dev/null
      pkg-config --version > /dev/null
      use_pkg_config=$?
      use_pkg_config=$?
      if test "x$use_pkg_config" = "x0"; then
      if test "x$use_pkg_config" = "x0"; then
        declare -a pkg_array=$(pkg-config --list-all | grep hdf5-serial)
        declare -a pkg_array=$(pkg-config --list-all | grep hdf5-serial)
        for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5-serial
        for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5-serial > /dev/null
        result=$?
        result=$?
        if test "x$result" = "x0"; then
        if test "x$result" = "x0"; then
          cflags=$(pkg-config --cflags-only-I hdf5-serial)
          cflags=$(pkg-config --cflags-only-I hdf5-serial)
@@ -24846,7 +24846,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
          export HDF5_LIB=$(echo "${ldflags:2}")
          export HDF5_LIB=$(echo "${ldflags:2}")
        else
        else
          declare -a pkg_array=$(pkg-config --list-all | grep hdf5)
          declare -a pkg_array=$(pkg-config --list-all | grep hdf5)
          for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5
          for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5 > /dev/null
          result=$?
          result=$?
          if test "x$result" = "x0"; then
          if test "x$result" = "x0"; then
            cflags=$(pkg-config --cflags-only-I hdf5)
            cflags=$(pkg-config --cflags-only-I hdf5)
@@ -25186,7 +25186,7 @@ then :
    if test "x$use_pkg_config" = "x0"; then
    if test "x$use_pkg_config" = "x0"; then
      # pkg-config is available
      # pkg-config is available
      declare -a pkg_array=$(pkg-config --list-all | grep ${MKL_BUILD})
      declare -a pkg_array=$(pkg-config --list-all | grep ${MKL_BUILD})
      for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD}
      for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD} > /dev/null
      result=$?
      result=$?
      if test "x$result" = "x0"; then
      if test "x$result" = "x0"; then
        # MKL was found
        # MKL was found
@@ -25196,7 +25196,7 @@ then :
      else
      else
        # MKL was not found, so configuration searches for LAPACKe
        # MKL was not found, so configuration searches for LAPACKe
        declare -a pkg_array=$(pkg-config --list-all | grep lapacke${LAPACK_LDSPEC})
        declare -a pkg_array=$(pkg-config --list-all | grep lapacke${LAPACK_LDSPEC})
        for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC}
        for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC} > /dev/null
        result=$?
        result=$?
        if test "x$result" = "x0"; then
        if test "x$result" = "x0"; then
          # LAPACKe was found
          # LAPACKe was found
@@ -25207,7 +25207,7 @@ then :
        if test "x${LAPACKFLAGS}${LAPACKLDFLAGS}" = "x"; then
        if test "x${LAPACKFLAGS}${LAPACKLDFLAGS}" = "x"; then
          # LAPACKe was not found, so configuration searches for LAPACK
          # LAPACKe was not found, so configuration searches for LAPACK
          declare -a pkg_array=$(pkg-config --list-all | grep lapack${LAPACK_LDSPEC})
          declare -a pkg_array=$(pkg-config --list-all | grep lapack${LAPACK_LDSPEC})
          for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC}
          for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC} > /dev/null
          result=$?
          result=$?
          if test "x$result" = "x0"; then
          if test "x$result" = "x0"; then
            # LAPACK was found
            # LAPACK was found
@@ -25270,7 +25270,7 @@ else case e in #(
    if test "x$use_pkg_config" = "x0"; then
    if test "x$use_pkg_config" = "x0"; then
      # pkg-config is available
      # pkg-config is available
      declare -a pkg_array=$(pkg-config --list-all | grep ${MKL_BUILD})
      declare -a pkg_array=$(pkg-config --list-all | grep ${MKL_BUILD})
      for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD}
      for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD} > /dev/null
      result=$?
      result=$?
      if test "x$result" = "x0"; then
      if test "x$result" = "x0"; then
        # MKL was found
        # MKL was found
@@ -25280,7 +25280,7 @@ else case e in #(
      else
      else
        # MKL was not found, so configuration searches for LAPACKe
        # MKL was not found, so configuration searches for LAPACKe
        declare -a pkg_array=$(pkg-config --list-all | grep lapacke${LAPACK_LDSPEC})
        declare -a pkg_array=$(pkg-config --list-all | grep lapacke${LAPACK_LDSPEC})
        for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC}
        for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC} > /dev/null
        result=$?
        result=$?
        if test "x$result" = "x0"; then
        if test "x$result" = "x0"; then
          # LAPACKe was found
          # LAPACKe was found
@@ -25291,7 +25291,7 @@ else case e in #(
        if test "x${LAPACKFLAGS}${LAPACKLDFLAGS}" = "x"; then
        if test "x${LAPACKFLAGS}${LAPACKLDFLAGS}" = "x"; then
          # LAPACKe was not found, so configuration searches for LAPACK
          # LAPACKe was not found, so configuration searches for LAPACK
          declare -a pkg_array=$(pkg-config --list-all | grep lapack${LAPACK_LDSPEC})
          declare -a pkg_array=$(pkg-config --list-all | grep lapack${LAPACK_LDSPEC})
          for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC}
          for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC} > /dev/null
          result=$?
          result=$?
          if test "x$result" = "x0"; then
          if test "x$result" = "x0"; then
            # LAPACK was found
            # LAPACK was found
@@ -25348,10 +25348,36 @@ then :
      MAGMALDFLAGS=""
      MAGMALDFLAGS=""
    else
    else
      if test "x$withval" != "xyes" and "x$withval" != "xauto"; then
      if test "x$withval" != "xyes"; then
        if test "x$withval" != "xauto"; then
          export MAGMA_HOME=$withval
          export MAGMA_HOME=$withval
	fi
	fi
      fi
    if test "x$ENABLE_ILP64" = "xyes"; then
      # 64-bit indices are enabled
      MAGMA_ILP64_FLAG="-DMAGMA_ILP64"
      MAGMA_LD_SPEC="64"
    else
      # 64-bit indices are disabled
      MAGMA_ILP64_FLAG=""
      MAGMA_LD_SPEC=""
    fi # end of 64-bit decision tree
    pkg-config --version > /dev/null
    use_pkg_config=$?
    if test "x$use_pkg_config" = "x0"; then
      # pkg-config is available
      declare -a pkg_array=$(pkg-config --list-all | grep cudart)
      for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart > /dev/null
      result=$?
      if test "x$result" = "x0"; then
        # CUDA runtime detected
        cuda_pkg=$(for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart)
	CUDAFLAGS=$(pkg-config --cflags ${cuda_pkg})
	CUDALDFLAGS=$(pkg-config --libs ${cuda_pkg})
      fi # end of CUDA runtime decision tree
    else
      # pkg-config is not available
      if test -f /usr/local/cuda/include/cuda.h; then
      if test -f /usr/local/cuda/include/cuda.h; then
        CUDAFLAGS="-I/usr/local/cuda/include"
        CUDAFLAGS="-I/usr/local/cuda/include"
        CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart"
        CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart"
@@ -25362,21 +25388,44 @@ then :
        CUDAFLAGS="-I${CUDA_HOME}/include"
        CUDAFLAGS="-I${CUDA_HOME}/include"
        CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart"
        CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart"
      fi
      fi
    fi # end of pkg-config decision tree
    if test "x${MAGMA_ROOT}${MAGMA_HOME}${MAGMA_DIR}" = "x"; then
      # MAGMA environment is not defined
      if "x$use_pkg_config" = "x0"; then
        # use pkg-config to search for MAGMA
        declare -a pkg_array=$(pkg-config --list-all | grep magma)
        for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma > /dev/null
        result=$?
	if test "x$result" = "x0"; then
	  # MAGMA was found
	  magma_pkg=$(for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma)
	  MAGMA_INCLUDE=$(pkg-config --cflags-only-I ${magma_pkg})
	  MAGMA_LIBS_DIR=$(pkg-config --cflags-only-L ${magma_pkg})
          export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS ${MAGMA_INCLUDE}"
          export MAGMALDFLAGS="$CUDALDFLAGS ${MAGMA_LIBS_DIR} -lmagma"
	fi # end of MAGMA decision tree
      else
        # search for MAGMA in some standard folders
        if test "x$CUDAFLAGS" != "x"; then
        if test "x$CUDAFLAGS" != "x"; then
          if test -f /usr/include/magma_v2.h; then
          if test -f /usr/include/magma_v2.h; then
        export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/include"
            export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/include"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
          elif test -f /usr/local/include/magma_v2.h; then
          elif test -f /usr/local/include/magma_v2.h; then
        export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/local/include"
            export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/local/include"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
      elif test "x$MAGMA_HOME" != "x"; then
          fi
        export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_HOME}/include"
        fi
        export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_HOME}/lib -lmagma"
      fi # end of pkg-config decision tree
      elif test "x$MAGMA_ROOT" != "x"; then
    else
      # MAGMA environment is defined, so configuration makes sure that MAGMA_ROOT is defined too
      if test "x${MAGMA_HOME}" != "x"; then
        MAGMA_ROOT="${MAGMA_HOME}"
      elif test "x${MAGMA_DIR}" != "x"; then
        MAGMA_ROOT="${MAGMA_DIR}"
      fi
      export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include"
      export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include"
      export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma"
      export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma"
    fi
    fi
    fi
      if test "x$MAGMALDFLAGS" != "x"
      if test "x$MAGMALDFLAGS" != "x"
@@ -25398,6 +25447,30 @@ fi
else case e in #(
else case e in #(
  e)
  e)
    if test "x$ENABLE_ILP64" = "xyes"; then
      # 64-bit indices are enabled
      MAGMA_ILP64_FLAG="-DMAGMA_ILP64"
      MAGMA_LD_SPEC="64"
    else
      # 64-bit indices are disabled
      MAGMA_ILP64_FLAG=""
      MAGMA_LD_SPEC=""
    fi # end of 64-bit decision tree
    pkg-config --version > /dev/null
    use_pkg_config=$?
    if test "x$use_pkg_config" = "x0"; then
      # pkg-config is available
      declare -a pkg_array=$(pkg-config --list-all | grep cudart)
      for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart > /dev/null
      result=$?
      if test "x$result" = "x0"; then
        # CUDA runtime detected
        cuda_pkg=$(for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart)
	CUDAFLAGS=$(pkg-config --cflags ${cuda_pkg})
	CUDALDFLAGS=$(pkg-config --libs ${cuda_pkg})
      fi # end of CUDA runtime decision tree
    else
      # pkg-config is not available
      if test -f /usr/local/cuda/include/cuda.h; then
      if test -f /usr/local/cuda/include/cuda.h; then
        CUDAFLAGS="-I/usr/local/cuda/include"
        CUDAFLAGS="-I/usr/local/cuda/include"
        CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart"
        CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart"
@@ -25408,21 +25481,44 @@ else case e in #(
        CUDAFLAGS="-I${CUDA_HOME}/include"
        CUDAFLAGS="-I${CUDA_HOME}/include"
        CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart"
        CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart"
      fi
      fi
    fi # end of pkg-config decision tree
    if test "x${MAGMA_ROOT}${MAGMA_HOME}${MAGMA_DIR}" = "x"; then
      # MAGMA environment is not defined
      if "x$use_pkg_config" = "x0"; then
        # use pkg-config to search for MAGMA
        declare -a pkg_array=$(pkg-config --list-all | grep magma)
        for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma > /dev/null
        result=$?
	if test "x$result" = "x0"; then
	  # MAGMA was found
	  magma_pkg=$(for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma)
	  MAGMA_INCLUDE=$(pkg-config --cflags-only-I ${magma_pkg})
	  MAGMA_LIBS_DIR=$(pkg-config --cflags-only-L ${magma_pkg})
          export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS ${MAGMA_INCLUDE}"
          export MAGMALDFLAGS="$CUDALDFLAGS ${MAGMA_LIBS_DIR} -lmagma"
	fi # end of MAGMA decision tree
      else
        # search for MAGMA in some standard folders
        if test "x$CUDAFLAGS" != "x"; then
        if test "x$CUDAFLAGS" != "x"; then
          if test -f /usr/include/magma_v2.h; then
          if test -f /usr/include/magma_v2.h; then
        export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/include"
            export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/include"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
          elif test -f /usr/local/include/magma_v2.h; then
          elif test -f /usr/local/include/magma_v2.h; then
        export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/local/include"
            export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/local/include"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
      elif test "x$MAGMA_HOME" != "x"; then
          fi
        export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_HOME}/include"
        fi
        export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_HOME}/lib -lmagma"
      fi # end of pkg-config decision tree
      elif test "x$MAGMA_ROOT" != "x"; then
    else
      # MAGMA environment is defined, so configuration makes sure that MAGMA_ROOT is defined too
      if test "x${MAGMA_HOME}" != "x"; then
        MAGMA_ROOT="${MAGMA_HOME}"
      elif test "x${MAGMA_DIR}" != "x"; then
        MAGMA_ROOT="${MAGMA_DIR}"
      fi
      export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include"
      export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include"
      export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma"
      export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma"
    fi
    fi
    fi
    if test "x$MAGMALDFLAGS" != "x"
    if test "x$MAGMALDFLAGS" != "x"
+80 −31
Original line number Original line Diff line number Diff line
@@ -2,12 +2,12 @@
m4_define(
m4_define(
  [M4_DETECT_HDF5],
  [M4_DETECT_HDF5],
  [
  [
    if test "x$HDF5_INCLUDE$HDF5_LIB" = "x"; then
    if test "x${HDF5_INCLUDE}${HDF5_LIB}" = "x"; then
      pkg-config --version > /dev/null
      pkg-config --version > /dev/null
      use_pkg_config=$?
      use_pkg_config=$?
      if test "x$use_pkg_config" = "x0"; then
      if test "x$use_pkg_config" = "x0"; then
        declare -a pkg_array=$(pkg-config --list-all | grep hdf5-serial)
        declare -a pkg_array=$(pkg-config --list-all | grep hdf5-serial)
        for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5-serial
        for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5-serial > /dev/null
        result=$?
        result=$?
        if test "x$result" = "x0"; then
        if test "x$result" = "x0"; then
          cflags=$(pkg-config --cflags-only-I hdf5-serial)
          cflags=$(pkg-config --cflags-only-I hdf5-serial)
@@ -16,7 +16,7 @@ m4_define(
          export HDF5_LIB=$(echo "${ldflags:2}")
          export HDF5_LIB=$(echo "${ldflags:2}")
        else
        else
          declare -a pkg_array=$(pkg-config --list-all | grep hdf5)
          declare -a pkg_array=$(pkg-config --list-all | grep hdf5)
          for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5
          for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5 > /dev/null
          result=$?
          result=$?
          if test "x$result" = "x0"; then
          if test "x$result" = "x0"; then
            cflags=$(pkg-config --cflags-only-I hdf5)
            cflags=$(pkg-config --cflags-only-I hdf5)
@@ -98,7 +98,7 @@ m4_define(
    if test "x$use_pkg_config" = "x0"; then
    if test "x$use_pkg_config" = "x0"; then
      # pkg-config is available
      # pkg-config is available
      declare -a pkg_array=$(pkg-config --list-all | grep ${MKL_BUILD})
      declare -a pkg_array=$(pkg-config --list-all | grep ${MKL_BUILD})
      for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD}
      for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD} > /dev/null
      result=$?
      result=$?
      if test "x$result" = "x0"; then
      if test "x$result" = "x0"; then
        # MKL was found
        # MKL was found
@@ -108,7 +108,7 @@ m4_define(
      else
      else
        # MKL was not found, so configuration searches for LAPACKe
        # MKL was not found, so configuration searches for LAPACKe
        declare -a pkg_array=$(pkg-config --list-all | grep lapacke${LAPACK_LDSPEC})
        declare -a pkg_array=$(pkg-config --list-all | grep lapacke${LAPACK_LDSPEC})
        for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC}
        for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC} > /dev/null
        result=$?
        result=$?
        if test "x$result" = "x0"; then
        if test "x$result" = "x0"; then
          # LAPACKe was found
          # LAPACKe was found
@@ -119,7 +119,7 @@ m4_define(
        if test "x${LAPACKFLAGS}${LAPACKLDFLAGS}" = "x"; then
        if test "x${LAPACKFLAGS}${LAPACKLDFLAGS}" = "x"; then
          # LAPACKe was not found, so configuration searches for LAPACK
          # LAPACKe was not found, so configuration searches for LAPACK
          declare -a pkg_array=$(pkg-config --list-all | grep lapack${LAPACK_LDSPEC})
          declare -a pkg_array=$(pkg-config --list-all | grep lapack${LAPACK_LDSPEC})
          for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC}
          for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC} > /dev/null
          result=$?
          result=$?
          if test "x$result" = "x0"; then
          if test "x$result" = "x0"; then
            # LAPACK was found
            # LAPACK was found
@@ -149,6 +149,30 @@ m4_define(
m4_define(
m4_define(
  [M4_DETECT_MAGMA],
  [M4_DETECT_MAGMA],
  [
  [
    if test "x$ENABLE_ILP64" = "xyes"; then
      # 64-bit indices are enabled
      MAGMA_ILP64_FLAG="-DMAGMA_ILP64"
      MAGMA_LD_SPEC="64"
    else
      # 64-bit indices are disabled
      MAGMA_ILP64_FLAG=""
      MAGMA_LD_SPEC=""
    fi # end of 64-bit decision tree
    pkg-config --version > /dev/null
    use_pkg_config=$?
    if test "x$use_pkg_config" = "x0"; then
      # pkg-config is available
      declare -a pkg_array=$(pkg-config --list-all | grep cudart)
      for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart > /dev/null
      result=$?
      if test "x$result" = "x0"; then
        # CUDA runtime detected
        cuda_pkg=$(for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart)
	CUDAFLAGS=$(pkg-config --cflags ${cuda_pkg})
	CUDALDFLAGS=$(pkg-config --libs ${cuda_pkg})
      fi # end of CUDA runtime decision tree
    else
      # pkg-config is not available
      if test -f /usr/local/cuda/include/cuda.h; then
      if test -f /usr/local/cuda/include/cuda.h; then
        CUDAFLAGS="-I/usr/local/cuda/include"
        CUDAFLAGS="-I/usr/local/cuda/include"
        CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart"
        CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart"
@@ -159,21 +183,44 @@ m4_define(
        CUDAFLAGS="-I${CUDA_HOME}/include"
        CUDAFLAGS="-I${CUDA_HOME}/include"
        CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart"
        CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart"
      fi
      fi
    fi # end of pkg-config decision tree
    if test "x${MAGMA_ROOT}${MAGMA_HOME}${MAGMA_DIR}" = "x"; then
      # MAGMA environment is not defined
      if "x$use_pkg_config" = "x0"; then
        # use pkg-config to search for MAGMA
        declare -a pkg_array=$(pkg-config --list-all | grep magma)
        for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma > /dev/null
        result=$?
	if test "x$result" = "x0"; then
	  # MAGMA was found
	  magma_pkg=$(for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma)
	  MAGMA_INCLUDE=$(pkg-config --cflags-only-I ${magma_pkg})
	  MAGMA_LIBS_DIR=$(pkg-config --cflags-only-L ${magma_pkg})
          export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS ${MAGMA_INCLUDE}"
          export MAGMALDFLAGS="$CUDALDFLAGS ${MAGMA_LIBS_DIR} -lmagma"
	fi # end of MAGMA decision tree
      else
        # search for MAGMA in some standard folders
        if test "x$CUDAFLAGS" != "x"; then
        if test "x$CUDAFLAGS" != "x"; then
          if test -f /usr/include/magma_v2.h; then
          if test -f /usr/include/magma_v2.h; then
        export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/include"
            export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/include"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
          elif test -f /usr/local/include/magma_v2.h; then
          elif test -f /usr/local/include/magma_v2.h; then
        export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/local/include"
            export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/local/include"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
            export MAGMALDFLAGS="$CUDALDFLAGS -lmagma"
      elif test "x$MAGMA_HOME" != "x"; then
          fi
        export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_HOME}/include"
        fi
        export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_HOME}/lib -lmagma"
      fi # end of pkg-config decision tree
      elif test "x$MAGMA_ROOT" != "x"; then
    else
      # MAGMA environment is defined, so configuration makes sure that MAGMA_ROOT is defined too
      if test "x${MAGMA_HOME}" != "x"; then
        MAGMA_ROOT="${MAGMA_HOME}"
      elif test "x${MAGMA_DIR}" != "x"; then
        MAGMA_ROOT="${MAGMA_DIR}"
      fi
      export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include"
      export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include"
      export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma"
      export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma"
    fi
    fi
    fi
  ]
  ]
)
)


@@ -501,9 +548,11 @@ AC_ARG_WITH(
      AC_SUBST([MAGMAFLAGS], [""])
      AC_SUBST([MAGMAFLAGS], [""])
      AC_SUBST([MAGMALDFLAGS], [""])
      AC_SUBST([MAGMALDFLAGS], [""])
    else
    else
      if test "x$withval" != "xyes" and "x$withval" != "xauto"; then
      if test "x$withval" != "xyes"; then
        if test "x$withval" != "xauto"; then
          export MAGMA_HOME=$withval
          export MAGMA_HOME=$withval
	fi
	fi
      fi
      M4_DETECT_MAGMA
      M4_DETECT_MAGMA
      AS_IF(
      AS_IF(
        [test "x$MAGMALDFLAGS" != "x"],
        [test "x$MAGMALDFLAGS" != "x"],