Index: /issm/trunk-jpl/m4/issm_options.m4
===================================================================
--- /issm/trunk-jpl/m4/issm_options.m4	(revision 15671)
+++ /issm/trunk-jpl/m4/issm_options.m4	(revision 15672)
@@ -99,14 +99,15 @@
 	AC_ARG_WITH([matlab-dir],
 		AS_HELP_STRING([--with-matlab-dir=DIR], [matlab root directory. necessary for serial build.]),
-		[MATLAB_ROOT=$withval],[MATLAB_ROOT=""]) 
+		[MATLAB_ROOT=$withval],[MATLAB_ROOT="no"]) 
 
 	AC_MSG_CHECKING([whether matlab is enabled])
-	if test -d "$MATLAB_ROOT"; then
+	if test "x$MATLAB_ROOT" = "xno" ; then
+		 HAVE_MATLAB=no
+	else
 		HAVE_MATLAB=yes
-	else
-		HAVE_MATLAB=no
-	fi
-	if test x$HAVE_MATLAB = xyes; then
-		AC_DEFINE([_HAVE_MATLAB_],[1],[with Matlab in ISSM src])
+		if ! test -d "$MATLAB_ROOT"; then
+		  AC_MSG_ERROR([matlab directory provided ($MATLAB_ROOT) does not exist]);
+		fi
+		AC_DEFINE([_HAVE_MATLAB_],[1],[with matlab in ISSM src])
 	fi
 	AC_MSG_RESULT($HAVE_MATLAB)
@@ -114,11 +115,10 @@
 
 	dnl 2. Get Matlab libraries
-	if test x$HAVE_MATLAB = xyes; then
+	if test "x$HAVE_MATLAB" = "xyes"; then
 
 		AC_MSG_CHECKING(for matlab headers and libraries in $MATLAB_ROOT)
   		MATLABINCL="-I$MATLAB_ROOT/extern/include/"
 		
-		dnl 4. get MEXLIB MEXLINK and MEXEXT (experimental)
-      dnl OS-dependent variables and checks
+		dnl 4. get MEXLIB MEXLINK and MEXEXT (experimental) except for windows
   		case "${host_os}" in
   			*cygwin*) 
@@ -140,5 +140,4 @@
       esac
 	   AC_MSG_RESULT(done)
-
 		AC_SUBST([MATLABINCL])
 		AC_SUBST([MEX])
@@ -152,13 +151,23 @@
 	AC_ARG_WITH([triangle-dir],
 			  AS_HELP_STRING([--with-triangle-dir=DIR], [triangle root directory. necessary for serial build]),
-			 [TRIANGLE_ROOT=$withval],[TRIANGLE_ROOT=""]) 
-	AC_MSG_CHECKING(for triangle headers and libraries)
-
-	if test -d "$TRIANGLE_ROOT"; then
-
-		dnl defaults
+			 [TRIANGLE_ROOT=$withval],[TRIANGLE_ROOT="no"]) 
+
+  dnl Check whether triangle is enabled
+	AC_MSG_CHECKING([for triangle])
+	if test "x$TRIANGLE_ROOT" = "xno" ; then
+		HAVE_TRIANGLE=no
+	else
 		HAVE_TRIANGLE=yes
+		if ! test -d "$TRIANGLE_ROOT"; then
+			AC_MSG_ERROR([triangle directory provided ($TRIANGLE_ROOT) does not exist]);
+		fi
+		AC_DEFINE([_HAVE_TRIANGLE_],[1],[with triangle in ISSM src])
+	fi
+	AC_MSG_RESULT($HAVE_TRIANGLE)
+	AM_CONDITIONAL([TRIANGLE],[test x$HAVE_TRIANGLE = xyes])
+
+	dnl library and header files
+	if test "x$HAVE_TRIANGLE" = "xyes"; then
 		TRIANGLEINCL=-I$TRIANGLE_ROOT/
-
 		case "${host_os}" in
 				*cygwin*)
@@ -172,34 +181,36 @@
 				;;
 			esac
-
 		AC_DEFINE([_HAVE_TRIANGLE_],[1],[with Triangle in ISSM src])
 		AC_SUBST([TRIANGLEINCL])
 		AC_SUBST([TRIANGLELIB])
