Index: issm/trunk-jpl/m4/issm_options.m4
===================================================================
--- issm/trunk-jpl/m4/issm_options.m4	(revision 26034)
+++ issm/trunk-jpl/m4/issm_options.m4	(revision 26036)
@@ -31,5 +31,5 @@
 		PACKAGE_DATE="unknown"
 	fi
-	AC_DEFINE_UNQUOTED([PACKAGE_BUILD_DATE], "${PACKAGE_DATE}", [build date])
+	AC_DEFINE_UNQUOTED(PACKAGE_BUILD_DATE, "$PACKAGE_DATE", [build date])
 	AC_MSG_RESULT([${PACKAGE_DATE}])
 
@@ -46,5 +46,5 @@
 		fi
 	fi
-	AC_DEFINE_UNQUOTED([USER_NAME], "${user_name}", [user name])
+	AC_DEFINE_UNQUOTED(USER_NAME, "$user_name", [user name])
 	AC_MSG_RESULT([${user_name}])
 
@@ -55,13 +55,13 @@
 		linux-gnu* | lignux* )	host_os=linux ;;
 	esac
-	AC_DEFINE_UNQUOTED([HOST_OS], "${host_os}", [host full OS name and version])
+	AC_DEFINE_UNQUOTED(HOST_OS, "$host_os", [host full OS name and version])
 	AC_MSG_RESULT([${host_os}])
 
 	AC_MSG_CHECKING([host cpu])
-	AC_DEFINE_UNQUOTED([HOST_CPU], "${host_cpu}", [host CPU])
+	AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu", [host CPU])
 	AC_MSG_RESULT([${host_cpu}])
 
 	AC_MSG_CHECKING([vendor])
-	AC_DEFINE_UNQUOTED([HOST_VENDOR], "${host_vendor}", [host vendor])
+	AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor", [host vendor])
 	AC_MSG_RESULT([${host_vendor}])
 
@@ -73,5 +73,5 @@
 		linux-gnu* | lignux* )	host_os_name=linux ;;
 	esac
-	AC_DEFINE_UNQUOTED([HOST_OS_NAME], "${host_os_name}", [host OS name])
+	AC_DEFINE_UNQUOTED(HOST_OS_NAME, "$host_os_name", [host OS name])
 	AC_MSG_RESULT([${host_os_name}])
 
@@ -82,5 +82,5 @@
 		host_os_version=`(uname -r) 2>/dev/null` || host_os_version=unknown
 	fi
-	AC_DEFINE_UNQUOTED([HOST_OS_VERSION], "${host_os_version}", [host OS version])
+	AC_DEFINE_UNQUOTED(HOST_OS_VERSION, "$host_os_version", [host OS version])
 	AC_MSG_RESULT([${host_os_version}])
 
@@ -95,5 +95,5 @@
 		i?86 )	host_arch=i386 ;; # all x86 should show up as i386
 	esac
-	AC_DEFINE_UNQUOTED([HOST_ARCH], "${host_arch}", [host archictecture])
+	AC_DEFINE_UNQUOTED(HOST_ARCH, "$host_arch", [host archictecture])
 	AC_MSG_RESULT([${host_arch}])
 
@@ -219,8 +219,7 @@
 		AC_MSG_RESULT([no])
 	fi
-	AC_DEFINE_UNQUOTED([_SYSTEM_HAS_FMEMOPEN_], ${SYSTEM_FMEMOPEN}, [does system copy of libc have fmemopen])
+	AC_DEFINE_UNQUOTED([_SYSTEM_HAS_FMEMOPEN_], $SYSTEM_FMEMOPEN, [does system copy of libc have fmemopen])
 	AM_CONDITIONAL([SYSTEM_HAS_FMEMOPEN], [test "${SYSTEM_FMEMOPEN}" == "1"])
 
-	IS_MSYS2=no
 	IS_WINDOWS=no
 	AC_MSG_CHECKING([for vendor compilers])
@@ -319,32 +318,18 @@
 			export CFLAGS="-g -O3 -ipo -axAVX -ipo -no-inline-min-size -inline-max-size=345 -no-inline-max-total-size -no-inline-max-per-routine -no-inline-max-per-compile -restrict"
 			AC_DEFINE([_HAVE_RESTRICT_], [1], [with restrict buffers])
-		elif test "${VENDOR}" == "win-msys2"; then
-			export LDFLAGS="${LDFLAGS} -no-undefined"
-			export OSLIBS="-Wl,-L/mingw64/lib/gcc/x86_64-w64-mingw32/10.2.0 -Wl,-L/mingw64/x86_64-w64-mingw32/lib -Wl,-lstdc++ -Wl,-lgfortran -Wl,-lmingw32 -Wl,-lgcc_s -Wl,-lmoldname -Wl,-lmingwex -Wl,-lmsvcrt -Wl,-lm -Wl,-lpthread -Wl,-lshell32 -Wl,-luser32 -Wl,-lgdi32 -Wl,-luser32 -Wl,-ladvapi32 -Wl,-lkernel32 -Wl,-lquadmath -Wl,-lstdc++ -Wl,-lgcc"
-			IS_MSYS2=yes
 		else
 			AC_MSG_ERROR([unknown compiler vendor!])
 		fi
 	fi
-	dnl Set default standard for C++
-	if test "${CXXFLAGS}" == ""; then
-		export CXXFLAGS="-std=C++11"
-	fi
 	AC_SUBST([OSLIBS])
 	AC_MSG_RESULT([done])
 
-	AC_MSG_CHECKING([if this is a MSVC (Windows) build])
+	AC_MSG_CHECKING([if this is a Windows build])
 	AM_CONDITIONAL([WINDOWS], [test "x${IS_WINDOWS}" == "xyes"])
 	AC_MSG_RESULT([${IS_WINDOWS}])