-
-	else
-		HAVE_TRIANGLE=no
-	fi
-	AC_MSG_RESULT($HAVE_TRIANGLE)
+	fi
 	dnl }}}
 	dnl boost{{{
 	AC_ARG_WITH([boost-dir],
 	  AS_HELP_STRING([--with-boost-dir=DIR], [boost root directory.]),
-	  [BOOST_ROOT=$withval],[BOOST_ROOT=""]) 
-	AC_MSG_CHECKING(for boost)
-	
-	if test -d "$BOOST_ROOT"; then
-		dnl defaults
+	  [BOOST_ROOT=$withval],[BOOST_ROOT="no"]) 
+
+	dnl Check whether boost is enabled
+	AC_MSG_CHECKING([for boost])
+	if test "x$BOOST_ROOT" = "xno" ; then
+		HAVE_BOOST=no
+	else
 		HAVE_BOOST=yes
+		if ! test -d "$BOOST_ROOT"; then
+			AC_MSG_ERROR([boost directory provided ($BOOST_ROOT) does not exist]);
+		fi
+		AC_DEFINE([_HAVE_BOOST_],[1],[with boost in ISSM src])
+	fi
+	AC_MSG_RESULT($HAVE_BOOST)
+	AM_CONDITIONAL([BOOST],[test x$HAVE_BOOST = xyes])
+
+	dnl library and header files
+	if test "x$HAVE_BOOST" = "xyes"; then
 		BOOSTINCL=-I$BOOST_ROOT/include
 		BOOSTLIB="-L$BOOST_ROOT/lib -lboost_python"
-
 		AC_DEFINE([_HAVE_BOOST_],[1],[with Boost in ISSM src])
 		AC_SUBST([BOOSTINCL])
 		AC_SUBST([BOOSTLIB])
-	else
-		HAVE_BOOST=no
-	fi
-	AM_CONDITIONAL([BOOST], [test x$HAVE_BOOST = xyes])
-	AC_MSG_RESULT($HAVE_BOOST)
+	fi
 	dnl }}}
 	dnl dakota{{{
@@ -207,12 +218,23 @@
 	  AS_HELP_STRING([--with-dakota-dir=DIR], [dakota root directory. necessary for serial build]),
 	  [DAKOTA_ROOT=$withval],[DAKOTA_ROOT=""]) 
-	AC_MSG_CHECKING(for dakota)
 	
-	if test -d "$DAKOTA_ROOT"; then
-
-		dnl defaults
+	dnl Check whether dakota is enabled
+	AC_MSG_CHECKING([for dakota])
+	if test "x$DAKOTA_ROOT" = "xno" ; then
+		HAVE_DAKOTA=no
+	else
 		HAVE_DAKOTA=yes
-		AC_MSG_RESULT($HAVE_DAKOTA)
+		if ! test -d "$DAKOTA_ROOT"; then
+			AC_MSG_ERROR([dakota directory provided ($DAKOTA_ROOT) does not exist]);
+		fi
+		AC_DEFINE([_HAVE_DAKOTA_],[1],[with dakota in ISSM src])
+	fi
+	AC_MSG_RESULT($HAVE_DAKOTA)
+	AM_CONDITIONAL([DAKOTA],[test x$HAVE_DAKOTA = xyes])
+
+	dnl library and header files
+	if test "x$HAVE_DAKOTA" = "xyes"; then
 		DAKOTAINCL=-I$DAKOTA_ROOT/include
+
 		AC_MSG_CHECKING(for dakota version)
 		if test -f "$DAKOTA_ROOT/../src/src/CommandLineHandler.C"; then
@@ -224,7 +246,7 @@
 		fi
 		fi
-
 		AC_MSG_RESULT($DAKOTA_VERSION)
 		AC_DEFINE_UNQUOTED([_DAKOTA_VERSION_],"$DAKOTA_VERSION",[Dakota version number])
+
 		DAKOTAFLAGS=""
 		case "${host_os}" in
@@ -301,11 +323,5 @@
 		AC_SUBST([DAKOTAFLAGS])
 		AC_SUBST([DAKOTALIB])
-
-	else
-		HAVE_DAKOTA=no
-		AC_MSG_RESULT($HAVE_DAKOTA)
-	fi
-
-	AM_CONDITIONAL([DAKOTA], [test x$HAVE_DAKOTA = xyes])
+	fi
 	dnl }}}
 	dnl python{{{
@@ -535,23 +551,20 @@
 		HAVE_GSL=no
 	else
-		if test -d "$GSL_ROOT"; then
-
-			dnl defaults
-			HAVE_GSL=yes
-			GSLINCL="-I$GSL_ROOT/include"
-
-			if test "x$HAVE_ATLAS" = "xyes" ; then
-				GSLLIB="-dy -L$GSL_ROOT/lib -lgsl -L$ATLAS_ROOT/lib -lcblas -latlas -lm"
-			else
-				GSLLIB="-dy -L$GSL_ROOT/lib -lgsl -lgslcblas -lm"
-			fi
-
-			AC_DEFINE([_HAVE_GSL_],[1],[with gsl in ISSM src])
-			AC_SUBST([GSLINCL])
-			AC_SUBST([GSLLIB])
-
+		if ! test -d "$GSL_ROOT"; then
+			AC_MSG_ERROR([gsl directory provided ($GSL_ROOT) does not exist]);
+		fi
+
+		HAVE_GSL=yes
+		GSLINCL="-I$GSL_ROOT/include"
+
+		if test "x$HAVE_ATLAS" = "xyes" ; then
+			GSLLIB="-dy -L$GSL_ROOT/lib -lgsl -L$ATLAS_ROOT/lib -lcblas -latlas -lm"
 		else
-			AC_MSG_ERROR([gsl directory provided ($GSL_ROOT) does not exist]);
-		fi
+			GSLLIB="-dy -L$GSL_ROOT/lib -lgsl -lgslcblas -lm"
+		fi
+
+		AC_DEFINE([_HAVE_GSL_],[1],[with gsl in ISSM src])
+		AC_SUBST([GSLINCL])
+		AC_SUBST([GSLLIB])
 	fi
 	AM_CONDITIONAL([GSL], [test x$HAVE_GSL = xyes])
@@ -1195,4 +1208,22 @@
 	AC_MSG_RESULT(done)
 	dnl }}}