-
-	AC_MSG_CHECKING([if this is a MSYS2 (Windows) build])
-	AM_CONDITIONAL([MSYS2], [test "x${IS_MSYS2}" == "xyes"])
-	AC_MSG_RESULT([${IS_MSYS2}])
-	AC_DEFINE([_IS_MSYS2_], [1], [is a MSYS2 (Windows) build])
 	dnl }}}
 	dnl MATLAB{{{
 
 	dnl See if MATLAB has been provided
-	AC_MSG_CHECKING([for MATLAB])
 	AC_ARG_WITH(
 		[matlab-dir],														dnl feature
@@ -353,4 +338,5 @@
 		[MATLAB_ROOT="no"]													dnl action if not given
 	)
+	AC_MSG_CHECKING([for MATLAB])
 	if test "x${MATLAB_ROOT}" == "xno"; then
 		HAVE_MATLAB=no
@@ -371,5 +357,5 @@
 		AC_DEFINE([_HAVE_MATLAB_], [1], [with MATLAB in ISSM src])
 
-		dnl Set MEX* variable
+		dnl Set MEXLIB, MEXLINK, and MEXEXT
 		AC_MSG_CHECKING([MATLAB's mex compilation flags])
 
@@ -381,47 +367,24 @@
 				if test "${VENDOR}" == "intel-win7-32"; then
 					MEXLIB="-Wl,libmx.lib -Wl,libmex.lib -Wl,libmat.lib ${OSLIBS} -Wl,libf2cblas.lib -Wl,libf2clapack.lib"
-					MEXLINKFLAGS="-Wl,/LIBPATH:`cygpath -m ${MATLAB_ROOT}/extern/lib/win32/microsoft` -Wl,/link -Wl,/EXPORT:mexFunction -Wl,/DLL"
+					MEXLINK="-Wl,/LIBPATH:`cygpath -m ${MATLAB_ROOT}/extern/lib/win32/microsoft` -Wl,/link -Wl,/EXPORT:mexFunction -Wl,/DLL"
 					MEXEXT=`${MATLAB_ROOT}/bin/mexext.bat`
 					MEXEXT=".${MEXEXT}"
 				elif test "${VENDOR}" == "intel-win7-64"; then
 					MEXLIB="-Wl,libmx.lib -Wl,libmex.lib -Wl,libmat.lib ${OSLIBS} -Wl,libf2cblas.lib -Wl,libf2clapack.lib"
-					MEXLINKFLAGS="-Wl,/LIBPATH:`cygpath -m ${MATLAB_ROOT}/extern/lib/win64/microsoft` -Wl,/link -Wl,/EXPORT:mexFunction -Wl,/DLL"
+					MEXLINK="-Wl,/LIBPATH:`cygpath -m ${MATLAB_ROOT}/extern/lib/win64/microsoft` -Wl,/link -Wl,/EXPORT:mexFunction -Wl,/DLL"
 					MEXEXT=".mexw64"
 				elif test "${VENDOR}" == "MSVC-Win64" || test "${VENDOR}" == "MSVC-Win64-par"; then
 					MEXLIB="-Wl,libmx.lib -Wl,libmex.lib -Wl,libmat.lib ${OSLIBS} -Wl,libf2cblas.lib -Wl,libf2clapack.lib"
-					MEXLINKFLAGS="-Wl,/link -Wl,/LIBPATH:`cygpath -m ${MATLAB_ROOT}/extern/lib/win64/microsoft` -Wl,/link -Wl,/EXPORT:mexFunction -Wl,/DLL"
+					MEXLINK="-Wl,/link -Wl,/LIBPATH:`cygpath -m ${MATLAB_ROOT}/extern/lib/win64/microsoft` -Wl,/link -Wl,/EXPORT:mexFunction -Wl,/DLL"
 					MATLABINCL="-I`cygpath -m ${MATLAB_ROOT}/extern/include`"
 					MEXEXT=".mexw64"
 				fi
 			;;
-			*mingw*)
-				if test "${IS_MSYS2}" == "yes"; then
-					dnl Value to set MEXEXT to can be found on Windows by running $MATLAB_ROOT/bin/mexext.bat
-					MEXEXT=".mexw64"
-					MATLABINCL="-I${MATLAB_ROOT}/extern/include"
-					MEXOPTFLAGS="-O2 -fwrapv -DNDEBUG -g"
-					MEXCFLAGS="-fexceptions -fno-omit-frame-pointer -m64 -DMATLAB_MEX_FILE"
-					MEXCXXFLAGS="-fexceptions -fno-omit-frame-pointer -std=c++11 -m64 -DMATLAB_MEX_FILE"
-					MEXLINKFLAGS="-m64 -Wl,--no-undefined -shared -static -Wl,${MATLAB_ROOT}/extern/lib/win64/mingw64/mexFunction.def"
-					MEXLIB_DIR="${MATLAB_ROOT}/extern/lib/win64/mingw64"
-					MEXLIB="-L${MEXLIB_DIR} -lmx -lmex -lmat -lm -lmwlapack -lmwblas"
-				fi
-			;;
-			*msys*)
-				dnl Value to set MEXEXT to can be found on Windows by running $MATLAB_ROOT/bin/mexext.bat
-				MEXEXT=".mexw64"
+			*)
 				MATLABINCL="-I${MATLAB_ROOT}/extern/include"
-				MEXOPTFLAGS="-O2 -fwrapv -DNDEBUG -g"
-				MEXCFLAGS="-fexceptions -fno-omit-frame-pointer -m64 -DMATLAB_MEX_FILE"
-				MEXCXXFLAGS="-fexceptions -fno-omit-frame-pointer -std=c++11 -m64 -DMATLAB_MEX_FILE"
-				MEXLINKFLAGS="-m64 -Wl,--no-undefined -shared -static -Wl,${MATLAB_ROOT}/extern/lib/win64/mingw64/mexFunction.def"
-				MEXLIB_DIR="${MATLAB_ROOT}/extern/lib/win64/mingw64"
-				MEXLIB="-L${MEXLIB_DIR} -lmx -lmex -lmat -lm -lmwlapack -lmwblas"
-			;;
-			*)
+				MEXLINK=$(${MATLAB_ROOT}/bin/mex -v 2>&1 < /dev/null | grep LDFLAGS | sed -e "s/         LDFLAGS            = //g")
+				MEXLIB=$(${MATLAB_ROOT}/bin/mex -v 2>&1 < /dev/null | grep CXXLIBS | sed -e "s/         CXXLIBS            = //g")
 				MEXEXT=$(${MATLAB_ROOT}/bin/mex -v 2>&1 < /dev/null | grep LDEXTENSION | sed -e "s/         LDEXTENSION        = //g")
-				MATLABINCL="-I${MATLAB_ROOT}/extern/include"
-				MEXLINKFLAGS=$(${MATLAB_ROOT}/bin/mex -v 2>&1 < /dev/null | grep LDFLAGS | sed -e "s/         LDFLAGS            = //g")
-				MEXLIB=$(${MATLAB_ROOT}/bin/mex -v 2>&1 < /dev/null | grep CXXLIBS | sed -e "s/         CXXLIBS            = //g")
+				dnl version 2014 and up
 				if test -z "${MEXEXT}"; then
 					echo "#include <mex.h>" > conftest.cpp
@@ -429,5 +392,5 @@
 					${MATLAB_ROOT}/bin/mex -v -lmex conftest.cpp > conftest.tmp 2>&1
 					rm -f conftest.cpp
-					MEXLINKFLAGS=$(cat conftest.tmp | grep LDFLAGS | sed -e "s/LDFLAGS ://g")
+					MEXLINK=$(cat conftest.tmp | grep LDFLAGS | sed -e "s/LDFLAGS ://g")
 					MEXLIB=$(cat conftest.tmp | grep LINKLIBS | sed -e "s/LINKLIBS ://g")
 					MEXEXT=$(cat conftest.tmp | grep LDEXT | sed -e "s/LDEXT ://g" | awk '{print $[1]}')
@@ -439,6 +402,6 @@
 
 				dnl Make sure mexFunction.map is not in MEXLIB to avoid problems with global variables
-				dnl MEXLINKFLAGS=$(echo ${MEXLINKFLAGS} | sed -e "s/,-expo.*mexFunction\\.map\"//g" | sed -e "s/-[[^ ]]*mexFunction\\.map//g")
-				MEXLINKFLAGS="" dnl We actually don't need MEXLINK????
+				dnl MEXLINK=$(echo ${MEXLINK} | sed -e "s/,-expo.*mexFunction\\.map\"//g" | sed -e "s/-[[^ ]]*mexFunction\\.map//g")
+				MEXLINK="" dnl We actually don't need MEXLINK????
 			;;
 		esac
@@ -448,15 +411,12 @@
 		fi
 
-		AC_SUBST([MEXEXT])
-		AC_SUBST([MEXOPTFLAGS])
-		AC_SUBST([MEXCFLAGS])
-		AC_SUBST([MEXCXXFLAGS])
 		AC_SUBST([MATLABINCL])
-		AC_SUBST([MEXLINKFLAGS])
+		MATLABWRAPPEREXT=${MEXEXT}
+		AC_SUBST([MATLABWRAPPEREXT])
 		AC_SUBST([MEXLIB])
+		AC_SUBST([MEXLINK])
 	fi
 	dnl }}}
 	dnl JavaScript{{{
-	AC_MSG_CHECKING([for JavaScript])
 	AC_ARG_WITH(
 		[javascript],
@@ -465,4 +425,5 @@
 		[JAVASCRIPT="no"]
 	)
+	AC_MSG_CHECKING([for JavaScript])
 	if test "x${JAVASCRIPT}" == "xno"; then
 		HAVE_JAVASCRIPT=no
@@ -477,5 +438,4 @@
 	dnl }}}
 	dnl Triangle {{{
-	AC_MSG_CHECKING([for triangle])
 	AC_ARG_WITH(
 		[triangle-dir],
@@ -484,4 +444,5 @@
 		[TRIANGLE_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for triangle])
 	if test "x${TRIANGLE_ROOT}" == "xno"; then
 		HAVE_TRIANGLE=no
@@ -522,20 +483,4 @@
 				fi
 			;;
-			*mingw*)
-				if test "x${HAVE_JAVASCRIPT}" == "xyes"; then
-					dnl Link to the object file, not the library
-					TRIANGLELIB=${TRIANGLE_ROOT}/share/triangle.o
-				else
-					TRIANGLELIB="-L${TRIANGLE_ROOT}/lib -ltriangle"
-				fi
-			;;
-			*msys*)
-				if test "x${HAVE_JAVASCRIPT}" == "xyes"; then
-					dnl Link to the object file, not the library
-					TRIANGLELIB=${TRIANGLE_ROOT}/share/triangle.o
-				else
-					TRIANGLELIB="-L${TRIANGLE_ROOT}/lib -ltriangle"
-				fi
-			;;
 		esac
 		AC_DEFINE([_HAVE_TRIANGLE_], [1], [with Triangle in ISSM src])
@@ -545,5 +490,4 @@
 	dnl }}}
 	dnl Boost{{{
-	AC_MSG_CHECKING([for Boost])
 	AC_ARG_WITH(
 		[boost-dir],
@@ -552,4 +496,5 @@
 		[BOOST_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for Boost])
 	if test "x${BOOST_ROOT}" == "xno"; then
 		HAVE_BOOST=no
@@ -578,5 +523,4 @@
 	dnl }}}
 	dnl Dakota{{{
-	AC_MSG_CHECKING([for Dakota])
 	AC_ARG_WITH(
 		[dakota-dir],
@@ -585,4 +529,5 @@
 		[DAKOTA_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for Dakota])
 	if test "x${DAKOTA_ROOT}" == "xno"; then
 		HAVE_DAKOTA=no
@@ -602,5 +547,5 @@
 		AC_MSG_CHECKING(for Dakota version)
 		dnl TODO:	Check if this method applies to all other versions of 
-		dnl			Dakota (it should as long as the Dakota binaries have been 
+		dnl			Dakota (it should as long as the Dakota binaries have been
 		dnl 		compiled). If so, we can remove the other methods of 
 		dnl			getting the version.
@@ -619,5 +564,5 @@
 		fi
 		AC_MSG_RESULT([${DAKOTA_VERSION}])
-		AC_DEFINE_UNQUOTED([_DAKOTA_VERSION_], ${DAKOTA_VERSION}, [Dakota version number])
+		AC_DEFINE_UNQUOTED(_DAKOTA_VERSION_, "${DAKOTA_VERSION}", [Dakota version number])
 
 		DAKOTAFLAGS=""
@@ -734,11 +679,11 @@
 		AC_MSG_CHECKING(for Dakota major version)
 		AC_MSG_RESULT(${DAKOTA_MAJOR})
-		AC_DEFINE_UNQUOTED([_DAKOTA_MAJOR_], ${DAKOTA_MAJOR}, [Dakota major version number])
+		AC_DEFINE_UNQUOTED(_DAKOTA_MAJOR_, $DAKOTA_MAJOR, [Dakota major version number])
 		AC_MSG_CHECKING(for Dakota minor version)
 		AC_MSG_RESULT(${DAKOTA_MINOR})
-		AC_DEFINE_UNQUOTED([_DAKOTA_MINOR_], ${DAKOTA_MINOR}, [Dakota minor version number])
+		AC_DEFINE_UNQUOTED(_DAKOTA_MINOR_, $DAKOTA_MINOR, [Dakota minor version number])
 		AC_MSG_CHECKING(for Dakota build version)
 		AC_MSG_RESULT(${DAKOTA_BUILD})
-		AC_DEFINE_UNQUOTED([_DAKOTA_BUILD_], ${DAKOTA_BUILD}, [Dakota build version number])
+		AC_DEFINE_UNQUOTED(_DAKOTA_BUILD_, $DAKOTA_BUILD, [Dakota build version number])
 
 		AC_DEFINE([_HAVE_DAKOTA_], [1], [with Dakota in ISSM src])
@@ -750,5 +695,4 @@
 	dnl }}}
 	dnl Python{{{
-	AC_MSG_CHECKING([for Python])
 	AC_ARG_WITH(
 		[python-dir],
@@ -764,4 +708,5 @@
 		[PYTHON_VERSION="no"]
 	)
+	AC_MSG_CHECKING([for Python])
 	if test "x${PYTHON_ROOT}" == "xno"; then
 		HAVE_PYTHON=no
@@ -790,5 +735,5 @@
 		dnl Determine major version
 		PYTHON_MAJOR=${PYTHON_VERSION%.*}
-		AC_DEFINE_UNQUOTED([_PYTHON_MAJOR_], ${PYTHON_MAJOR}, [Python version major])
+		AC_DEFINE_UNQUOTED(_PYTHON_MAJOR_, $PYTHON_MAJOR, [Python version major])
 		if test "x${PYTHON_MAJOR}" == "x3"; then
 			HAVE_PYTHON3="yes"
@@ -806,5 +751,5 @@
 			PYTHONINCL=-I${PYTHON_ROOT}/include/python${PYTHON_VERSION}m
 		else
-			AC_MSG_ERROR([Python.h not found! Please locate this file and contact ISSM developers via forum or email.]);
+			AC_MSG_ERROR([Python.h not found, locate this file and contact ISSM developers]);
 		fi
 		AC_MSG_RESULT([found])
@@ -819,15 +764,9 @@
 				PYTHONLINK="-shared"
 			;;
+			*linux*)
+				PYTHONLINK="-shared"
+			;;
 			*darwin*)
 				PYTHONLINK="-dynamiclib"
-			;;
-			*linux*)
-				PYTHONLINK="-shared"
-			;;
-			*mingw*)
-				PYTHONLINK="-shared"
-			;;
-			*msys*)
-				PYTHONLINK="-shared"
 			;;
 		esac
@@ -842,4 +781,15 @@
 	dnl }}}
 	dnl NumPy{{{
+	dnl TODO:
+	dnl - Replace references to python-numpy with numpy (and similar terms)
+	dnl	  project-wide
+	dnl
+	AC_ARG_WITH(
+		[python-numpy-dir],
+		AS_HELP_STRING([--with-python-numpy-dir=DIR], [python-numpy root directory]),
+		[PYTHON_NUMPY_ROOT=${withval}],
+		[PYTHON_NUMPY_ROOT="no"]
+	)
+
 	dnl NOTE: You can find NumPy by running,
 	dnl
@@ -847,15 +797,6 @@
 	dnl		>>> numpy.__file__
 	dnl
-	dnl TODO:
-	dnl - Replace references to python-numpy with numpy (and similar terms)
-	dnl	  project-wide
-	dnl
+
 	AC_MSG_CHECKING(for python-numpy)
-	AC_ARG_WITH(
-		[python-numpy-dir],
-		AS_HELP_STRING([--with-python-numpy-dir=DIR], [python-numpy root directory]),
-		[PYTHON_NUMPY_ROOT=${withval}],
-		[PYTHON_NUMPY_ROOT="no"]
-	)
 	if test "x${PYTHON_NUMPY_ROOT}" == "xno"; then
 		HAVE_PYTHON_NUMPY=no
@@ -876,5 +817,4 @@
 	dnl }}}
 	dnl Chaco{{{
-	AC_MSG_CHECKING([for Chaco])
 	AC_ARG_WITH(
 		[chaco-dir],
@@ -883,4 +823,5 @@
 		[CHACO_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for Chaco])
 	if test "x${CHACO_ROOT}" == "xno"; then
 		HAVE_CHACO=no
@@ -904,5 +845,4 @@
 	dnl }}}
 	dnl ESMF{{{
-	AC_MSG_CHECKING([for ESMF])
 	AC_ARG_WITH(
 		[esmf-dir],
@@ -911,4 +851,5 @@
 		[ESMF_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for ESMF])
 	if test "x${ESMF_ROOT}" == "xno"; then
 		HAVE_ESMF=no
@@ -932,5 +873,4 @@
 	dnl }}}
 	dnl CoDiPack{{{
-	AC_MSG_CHECKING([for CoDiPack])
 	AC_ARG_WITH(
 		[codipack-dir],
@@ -939,4 +879,5 @@
 		[CODIPACK_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for CoDiPack])
 	if test "x${CODIPACK_ROOT}" == "xno"; then
 		HAVE_CODIPACK=no
@@ -960,5 +901,4 @@
 	dnl }}}
 	dnl Tape Allocation {{{
-	AC_MSG_CHECKING(for tape allocation)
 	AC_ARG_ENABLE(
 		[tape-alloc],																dnl feature
@@ -967,4 +907,5 @@
 		[enable_tape_alloc=no]
 	)
+	AC_MSG_CHECKING(for tape allocation)
 	if test "x${enable_tape_alloc}" == "xyes"; then
 		AC_DEFINE([_AD_TAPE_ALLOC_], [1], [enable a priori tape allocation for AD])
@@ -973,5 +914,4 @@
 	dnl }}}
 	dnl ADOL-C {{{
-	AC_MSG_CHECKING([for ADOL-C])
 	AC_ARG_WITH(
 		[adolc-dir],
@@ -980,4 +920,5 @@
 		[ADOLC_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for ADOL-C])
 	if test "x${ADOLC_ROOT}" == "xno"; then
 		HAVE_ADOLC=no
@@ -1004,5 +945,4 @@
 	dnl }}}
 	dnl ADOL-C version{{{
-	AC_MSG_CHECKING(for ADOL-C version)
 	AC_ARG_WITH(
 		[adolc-version],
@@ -1011,9 +951,10 @@
 		[ADOLC_VERSION=2]
 	)
-	AC_DEFINE_UNQUOTED([_ADOLC_VERSION_], ${ADOLC_VERSION}, [ADOL-C version])
+	AC_MSG_CHECKING(for ADOL-C version)
+
+	AC_DEFINE_UNQUOTED(_ADOLC_VERSION_, $ADOLC_VERSION, [ADOL-C version])
 	AC_MSG_RESULT(${ADOLC_VERSION})
 	dnl }}}
 	dnl ADIC2 {{{
-	AC_MSG_CHECKING([for ADIC2])
 	AC_ARG_WITH(
 		[adic2-dir],
@@ -1022,4 +963,5 @@
 		[ADIC2_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for ADIC2])
 	if test "x${ADIC2_ROOT}" == "xno"; then
 		HAVE_ADIC2=no
@@ -1043,5 +985,4 @@
 	dnl }}}
 	dnl ATLAS {{{
-	AC_MSG_CHECKING(for ATLAS and CBLAS libraries)
 	AC_ARG_WITH(
 		[atlas-dir],
@@ -1050,4 +991,5 @@
 		[ATLAS_ROOT="no"]
 	)
+	AC_MSG_CHECKING(for ATLAS and CBLAS libraries)
 	if test "x${ATLAS_ROOT}" == "xno"; then
 		HAVE_ATLAS=no
@@ -1066,15 +1008,9 @@
 				ATLASLIB="-L`cygpath -m ${ATLAS_ROOT}` -Wl,libatlas.lib  -Wl,libcblas.lib"
 			;;
+			*linux*)
+				ATLASLIB="-L${ATLAS_ROOT}/lib -lcblas -latlas -lm "
+			;;
 			*darwin*)
-				ATLASLIB="-L${ATLAS_ROOT}/lib -lcblas -latlas -lm"
-			;;
-			*linux*)
-				ATLASLIB="-L${ATLAS_ROOT}/lib -lcblas -latlas -lm"
-			;;
-			*mingw*)
-				ATLASLIB="-L${ATLAS_ROOT}/lib -lcblas -latlas -lm"
-			;;
-			*msys*)
-				ATLASLIB="-L${ATLAS_ROOT}/lib -lcblas -latlas -lm"
+				ATLASLIB="-L${ATLAS_ROOT}/lib -lcblas -latlas -lm "
 			;;
 		esac