+	dnl math77{{{
+		AC_ARG_WITH([math77-dir],
+					AS_HELP_STRING([--with-math77-dir=DIR], [math77 root directory.]),
+					[MATH77_ROOT=$withval],[MATH77_ROOT=""]) 
+		  AC_MSG_CHECKING(for math77)
+
+		  if test -d "$MATH77_ROOT"; then
+
+			HAVE_MATH77=yes
+			  MATH77LIB="-L$MATH77_ROOT/ -lmath77"
+
+			  AC_DEFINE([_HAVE_MATH77_],[1],[with math77 in ISSM src])
+			  AC_SUBST([MATH77LIB])
+		  else
+			HAVE_MATH77=no
+			  fi
+			  AC_MSG_RESULT($HAVE_MATH77)
+			  dnl }}}
 	dnl fortran{{{
 	AC_ARG_WITH([fortran],
@@ -1513,22 +1544,4 @@
 	AC_MSG_RESULT($HAVE_RIFTS)
 	dnl }}}
-	dnl math77{{{
-	AC_ARG_WITH([math77-dir],
-		AS_HELP_STRING([--with-math77-dir=DIR], [math77 root directory.]),
-		[MATH77_ROOT=$withval],[MATH77_ROOT=""]) 
-	AC_MSG_CHECKING(for math77)
-
-	if test -d "$MATH77_ROOT"; then
-
-	  HAVE_MATH77=yes
-	  MATH77LIB="-L$MATH77_ROOT/ -lmath77"
-
-	  AC_DEFINE([_HAVE_MATH77_],[1],[with math77 in ISSM src])
-	  AC_SUBST([MATH77LIB])
-	else
-		HAVE_MATH77=no
-	fi
-	AC_MSG_RESULT($HAVE_MATH77)
-	dnl }}}
 	dnl with-gia{{{
 	AC_ARG_WITH([gia],
@@ -1635,26 +1648,4 @@
 	AM_CONDITIONAL([THREED], [test x$HAVE_3D = xyes])
 	AC_MSG_RESULT($HAVE_3D)
-	dnl }}}
-	dnl checks{{{
-	AC_MSG_CHECKING(consistency between all libraries)
-	
-	dnl check that if petsc is requested , mpi should be specified
-	if test "$HAVE_PETSC" = "yes" ; then
-		if test "$HAVE_MPI" = "NO";  then
-			AC_MSG_ERROR([petsc requires mpi!]);
-		fi
-	fi
-
-	dnl check that we have either python or matlab support if we compile the modules
-	if test "$MODULES_VALUE" = "yes"  && test "$HAVE_MATLAB" = "no" && test "$HAVE_PYTHON" = "no"; then
-		AC_MSG_ERROR([need at least python or matlab support to compile modules (or use --with-modules=no)]);
-	fi
-
-	dnl check that if we have MPI, we have metis
-	if test "$HAVE_METIS" = "yes"  && test "$HAVE_MPI" = "no" ; then
-	AC_MSG_ERROR([need mpi if using the metis partitioner!]);
-	fi
-
-	AC_MSG_RESULT(done)
 	dnl }}}
 
@@ -1712,3 +1703,27 @@
 	AC_MSG_RESULT($USE_64BIT_INDICES)
 	dnl }}}
+
+	dnl Checks
+	dnl checks{{{
+		AC_MSG_CHECKING(consistency between all libraries)
+
+		  dnl check that if petsc is requested , mpi should be specified
+		  if test "$HAVE_PETSC" = "yes" ; then
+			if test "$HAVE_MPI" = "NO";  then
+			 AC_MSG_ERROR([petsc requires mpi!]);
+		fi
+		  fi
+
+		  dnl check that we have either python or matlab support if we compile the modules
+		  if test "$MODULES_VALUE" = "yes"  && test "$HAVE_MATLAB" = "no" && test "$HAVE_PYTHON" = "no"; then
+			AC_MSG_ERROR([need at least python or matlab support to compile modules (or use --with-modules=no)]);
+		fi
+
+		  dnl check that if we have MPI, we have metis
+		  if test "$HAVE_METIS" = "yes"  && test "$HAVE_MPI" = "no" ; then
+			AC_MSG_ERROR([need mpi if using the metis partitioner!]);
+		fi
+
+		  AC_MSG_RESULT(done)
+		  dnl }}}
 ])