@@ -1084,5 +1020,4 @@
 	dnl }}}
 	dnl GSL{{{
-	AC_MSG_CHECKING([for GSL])
 	AC_ARG_WITH(
 		[gsl-dir],
@@ -1091,4 +1026,5 @@
 		[GSL_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for GSL])
 	if test "x${GSL_ROOT}" == "xno"; then
 		HAVE_GSL=no
@@ -1116,5 +1052,4 @@
 	dnl }}}
 	dnl AMPI (ADOL-C){{{
-	AC_MSG_CHECKING([for AMPI])
 	AC_ARG_WITH(
 		[ampi-dir],
@@ -1123,4 +1058,5 @@
 		[AMPI_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for AMPI])
 	if test "x${AMPI_ROOT}" == "xno"; then
 		HAVE_AMPI=no
@@ -1152,5 +1088,4 @@
 	dnl }}}
 	dnl Adjoint MPI (CoDiPack){{{
-	AC_MSG_CHECKING([for Adjoint MPI])
 	AC_ARG_WITH(
 		[adjointmpi-dir],
@@ -1159,4 +1094,5 @@
 		[ADJOINTMPI_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for Adjoint MPI])
 	if test "x${ADJOINTMPI_ROOT}" == "xno"; then
 		HAVE_ADJOINTMPI=no
@@ -1186,5 +1122,4 @@
 	dnl }}}
 	dnl MeDiPack (CoDiPack, ADOL-C dev){{{
-	AC_MSG_CHECKING([for MeDiPack])
 	AC_ARG_WITH(
 		[medipack-dir],
@@ -1193,4 +1128,5 @@
 		[MEDIPACK_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for MeDiPack])
 	if test "x${MEDIPACK_ROOT}" == "xno"; then
 		HAVE_MEDIPACK=no
@@ -1218,5 +1154,4 @@
 	dnl }}}
 	dnl HDF5 {{{
-	AC_MSG_CHECKING(for HDF5 libraries)
 	AC_ARG_WITH(
 		[hdf5-dir],
@@ -1225,4 +1160,5 @@
 		[HDF5_ROOT="no"]
 	)
+	AC_MSG_CHECKING(for HDF5 libraries)
 	if test "x${HDF5_ROOT}" == "xno"; then
 		HAVE_HDF5=no
@@ -1245,14 +1181,8 @@
 				HDF5LIB="-L`cygpath -m ${HDF5_ROOT}` -Wl,libhdf5.lib  -Wl,libhdf5_hl.lib"
 			;;
-			*darwin*)
-				HDF5LIB="-L${HDF5_ROOT}/lib -lhdf5 -lhdf5_hl"
-			;;
 			*linux*)
 				HDF5LIB="-L${HDF5_ROOT}/lib -lhdf5 -lhdf5_hl"
 			;;
-			*mingw*)
-				HDF5LIB="-L${HDF5_ROOT}/lib -lhdf5 -lhdf5_hl"
-			;;
-			*msys*)
+			*darwin*)
 				HDF5LIB="-L${HDF5_ROOT}/lib -lhdf5 -lhdf5_hl"
 			;;
@@ -1263,5 +1193,4 @@
 	dnl }}}
 	dnl PETSc{{{
-	AC_MSG_CHECKING([for PETSc])
 	AC_ARG_WITH(
 		[petsc-dir],
@@ -1270,4 +1199,5 @@
 		[PETSC_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for PETSc])
 	if test "x${PETSC_ROOT}" == "xno"; then
 		HAVE_PETSC=no
@@ -1290,6 +1220,6 @@
 		PETSC_MAJOR=`cat ${PETSC_ROOT}/include/petscversion.h | grep "#define PETSC_VERSION_MAJOR" | sed 's/#define PETSC_VERSION_MAJOR//' | sed 's/ //g'`
 		PETSC_MINOR=`cat ${PETSC_ROOT}/include/petscversion.h | grep "#define PETSC_VERSION_MINOR" | sed 's/#define PETSC_VERSION_MINOR//' | sed 's/ //g'`
-		AC_DEFINE_UNQUOTED([_PETSC_MAJOR_], ${PETSC_MAJOR}, [PETSc version major])
-		AC_DEFINE_UNQUOTED([_PETSC_MINOR_], ${PETSC_MINOR}, [PETSc version minor])
+		AC_DEFINE_UNQUOTED([_PETSC_MAJOR_], [$PETSC_MAJOR], [PETSc version major])
+		AC_DEFINE_UNQUOTED([_PETSC_MINOR_], [$PETSC_MINOR], [PETSc version minor])
 		AC_MSG_RESULT([${PETSC_MAJOR}.${PETSC_MINOR}])
 
@@ -1332,14 +1262,4 @@
 					PETSCLIB="/link -Wl,/LIBPATH:`cygpath -m ${PETSC_ROOT}/lib` -Wl,libpetsc.lib"
 					PETSCINCL="/I`cygpath -m ${PETSC_ROOT}/include`"
-				fi
-			;;
-			*darwin*)
-				if test ${PETSC_MAJOR} -lt 3; then
-					PETSCLIB="-L${PETSC_ROOT}/lib -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetscsnes -lpetscts -lpetsc"
-				else
-					PETSCLIB="-L${PETSC_ROOT}/lib -lpetsc"
-					if test ${PETSC_MAJOR} -gt 3 || test ${PETSC_MINOR} -ge 3; then
-						PETSCLIB+=" -lmetis"
-					fi
 				fi
 			;;
@@ -1360,9 +1280,13 @@
 				fi
 			;;
-			*mingw*)
-				PETSCLIB="-Wl,${PETSC_ROOT}/lib/libpetsc.a"
-			;;
-			*msys*)
-				PETSCLIB="${PETSC_ROOT}/lib -lpetsc"
+			*darwin*)
+				if test ${PETSC_MAJOR} -lt 3; then
+					PETSCLIB="-L${PETSC_ROOT}/lib -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetscsnes -lpetscts -lpetsc"
+				else
+					PETSCLIB="-L${PETSC_ROOT}/lib -lpetsc"
+					if test ${PETSC_MAJOR} -gt 3 || test ${PETSC_MINOR} -ge 3; then
+						PETSCLIB+=" -lmetis"
+					fi
+				fi
 			;;
 		esac
@@ -1375,4 +1299,5 @@
 	dnl MPI{{{
 	AC_MSG_CHECKING(for MPI)
+
 	AC_ARG_WITH(
 		[mpi-include],
@@ -1381,4 +1306,5 @@
 		[MPI_INCLUDE=""]
 	)
+
 	AC_ARG_WITH(
 		[mpi-libdir],
@@ -1387,4 +1313,5 @@
 		[MPI_LIBDIR=""]
 	)
+
 	AC_ARG_WITH(
 		[mpi-libflags],
@@ -1393,4 +1320,5 @@
 		[MPI_LIBFLAGS=""]
 	)
+
 	if test -z "${MPI_INCLUDE}"; then
 		HAVE_MPI=no
@@ -1435,5 +1363,4 @@
 	dnl }}}
 	dnl SCOTCH{{{
-	AC_MSG_CHECKING([for SCOTCH])
 	AC_ARG_WITH(
 		[scotch-dir],
@@ -1442,4 +1369,5 @@
 		[SCOTCH_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for SCOTCH])
 	if test "x${SCOTCH_ROOT}" == "xno"; then
 		HAVE_SCOTCH=no
@@ -1474,136 +1402,82 @@
 	dnl }}}
 	dnl METIS{{{
-	AC_MSG_CHECKING([for METIS])
-	AC_ARG_WITH(
-		[metis-dir],
-		AS_HELP_STRING([--with-metis-dir=DIR], [METIS root directory, necessary for serial build]),
-		[METIS_ROOT=${withval}],
-		[METIS_ROOT="no"]
-	)
-	HAVE_METIS=no
-	if test "x${METIS_ROOT}" == "xno"; then
-		dnl Check if METIS was installed via PETSc
-		if test -f ${PETSC_ROOT}/install/include/metis.h; then
+
+	dnl NOTE: We know $VENDOR cannot be empty at this point, so no need to
+	dnl		  check again in the following conditionals
+	dnl
+	if test "x${HAVE_PETSC}" == "xyes" && test "x${PETSC_MAJOR}" == "x3" && test ${PETSC_MINOR} -ge 3 && test "${VENDOR}" != "MSVC-Win64" && test "${VENDOR}" != "MSVC-Win64-par"; then
+		dnl In PETSc >=3.3, METIS is provided
+		HAVE_METIS="yes"
+		AC_DEFINE([_METIS_VERSION_], [5], [METIS version number])
+		AC_DEFINE([_HAVE_METIS_], [1], [with METIS in ISSM src])
+	else
+		AC_ARG_WITH(
+			[metis-dir],
+			AS_HELP_STRING([--with-metis-dir=DIR], [METIS root directory, necessary for serial build]),
+			[METIS_ROOT=${withval}],
+			[METIS_ROOT="no"]
+		)
+		AC_MSG_CHECKING([for METIS])
+		if test "x${METIS_ROOT}" == "xno"; then
+			HAVE_METIS=no
+		else
 			HAVE_METIS=yes
-			METIS_ROOT="${PETSC_ROOT}"
-		fi
-	else
-		if ! test -d "${METIS_ROOT}"; then
-			AC_MSG_ERROR([METIS directory provided (${METIS_ROOT}) does not exist!]);
-		fi
-		HAVE_METIS=yes
-	fi
-	if test "${HAVE_METIS}" = "yes"; then
-		METIS_VERSION=$(grep "#define METIS_VER_MAJOR" ${METIS_ROOT}/include/metis.h | sed 's|.*METIS_VER_MAJOR[[:space:]]*||')
+			if ! test -d "${METIS_ROOT}"; then
+				AC_MSG_ERROR([METIS directory provided (${METIS_ROOT}) does not exist!]);
+			fi
+		fi
+		AC_MSG_RESULT([${HAVE_METIS}])
+		AM_CONDITIONAL([METIS], [test "x${HAVE_METIS}" == "xyes"])
+
 		dnl METIS libraries and header files
-		if test "x${METIS_VERSION}" == "x4"; then
-			METISINCL="-I${METIS_ROOT}/Lib"
-			case "${host_os}" in
-				*cygwin*)
-					METISINCL="/I`cygpath -m ${METIS_ROOT}/Lib`"
-					METISLIB="-Wl,/link -Wl,/LIBPATH:`cygpath -m ${METIS_ROOT}` -Wl,libmetis.lib"
-				;;
-				*darwin*)
-					METISLIB="-L${METIS_ROOT} -lmetis"
-				;;
-				*linux*)
-					METISLIB="-L${METIS_ROOT} -lmetis"
-				;;
-				*mingw*)
-					METISLIB="-Wl,${METIS_ROOT}/lib/libmetis.a"
-				;;
-				*msys*)
-					METISLIB="-L${METIS_ROOT} -lmetis"
-				;;
-			esac
-		elif test "x${METIS_VERSION}" == "x5"; then
-			METISINCL="-I${METIS_ROOT}/include"
-			case "${host_os}" in
-				*cygwin*)
-					METISLIB="-L${METIS_ROOT} libmetis.lib"
-				;;
-				*darwin*)
-					METISLIB="-L${METIS_ROOT}/lib -lmetis"
-				;;
-				*linux*)
-					METISLIB="-L${METIS_ROOT}/lib -lmetis"
-				;;
-				*mingw*)
-					METISLIB="-Wl,${METIS_ROOT}/lib/libmetis.a"
-				;;
-				*msys*)
-					METISLIB="-L${METIS_ROOT}/lib -lmetis"
-				;;
-			esac
-		else
-			AC_MSG_ERROR([METIS version ${METIS_VERSION} not yet supported! Please contact ISSM developers via forum or email.])
-		fi
-		AC_DEFINE([_HAVE_METIS_], [1], [with METIS in ISSM src])
-		AC_DEFINE_UNQUOTED([_METIS_VERSION_], ${METIS_VERSION}, [METIS version number])
-		AC_SUBST([METISINCL])
-		AC_SUBST([METISLIB])
-	fi
-	AC_MSG_RESULT([${HAVE_METIS}])
-	AM_CONDITIONAL([METIS], [test "x${HAVE_METIS}" = "xyes"])
-	dnl }}}
-	dnl ParMETIS{{{
-	AC_MSG_CHECKING([for ParMETIS])
-	AC_ARG_WITH(
-		[parmetis-dir],
-		AS_HELP_STRING([--with-parmetis-dir=DIR], [ParMETIS root directory, necessary for parallel build]),
-		[PARMETIS_ROOT=${withval}],
-		[PARMETIS_ROOT="no"]
-	)
-	HAVE_PARMETIS=no
-	if test "x${PARMETIS_ROOT}" == "xno"; then
-		dnl Check if ParMETIS was installed via PETSc
-		if test -f ${PETSC_ROOT}/install/include/parmetis.h; then
-			HAVE_PARMETIS="yes"
-			PARMETIS_ROOT="${PETSC_ROOT}"
-		fi
-	else
-		if ! test -d "${PARMETIS_ROOT}"; then
-			AC_MSG_ERROR([ParMETIS directory provided (${PARMETIS_ROOT}) does not exist!]);
-		fi
-		if ! test -d "${METIS_ROOT}"; then
-			AC_MSG_ERROR([If supplying path to ParMETIS with option --with-parmetis-dir, must also supply path to METIS with option --with-metis-dir]);
-		fi
-		HAVE_PARMETIS="yes"
-	fi
-	if test "${HAVE_PARMETIS}" == "yes"; then
-		#PARMETIS_VERSION=$(grep "#define PARMETIS_MAJOR_VERSION" ${PARMETIS_ROOT}/include/parmetis.h | sed 's|.*PARMETIS_MAJOR_VERSION[[:space:]]*||')
-		dnl METIS libraries and header files
-		#if test "x${PARMETIS_VERSION}" == "x4"; then
-			PARMETISINCL="-I${PARMETIS_ROOT}/include"
-			case "${host_os}" in
-				*cygwin*)
-					PARMETISLIB="-L${PARMETIS_ROOT}/lib -lparmetis"
-				;;
-				*darwin*)
-					PARMETISLIB="-L${PARMETIS_ROOT}/lib -lparmetis"
-				;;
-				*linux*)
-					PARMETISLIB="-L${PARMETIS_ROOT}/lib -lparmetis"
-				;;
-				*mingw*)
-					PARMETISLIB="-Wl,${PARMETIS_ROOT}/lib/libparmetis.a"
-				;;
-				*msys*)
-					PARMETISLIB="-L${PARMETIS_ROOT}/lib -lparmetis"
-				;;
-			esac
-		#else
-		#	AC_MSG_ERROR([ParMETIS version ${PARMETIS_VERSION} not yet supported! Please contact ISSM developers via forum or email.])
-		#fi
-		AC_DEFINE([_HAVE_PARMETIS_], [1], [with ParMETIS in ISSM src])
-		#AC_DEFINE([_PARMETIS_VERSION_], [${PARMETIS_VERSION}], [ParMETIS version number])
-		AC_SUBST([PARMETISINCL])
-		AC_SUBST([PARMETISLIB])
-	fi
-	AC_MSG_RESULT([${HAVE_PARMETIS}])
-	AM_CONDITIONAL([PARMETIS], [test "x${HAVE_PARMETIS}" = "xyes"])
+		if test "x${HAVE_METIS}" == "xyes"; then
+			dnl Retrieve METIS version (does the VERSION file exist?)
+			if test -f "${METIS_ROOT}/VERSION"; then
+				METIS_VERSION=4
+			else
+				METIS_VERSION=5
+			fi
+
+			if test "x${METIS_VERSION}" == "x4"; then
+				METISINCL="-I${METIS_ROOT}/Lib"
+				case "${host_os}" in
+					*cygwin*)
+						METISINCL="/I`cygpath -m ${METIS_ROOT}/Lib`"
+						METISLIB="-Wl,/link -Wl,/LIBPATH:`cygpath -m ${METIS_ROOT}` -Wl,libmetis.lib"
+					;;
+					*linux*)
+						METISLIB="-L${METIS_ROOT} -lparmetis -lmetis"
+					;;
+					*darwin*)
+						METISLIB="-L${METIS_ROOT} -lparmetis -lmetis"
+					;;
+				esac
+				AC_DEFINE([_METIS_VERSION_], [4], [ METIS version number])
+			fi
+
+			if test "x${METIS_VERSION}" == "x5"; then
+				case "${host_os}" in
+					*cygwin*)
+						METISLIB="-L${METIS_ROOT} libmetis.lib"
+					;;
+					*linux*)
+						METISLIB="-L${METIS_ROOT}/lib -lparmetis -lmetis"
+					;;
+					*darwin*)
+						METISLIB="-L${METIS_ROOT}/lib -lparmetis -lmetis"
+					;;
+				esac
+				METISINCL="-I${METIS_ROOT}/include"
+				AC_DEFINE([_METIS_VERSION_], [5], [METIS version number])
+			fi
+
+			AC_DEFINE([_HAVE_METIS_], [1], [with METIS in ISSM src])
+			AC_SUBST([METISINCL])
+			AC_SUBST([METISLIB])
+		fi
+	fi
+	AM_CONDITIONAL([METIS], [test "x${HAVE_METIS}" == "xyes"])
 	dnl }}}
 	dnl Toolkit for Advanced Optimization (TAO){{{
-	AC_MSG_CHECKING([for TAO])
 	AC_ARG_WITH(
 		[tao-dir],
@@ -1612,4 +1486,6 @@
 		[TAO_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for TAO])
+
 	if test "x${HAVE_PETSC}" == "xyes" && test "x${PETSC_MAJOR}" == "x3" && test ${PETSC_MINOR} -ge 5; then
 		dnl In PETSc >= 3.5, TAO is provided
@@ -1639,5 +1515,4 @@
 	dnl }}}
 	dnl M1QN3{{{
-	AC_MSG_CHECKING([for M1QN3])
 	AC_ARG_WITH(
 		[m1qn3-dir],
@@ -1646,4 +1521,5 @@
 		[M1QN3_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for M1QN3])
 	if test "x${M1QN3_ROOT}" == "xno"; then
 		HAVE_M1QN3=no
@@ -1664,5 +1540,4 @@
 	dnl }}}
 	dnl PROJ{{{
-	AC_MSG_CHECKING([for PROJ])
 	AC_ARG_WITH(
 		[proj-dir],
@@ -1671,4 +1546,5 @@
 		[PROJ_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for PROJ])
 	if test "x${PROJ_ROOT}" == "xno"; then
 		HAVE_PROJ=no
@@ -1692,5 +1568,4 @@
 	dnl }}}
 	dnl SLEPc{{{
-	AC_MSG_CHECKING([for SLEPc])
 	AC_ARG_WITH(
 		[slepc-dir],
@@ -1699,4 +1574,5 @@
 		[SLEPC_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for SLEPc])
 	if test "x${SLEPC_ROOT}" == "xno"; then
 		HAVE_SLEPC=no
@@ -1719,5 +1595,4 @@
 	dnl }}}
 	dnl shapelib{{{
-	AC_MSG_CHECKING([for shapelib])
 	AC_ARG_WITH(
 		[shapelib-dir],
@@ -1726,4 +1601,5 @@
 		[SHAPELIB_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for shapelib])
 	if test "x${SHAPELIB_ROOT}" == "xno"; then
 		HAVE_SHAPELIB=no
@@ -1746,7 +1622,6 @@
 	dnl }}}
 	dnl ScaLAPACK{{{
+
 	dnl NOTE: User should supply path to root directory or libraries, but not both
-	dnl
-	AC_MSG_CHECKING([for ScaLAPACK])
 	AC_ARG_WITH(
 		[scalapack-dir],
@@ -1761,4 +1636,5 @@
 		[SCALAPACKLIB="no"]
 	)
+	AC_MSG_CHECKING([for ScaLAPACK])
 	if test "x${SCALAPACK_ROOT}" == "xno" && test "x${SCALAPACKLIB}" == "xno"; then
 		HAVE_SCALAPACK=no
@@ -1769,9 +1645,5 @@
 		fi
 		HAVE_SCALAPACK=yes
-		if test "${VENDOR}" == "win-msys2"; then
-			SCALAPACKLIB="-Wl,${SCALAPACK_ROOT}/lib/libscalapack.a"
-		else
-			SCALAPACKLIB="-L${SCALAPACK_ROOT}/lib -lscalapack"
-		fi
+		SCALAPACKLIB="-L${SCALAPACK_ROOT}/lib -lscalapack"
 	elif test "x${SCALAPACKLIB}" != "xno"; then
 		dnl Value of SCALAPACKLIB should be valid here, so no need to set it (as above)
@@ -1789,17 +1661,4 @@
 	dnl }}}
 	dnl BLAS/LAPACK{{{
-	AC_MSG_CHECKING([for BLAS/LAPACK])
-	AC_ARG_WITH(
-		[blas-dir],
-		[AS_HELP_STRING([--with-blas-dir=DIR], [BLAS root directory])],
-		[BLAS_ROOT=$withval],
-		[BLAS_ROOT="no"]
-	)
-	AC_ARG_WITH(
-		[lapack-dir],
-		[AS_HELP_STRING([--with-lapack-dir=DIR], [LAPACK root directory])],
-		[LAPACK_ROOT=$withval],
-		[LAPACK_ROOT="no"]
-	)
 	AC_ARG_WITH(
 		[blas-lapack-dir],
@@ -1808,12 +1667,11 @@
 		[BLASLAPACK_ROOT="no"]
 	)
-	if (test "x${BLAS_ROOT}" = "xno" || test "x${LAPACK_ROOT}" = "xno") && test "x${BLASLAPACK_ROOT}" = "xno"; then
+	AC_MSG_CHECKING([for BLAS/LAPACK])
+	if test "x${BLASLAPACK_ROOT}" == "xno" ; then
 		HAVE_BLASLAPACK=no
 	else
 		HAVE_BLASLAPACK=yes
-		if ! test -d "${BLAS_ROOT}" || ! test -d "${LAPACK_ROOT}"; then
-			if ! test -d "${BLASLAPACK_ROOT}"; then
-				AC_MSG_ERROR([Use either --with-blas-dir and --with-lapack-dir *or* --with-blaslapack-dir]);
-			fi
+		if ! test -d "${BLASLAPACK_ROOT}"; then
+			AC_MSG_ERROR([BLAS/LAPACK directory provided (${BLASLAPACK_ROOT}) does not exist!]);
 		fi
 	fi
@@ -1822,4 +1680,5 @@
 	dnl BLAS/LAPACK libraries and header files
 	if test "x${HAVE_BLASLAPACK}" == "xyes"; then
+		BLASLAPACKINCL=""
 		case "${host_os}" in
 			*cygwin*)
@@ -1850,42 +1709,11 @@
 				fi
 			;;
-			*mingw*)
-				if test -d "${BLASLAPACK_ROOT}"; then
-					BLASLAPACKLIB="-L${BLASLAPACK_ROOT}/lib"
-					if ls ${BLASLAPACK_ROOT}/lib/libopenblas.* 1> /dev/null 2>&1; then
-						BLASLAPACKLIB+=" -lopenblas"
-					elif ls ${BLASLAPACK_ROOT}/lib/libf2clapack.* 1> /dev/null 2>&1; then
-						BLASLAPACKLIB+=" -lf2clapack -lf2cblas"
-					elif ls ${BLASLAPACK_ROOT}/lib/libflapack.* 1> /dev/null 2>&1; then
-						BLASLAPACKLIB="-Wl,${BLASLAPACK_ROOT}/lib/libflapack.a -Wl,${BLASLAPACK_ROOT}/lib/libfblas.a"
-					else
-						BLASLAPACKLIB+=" -llapack -lblas"
-					fi
-				else
-					BLASLAPACKLIB="-Wl,${LAPACK_ROOT}/lib/liblapack.a -Wl,${BLAS_ROOT}/lib/libblas.a"
-				fi
-			;;
-			*msys*)
-				if test -d "${BLASLAPACK_ROOT}"; then
-					if ls ${BLASLAPACK_ROOT}/lib/libopenblas.* 1> /dev/null 2>&1; then
-						BLASLAPACKLIB=" -lopenblas"
-					elif ls ${BLASLAPACK_ROOT}/lib/libf2clapack.* 1> /dev/null 2>&1; then
-						BLASLAPACKLIB=" -lf2clapack -lf2cblas"
-					elif ls ${BLASLAPACK_ROOT}/lib/libflapack.* 1> /dev/null 2>&1; then
-						BLASLAPACKLIB+=" -lflapack -lfblas"
-					else
-						BLASLAPACKLIB=" -llapack -lblas"
-					fi
-				else
-					BLASLAPACKLIB="-L${LAPACK_ROOT}/lib -llapack -L${BLAS_ROOT}/lib -lblas"
-				fi
-			;;
 		esac
 		AC_DEFINE([_HAVE_BLASLAPACK_], [1], [with BLAS/LAPACK in ISSM src])
 		AC_SUBST([BLASLAPACKLIB])
+		AC_SUBST([BLASLAPACKINCL])
 	fi
 	dnl }}}
 	dnl Math Kernel Library (MKL){{{
-	AC_MSG_CHECKING([for MKL])
 	AC_ARG_WITH(
 		[mkl-libflags],
@@ -1894,4 +1722,5 @@
 		[MKL_LIBFLAGS="no"]
 	)
+	AC_MSG_CHECKING([for MKL])
 	if test "x${MKL_LIBFLAGS}" == "xno"; then
 		HAVE_MKL=no
@@ -1906,4 +1735,5 @@
 	dnl }}}
 	dnl PlaLAPACK{{{
+
 	dnl TODO: 	Handle user supplying path to root directory *or* individual
 	dnl 		arguments (like ScaLAPACK)
@@ -1940,5 +1770,4 @@
 	dnl }}}
 	dnl MUMPS{{{
-	AC_MSG_CHECKING([for MUMPS])
 	AC_ARG_WITH(
 		[mumps-dir],
@@ -1947,4 +1776,5 @@
 		[MUMPS_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for MUMPS])
 	if test "x${MUMPS_ROOT}" == "xno"; then
 		HAVE_MUMPS=no
@@ -1961,6 +1791,6 @@
 		MUMPSINCL="-I${MUMPS_ROOT}/include"
 		if test "x${MUMPS_ROOT}" == "x${PETSC_ROOT}"; then
-			if test "${VENDOR}" == "win-msys2"; then
-				MUMPSLIB="-Wl,${MUMPS_ROOT}/lib/libcmumps.a -Wl,${MUMPS_ROOT}/lib/libdmumps.a -Wl,${MUMPS_ROOT}/lib/libsmumps.a -Wl,${MUMPS_ROOT}/lib/libzmumps.a -Wl,${MUMPS_ROOT}/lib/libmumps_common.a -Wl,${MUMPS_ROOT}/lib/libpord.a"
+			if test "x${PETSC_MAJOR}" == "x2"; then
+				MUMPSLIB="-L${MUMPS_ROOT}/lib "
 			else
 				MUMPSLIB="-L${MUMPS_ROOT}/lib -ldmumps -lcmumps -lmumps_common -lpord -lparmetis -lzmumps -lmetis"
@@ -2011,5 +1841,4 @@
 	dnl }}}
 	dnl BLACS{{{
-	AC_MSG_CHECKING([for BLACS])
 	AC_ARG_WITH(
 		[blacs-dir],
@@ -2018,4 +1847,5 @@
 		[BLACS_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for BLACS])
 	if test "x${BLACS_ROOT}" == "xno"; then
 		HAVE_BLACS=no
@@ -2038,5 +1868,4 @@
 	dnl }}}
 	dnl HYPRE{{{
-	AC_MSG_CHECKING([for HYPRE])
 	AC_ARG_WITH(
 		[hypre-dir],
@@ -2045,4 +1874,5 @@
 		[HYPRE_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for HYPRE])
 	if test "x${HYPRE_ROOT}" == "xno"; then
 		HAVE_HYPRE=no
@@ -2065,5 +1895,4 @@
 	dnl }}}
 	dnl Prometheus{{{
-	AC_MSG_CHECKING([for Prometheus])
 	AC_ARG_WITH(
 		[prometheus-dir],
@@ -2072,4 +1901,5 @@
 		[PROMETHEUS_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for Prometheus])
 	if test "x${PROMETHEUS_ROOT}" == "xno"; then
 		HAVE_PROMETHEUS=no
@@ -2092,5 +1922,4 @@
 	dnl }}}
 	dnl SEMIC{{{
-	AC_MSG_CHECKING([for SEMIC])
 	AC_ARG_WITH(
 		[semic-dir],
@@ -2099,4 +1928,5 @@
 		[SEMIC_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for SEMIC])
 	if test "x${SEMIC_ROOT}" == "xno"; then
 		HAVE_SEMIC=no
@@ -2120,5 +1950,4 @@
 	dnl }}}
 	dnl SPAI{{{
-	AC_MSG_CHECKING([for SPAI])
 	AC_ARG_WITH(
 		[spai-dir],
@@ -2127,4 +1956,5 @@
 		[SPAI_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for SPAI])
 	if test "x${SPAI_ROOT}" == "xno"; then
 		HAVE_SPAI=no
@@ -2147,5 +1977,4 @@
 	dnl }}}
 	dnl SuperLU{{{
-	AC_MSG_CHECKING([for SuperLU])
 	AC_ARG_WITH(
 		[superlu-dir],
@@ -2154,4 +1983,5 @@
 		[SUPERLU_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for SuperLU])
 	if test "x${SUPERLU_ROOT}" == "xno"; then
 		HAVE_SUPERLU=no
@@ -2174,5 +2004,4 @@
 	dnl }}}
 	dnl SPOOLES{{{
-	AC_MSG_CHECKING([for SPOOLES])
 	AC_ARG_WITH(
 		[spooles-dir],
@@ -2181,4 +2010,5 @@
 		[SPOOLES_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for SPOOLES])
 	if test "x${SPOOLES_ROOT}" == "xno"; then
 		HAVE_SPOOLES=no
@@ -2201,5 +2031,4 @@
 	dnl }}}
 	dnl PaStiX{{{
-	AC_MSG_CHECKING([for PaStiX])
 	AC_ARG_WITH(
 		[pastix-dir],
@@ -2208,4 +2037,5 @@
 		[PASTIX_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for PaStiX])
 	if test "x${PASTIX_ROOT}" == "xno"; then
 		HAVE_PASTIX=no
@@ -2229,5 +2059,4 @@
 	dnl }}}
 	dnl ml{{{
-	AC_MSG_CHECKING([for ml])
 	AC_ARG_WITH(
 		[ml-dir],
@@ -2236,4 +2065,5 @@
 		[ML_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for ml])
 	if test "x${ML_ROOT}" == "xno"; then
 		HAVE_ML=no
@@ -2256,5 +2086,4 @@
 	dnl }}}
 	dnl UMFPACK{{{
-	AC_MSG_CHECKING([for UMFPACK])
 	AC_ARG_WITH(
 		[umfpack-dir],
@@ -2263,4 +2092,5 @@
 		[UMFPACK_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for UMFPACK])
 	if test "x${UMFPACK_ROOT}" == "xno"; then
 		HAVE_UMFPACK=no
@@ -2299,5 +2129,4 @@
 	dnl }}}
 	dnl MATH77{{{
-	AC_MSG_CHECKING([for MATH77])
 	AC_ARG_WITH(
 		[math77-dir],
@@ -2306,4 +2135,5 @@
 		[MATH77_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for MATH77])
 	if test "x${MATH77_ROOT}" == "xno"; then
 		HAVE_MATH77=no
@@ -2324,5 +2154,4 @@
 	dnl }}}
 	dnl Fortran{{{
-	AC_MSG_CHECKING(for Fortran compilation)
 	AC_ARG_WITH(
 		[fortran],
@@ -2331,4 +2160,5 @@
 		[FORTRAN=yes]
 	)
+	AC_MSG_CHECKING(for Fortran compilation)
 	if test "x${FORTRAN}" == "xyes"; then
 		HAVE_FORTRAN=yes
@@ -2394,5 +2224,4 @@
 	dnl }}}
 	dnl MeteoIO{{{
-	AC_MSG_CHECKING([for MeteoIO])
 	AC_ARG_WITH(
 		[meteoio-dir],
@@ -2401,4 +2230,5 @@
 		[METEOIO_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for MeteoIO])
 	if test "x${METEOIO_ROOT}" == "xno"; then
 		HAVE_METEOIO=no
@@ -2423,5 +2253,4 @@
 	dnl }}}
 	dnl SNOWPACK{{{
-	AC_MSG_CHECKING([for SNOWPACK])
 	AC_ARG_WITH(
 		[snowpack-dir],
@@ -2430,4 +2259,5 @@
 		[SNOWPACK_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for SNOWPACK])
 	if test "x${SNOWPACK_ROOT}" == "xno"; then
 		HAVE_SNOWPACK=no
@@ -2451,5 +2281,4 @@
 	dnl }}}
 	dnl NeoPZ{{{
-	AC_MSG_CHECKING([for NeoPZ])
 	AC_ARG_WITH(
 		[neopz-dir],
@@ -2458,4 +2287,5 @@
 		[NEOPZ_ROOT="no"]
 	)
+	AC_MSG_CHECKING([for NeoPZ])
 	if test "x${NEOPZ_ROOT}" == "xno"; then
 		HAVE_NEOPZ=no
@@ -2526,10 +2356,9 @@
 		GMSH_VERSION_MAJOR=`${GMSH_ROOT}/bin/gmsh -info | grep "Version" | sed -e "s/Version@<:@@<:@:blank:@:>@@:>@*:@<:@@<:@:blank:@:>@@:>@//" | cut -d "." -f 1`
 		AC_MSG_RESULT([${GMSH_VERSION_MAJOR}])
-		AC_DEFINE_UNQUOTED([_GMSH_VERSION_MAJOR_], ${GMSH_VERSION_MAJOR}, [Gmsh major version])
+		AC_DEFINE_UNQUOTED(_GMSH_VERSION_MAJOR_, $GMSH_VERSION_MAJOR, [Gmsh major version])
 	fi	
 	dnl }}}
 	dnl Capabilities
 	dnl with-bamg{{{
-	AC_MSG_CHECKING([for BAMG capability compilation])
 	AC_ARG_WITH(
 		[bamg],
@@ -2538,4 +2367,5 @@
 		[BAMG=yes]
 	)
+	AC_MSG_CHECKING([for BAMG capability compilation])
 	HAVE_BAMG=no
 	if test "x${BAMG}" == "xyes"; then
@@ -2547,5 +2377,4 @@
 	dnl }}}
 	dnl with-ocean{{{
-	AC_MSG_CHECKING(for ice/ocean coupling capability compilation)
 	AC_ARG_WITH(
 		[ocean],
@@ -2554,4 +2383,6 @@
 		[OCEAN=no]
 	)
+	AC_MSG_CHECKING(for ice/ocean coupling capability compilation)
+
 	HAVE_OCEAN=no
 	if test "x${OCEAN}" == "xyes"; then
@@ -2563,5 +2394,4 @@
 	dnl }}}
 	dnl with-kml{{{
-	AC_MSG_CHECKING(for kml capability compilation)
 	AC_ARG_WITH(
 		[kml],
@@ -2570,4 +2400,6 @@
 		[KML=no]
 	)
+	AC_MSG_CHECKING(for kml capability compilation)
+
 	HAVE_KML=no
 	if test "x${KML}" == "xyes"; then
@@ -2579,5 +2411,4 @@
 	dnl }}}
 	dnl with-kriging{{{
-	AC_MSG_CHECKING(for kriging capability compilation)
 	AC_ARG_WITH(
 		[kriging],
@@ -2586,4 +2417,6 @@
 		[KRIGING=yes]
 	)
+	AC_MSG_CHECKING(for kriging capability compilation)
+
 	HAVE_KRIGING=no
 	if test "x${KRIGING}" == "xyes"; then
@@ -2600,5 +2433,4 @@
 	dnl Platform specifics
 	dnl with-ios{{{
-	AC_MSG_CHECKING(for iOS compilation)
 	AC_ARG_WITH(
 		[ios],
@@ -2607,4 +2439,6 @@
 		[IOS=no]
 	)
+	AC_MSG_CHECKING(for iOS compilation)
+
 	HAVE_IOS=no
 	if test "x${IOS}" == "xyes"; then
@@ -2616,11 +2450,11 @@
 	dnl }}}
 	dnl with-android{{{
-	AC_MSG_CHECKING([for Android capability compilation])
 	AC_ARG_WITH(
 		[android],
 		AS_HELP_STRING([--with-android=EXE], [compile with Android capabilities (default: "no"; alternatives: "exe", "jni")]),
 		[ANDROID=${withval}],
-		[ANDROID=no]
-	)
+		[ANDROID=no])
+	AC_MSG_CHECKING([for Android capability compilation])
+
 	if test "x${ANDROID}" == "xjni"; then
 		HAVE_ANDROID=jni
@@ -2641,5 +2475,4 @@
 	dnl }}}
 	dnl with-android-ndk{{{
-	AC_MSG_CHECKING([with Android Native Development Kit (NDK)])
 	AC_ARG_WITH(
 		[android-ndk],
@@ -2648,4 +2481,6 @@
 		[ANDROID_NDK_ROOT=""]
 	)
+	AC_MSG_CHECKING([with Android Native Development Kit (NDK)])
+
 	if test -d "${ANDROID_NDK_ROOT}"; then
 		HAVE_ANDROID_NDK=yes
@@ -2661,17 +2496,16 @@
 	dnl other options
 	dnl optimization{{{
-	dnl -- bypass standard optimization -g -O2 -fPIC?
-	AC_MSG_CHECKING(for C++ optimization flags)
+	dnl -- bypass standard optimization -g -O2 -fPIC -std=c++11?
 	AC_ARG_WITH(
 		[cxxoptflags],
 		AS_HELP_STRING([--with-cxxoptflags=CXXOPTFLAGS], [C++ optimization flags (i.e. --with-cxxoptflags="-march=opteron -O3 -std=c++11"]),
 		[CXXOPTFLAGS=${withval}],
-		[CXXOPTFLAGS="-g -O2 -fPIC"]
-	)
+		[CXXOPTFLAGS="-g -O2 -fPIC -std=c++11"]
+	)
+	AC_MSG_CHECKING(for C++ optimization flags)
 	AC_SUBST([CXXOPTFLAGS])
-	AC_MSG_RESULT([${CXXOPTFLAGS}])
+	AC_MSG_RESULT([done])
 	dnl }}}
 	dnl multithreading{{{
-	AC_MSG_CHECKING(for number of threads)
 	AC_ARG_WITH(
 		[numthreads],
@@ -2680,4 +2514,5 @@
 		[NUMTHREADS_VALUE=1]
 	)
+	AC_MSG_CHECKING(for number of threads)
 	dnl Check that supplied value is an integer
 	if [[ "${NUMTHREADS_VALUE}" != "${NUMTHREADS_VALUE}" 2> /dev/null ]]; then
@@ -2694,25 +2529,18 @@
 				MULTITHREADINGLIB="-lpthread -lrt"
 			;;
+			*linux*)
+				MULTITHREADINGLIB="-lpthread -lrt"
+			;;
 			*darwin*)
 				MULTITHREADINGLIB="-lpthread"
 			;;
-			*linux*)
-				MULTITHREADINGLIB="-lpthread -lrt"
-			;;
-			*mingw*)
-				MULTITHREADINGLIB=""
-			;;
-			*msys*)
-				MULTITHREADINGLIB=""
-			;;
 		esac
 		AC_DEFINE([_MULTITHREADING_], [1], [with multithreading enabled])
 	fi
-	AC_DEFINE_UNQUOTED([_NUMTHREADS_], ${NUMTHREADS_VALUE}, [number of threads])
+	AC_DEFINE_UNQUOTED(_NUMTHREADS_, $NUMTHREADS_VALUE, [number of threads])
 	AC_SUBST([MULTITHREADINGLIB])
 	AC_MSG_RESULT([${NUMTHREADS_VALUE}])
 	dnl }}}
 	dnl 64-bit indices{{{
-	AC_MSG_CHECKING([for 64-bit indices])
 	AC_ARG_WITH(
 		[64bit-indices],
@@ -2721,4 +2549,6 @@
 		[USE_64BIT_INDICES=0]
 	)
+	AC_MSG_CHECKING([for 64-bit indices])
+
 	if test "x${USE_64BIT_INDICES}" == "x1"; then
 		AC_DEFINE([ISSM_USE_64BIT_INDICES], [1], [with 64-bit indices])
@@ -2730,5 +2560,5 @@
 
 	dnl Checks {{{
-	AC_MSG_CHECKING(consistency between all external packages)
+	AC_MSG_CHECKING(consistency between all libraries)
 
 	dnl Check that if PETSc is requested, MPI is specified
@@ -2760,5 +2590,5 @@
 
 	dnl Check that if we run ADOL-C, we don't compile kriging.exe
-	if test "x${HAVE_ADOLC}" == "xyes" && test "${HAVE_KRIGING}" == "xyes"; then
+	if test "x$HAVE_ADOLC" == "xyes" && test "${HAVE_KRIGING}" == "xyes"; then
 		AC_MSG_ERROR([cannot compile kriging.exe under ADOL-C conditions!]);
 	fi
