Index: issm/trunk-jpl/src/modules/matlab/Makefile.am
===================================================================
--- issm/trunk-jpl/src/modules/matlab/Makefile.am	(revision 13055)
+++ issm/trunk-jpl/src/modules/matlab/Makefile.am	(revision 13072)
@@ -1,45 +1,55 @@
 AM_CPPFLAGS = @DAKOTAINCL@ @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
+
 EXEEXT=$(MATLABWRAPPEREXT)
-#Bin programs {{{1
+
+#Modules {{{1
 if MODULES
-bin_PROGRAMS =  AverageFilter\
-				BamgMesher\
-				BamgConvertMesh\
-				BamgTriangulate\
-				Chaco\
-				ContourToMesh \
-				ContourToNodes \
-				ElementConnectivity\
-				EnumToString\
-				Exp2Kml \
-				HoleFiller \
-				InternalFront\
-				InterpFromGridToMesh \
-				InterpFromMeshToMesh2d \
-				InterpFromMeshToMesh3d \
-				InterpFromMeshToGrid \
-				InterpFromMesh2d \
-				KMLFileRead \
-				KMLMeshWrite \
-				KMLOverlay \
-				Kml2Exp \
-				Kriging \
-				Ll2xy \
-				NodeConnectivity \
-				MeshPartition\
-				MeshProfileIntersection\
-				PointCloudFindNeighbors\
-				PropagateFlagsFromConnectivity\
-				Scotch\
-				Shp2Kml\
-				StringToEnum\
-				TriaSearch\
-				TriMesh\
-				TriMeshProcessRifts\
-				Xy2ll
+lib_LTLIBRARIES =  AverageFilter.la\
+			       BamgMesher.la\
+				   BamgConvertMesh.la\
+				   BamgTriangulate.la\
+				   ContourToMesh.la\
+				   ContourToNodes.la\
+				   ElementConnectivity.la\
+				   EnumToString.la\
+				   Exp2Kml.la\
+				   HoleFiller.la\
+				   InternalFront.la\
+				   InterpFromGridToMesh.la\
+				   InterpFromMeshToMesh2d.la\
+				   InterpFromMeshToMesh3d.la\
+				   InterpFromMeshToGrid.la\
+				   InterpFromMesh2d.la\
+				   KMLFileRead.la\
+				   KMLMeshWrite.la\
+				   KMLOverlay.la\
+				   Kml2Exp.la\
+				   Kriging.la\
+				   Ll2xy.la\
+				   NodeConnectivity.la\
+				   MeshPartition.la\
+				   MeshProfileIntersection.la\
+				   PointCloudFindNeighbors.la\
+				   PropagateFlagsFromConnectivity.la\
+				   Shp2Kml.la\
+				   StringToEnum.la\
+				   TriaSearch.la\
+				   TriMesh.la\
+				   TriMeshProcessRifts.la\
+				   Scotch.la\
+				   Xy2ll.la\
+                   Chaco.la
 endif 
 #}}}
 #Flags and libraries {{{1
-LDADD = ../../c/libISSMCore.a ../../c/libISSMModules.a $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(SPOOLESLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
+if SHAREDLIBS
+deps = ../../c/libISSMCore.la ../../c/libISSMModules.la
+else
+deps = ../../c/libISSMCore.a ../../c/libISSMModules.a
+endif
+
+deps +=  $(MATHLIB) ${MEXLIB}
+
+#$(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(SPOOLESLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB) 
 
 #Triangle library
@@ -47,120 +57,176 @@
 
 #Matlab part
-AM_LDFLAGS   = $(MEXLINK)
+AM_LDFLAGS = $(MEXLINK) -shrext ${EXEEXT} -module
+if VERSION
+AM_LDFLAGS +=
+else
+AM_LDFLAGS += -avoid-version
+endif
+if SHAREDLIBS
+deps += ../../c/libISSMMatlab.la 
+else
+deps += ../../c/libISSMMatlab.a
+AM_LDFLAGS += --no-warnings 
+endif
+
 AM_CXXFLAGS +=  -D_HAVE_MATLAB_MODULES_ -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread 
-LDADD       += $(MEXLIB) ../../c/libISSMMatlab.a 
-LDADD       += ../../c/libISSMCore.a 
-if CIRCULAR_DEPENDENCIES
-LDADD       += $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(SPOOLESLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
-endif
-LDADD       += ../../c/libISSMModules.a
+
+######################################################################################
+# Circular dependencies may not be necessary here.
+#deps += ../../c/libISSMCore.a 
+#if CIRCULAR_DEPENDENCIES
+#deps += $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(SPOOLESLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
+#endif
+######################################################################################
+
+if SHAREDLIBS
+deps +=
+else
+deps += ../../c/libISSMModules.a ../../c/libISSMCore.a
+endif
 
 #Optimization flags:
 AM_CXXFLAGS += $(CXXOPTFLAGS) 
 #}}}
+
 #Bin sources {{{1
-AverageFilter_SOURCES = ../AverageFilter/AverageFilter.cpp\
+AverageFilter_la_SOURCES = ../AverageFilter/AverageFilter.cpp\
 			  ../AverageFilter/AverageFilter.h
-
-BamgMesher_SOURCES = ../BamgMesher/BamgMesher.cpp\
+AverageFilter_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+BamgMesher_la_SOURCES = ../BamgMesher/BamgMesher.cpp\
 					../BamgMesher/BamgMesher.h
-
-BamgConvertMesh_SOURCES = ../BamgConvertMesh/BamgConvertMesh.cpp\
+BamgMesher_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+BamgConvertMesh_la_SOURCES = ../BamgConvertMesh/BamgConvertMesh.cpp\
 					../BamgConvertMesh/BamgConvertMesh.h
-
-BamgTriangulate_SOURCES = ../BamgTriangulate/BamgTriangulate.cpp\
+BamgConvertMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+BamgTriangulate_la_SOURCES = ../BamgTriangulate/BamgTriangulate.cpp\
 								  ../BamgTriangulate/BamgTriangulate.h
-
-Chaco_SOURCES = ../Chaco/Chaco.cpp\
+BamgTriangulate_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+Chaco_la_SOURCES = ../Chaco/Chaco.cpp\
 					../Chaco/Chaco.h
-
-ContourToMesh_SOURCES = ../ContourToMesh/ContourToMesh.cpp\
-			  ../ContourToMesh/ContourToMesh.h
-
-ContourToNodes_SOURCES = ../ContourToNodes/ContourToNodes.cpp\
+Chaco_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(CHACOLIB)
+
+ContourToMesh_la_SOURCES = ../ContourToMesh/ContourToMesh.cpp\
+			               ../ContourToMesh/ContourToMesh.h
+ContourToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB)
+
+ContourToNodes_la_SOURCES = ../ContourToNodes/ContourToNodes.cpp\
 			  ../ContourToNodes/ContourToNodes.h
-
-ElementConnectivity_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp\
+ContourToNodes_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+ElementConnectivity_la_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp\
 			  ../ElementConnectivity/ElementConnectivity.h
-
-EnumToString_SOURCES = ../EnumToString/EnumToString.cpp\
+ElementConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+EnumToString_la_SOURCES = ../EnumToString/EnumToString.cpp\
 			  ../EnumToString/EnumToString.h
-
-StringToEnum_SOURCES = ../StringToEnum/StringToEnum.cpp\
+EnumToString_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+StringToEnum_la_SOURCES = ../StringToEnum/StringToEnum.cpp\
 			  ../StringToEnum/StringToEnum.h
-
-HoleFiller_SOURCES = ../HoleFiller/HoleFiller.cpp\
+StringToEnum_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+HoleFiller_la_SOURCES = ../HoleFiller/HoleFiller.cpp\
 			  ../HoleFiller/HoleFiller.h
-
-InternalFront_SOURCES = ../InternalFront/InternalFront.cpp\
+HoleFiller_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) 
+
+InternalFront_la_SOURCES = ../InternalFront/InternalFront.cpp\
 										 ../InternalFront/InternalFront.h
-
-InterpFromGridToMesh_SOURCES = ../InterpFromGridToMesh/InterpFromGridToMesh.cpp\
+InternalFront_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+InterpFromGridToMesh_la_SOURCES = ../InterpFromGridToMesh/InterpFromGridToMesh.cpp\
 			  ../InterpFromGridToMesh/InterpFromGridToMesh.h
-
-InterpFromMeshToMesh2d_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\
+InterpFromGridToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB)
+
+InterpFromMeshToMesh2d_la_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\
 							../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
-
-InterpFromMeshToMesh3d_SOURCES = ../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp\
+InterpFromMeshToMesh2d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB)
+
+InterpFromMeshToMesh3d_la_SOURCES = ../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp\
 									../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h
-
-InterpFromMeshToGrid_SOURCES = ../InterpFromMeshToGrid/InterpFromMeshToGrid.cpp\
+InterpFromMeshToMesh3d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+InterpFromMeshToGrid_la_SOURCES = ../InterpFromMeshToGrid/InterpFromMeshToGrid.cpp\
 									../InterpFromMeshToGrid/InterpFromMeshToGrid.h
-
-InterpFromMesh2d_SOURCES = ../InterpFromMesh2d/InterpFromMesh2d.cpp\
+InterpFromMeshToGrid_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+InterpFromMesh2d_la_SOURCES = ../InterpFromMesh2d/InterpFromMesh2d.cpp\
 									../InterpFromMesh2d/InterpFromMesh2d.h
-
-KMLFileRead_SOURCES = ../KMLFileRead/KMLFileRead.cpp\
+InterpFromMesh2d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB)
+
+KMLFileRead_la_SOURCES = ../KMLFileRead/KMLFileRead.cpp\
 			  ../KMLFileRead/KMLFileRead.h
-
-KMLMeshWrite_SOURCES = ../KMLMeshWrite/KMLMeshWrite.cpp\
+KMLFileRead_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+KMLMeshWrite_la_SOURCES = ../KMLMeshWrite/KMLMeshWrite.cpp\
 			  ../KMLMeshWrite/KMLMeshWrite.h
-
-KMLOverlay_SOURCES = ../KMLOverlay/KMLOverlay.cpp\
+KMLMeshWrite_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+KMLOverlay_la_SOURCES = ../KMLOverlay/KMLOverlay.cpp\
 			  ../KMLOverlay/KMLOverlay.h
-
-Xy2ll_SOURCES = ../Xy2ll/Xy2ll.cpp\
+KMLOverlay_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+Xy2ll_la_SOURCES = ../Xy2ll/Xy2ll.cpp\
 			  ../Xy2ll/Xy2ll.h
-
-Ll2xy_SOURCES = ../Ll2xy/Ll2xy.cpp\
+Xy2ll_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+Ll2xy_la_SOURCES = ../Ll2xy/Ll2xy.cpp\
 			  ../Ll2xy/Ll2xy.h
-
-Exp2Kml_SOURCES = ../Exp2Kml/Exp2Kml.cpp\
+Ll2xy_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+Exp2Kml_la_SOURCES = ../Exp2Kml/Exp2Kml.cpp\
 			  ../Exp2Kml/Exp2Kml.h
-
-Kml2Exp_SOURCES = ../Kml2Exp/Kml2Exp.cpp\
+Exp2Kml_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+Kml2Exp_la_SOURCES = ../Kml2Exp/Kml2Exp.cpp\
 			  ../Kml2Exp/Kml2Exp.h
-
-Kriging_SOURCES = ../Kriging/Kriging.cpp\
+Kml2Exp_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+Kriging_la_SOURCES = ../Kriging/Kriging.cpp\
 						../Kriging/Kriging.h
-
-MeshPartition_SOURCES = ../MeshPartition/MeshPartition.cpp\
+Kriging_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB)
+
+MeshPartition_la_SOURCES = ../MeshPartition/MeshPartition.cpp\
 			  ../MeshPartition/MeshPartition.h
-
-MeshProfileIntersection_SOURCES = ../MeshProfileIntersection/MeshProfileIntersection.cpp\
+MeshPartition_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+MeshProfileIntersection_la_SOURCES = ../MeshProfileIntersection/MeshProfileIntersection.cpp\
 			  ../MeshProfileIntersection/MeshProfileIntersection.h
-
-NodeConnectivity_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp\
+MeshProfileIntersection_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+NodeConnectivity_la_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp\
 										../NodeConnectivity/NodeConnectivity.h
-
-PointCloudFindNeighbors_SOURCES = ../PointCloudFindNeighbors/PointCloudFindNeighbors.cpp\
+NodeConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+PointCloudFindNeighbors_la_SOURCES = ../PointCloudFindNeighbors/PointCloudFindNeighbors.cpp\
 			  ../PointCloudFindNeighbors/PointCloudFindNeighbors.h
-
-PropagateFlagsFromConnectivity_SOURCES = ../PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp\
+PointCloudFindNeighbors_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB)
+
+PropagateFlagsFromConnectivity_la_SOURCES = ../PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp\
 			  ../PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h
-
-Scotch_SOURCES = ../Scotch/Scotch.cpp\
-			  ../Scotch/Scotch.h
-
-Shp2Kml_SOURCES = ../Shp2Kml/Shp2Kml.cpp\
-			  ../Shp2Kml/Shp2Kml.h
-
-TriaSearch_SOURCES = ../TriaSearch/TriaSearch.cpp\
+PropagateFlagsFromConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+Scotch_la_SOURCES = ../Scotch/Scotch.cpp\
+                    ../Scotch/Scotch.h
+Scotch_la_LIBADD = ${deps} $(SCOTCHLIB)
+
+Shp2Kml_la_SOURCES = ../Shp2Kml/Shp2Kml.cpp\
+                     ../Shp2Kml/Shp2Kml.h
+Shp2Kml_la_LIBADD = ${deps}
+
+TriaSearch_la_SOURCES = ../TriaSearch/TriaSearch.cpp\
 			  ../TriaSearch/TriaSearch.h
-
-TriMesh_SOURCES = ../TriMesh/TriMesh.cpp\
-			  ../TriMesh/TriMesh.h
-
-TriMeshProcessRifts_SOURCES = ../TriMeshProcessRifts/TriMeshProcessRifts.cpp\
+TriaSearch_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
+TriMesh_la_SOURCES = ../TriMesh/TriMesh.cpp\
+                     ../TriMesh/TriMesh.h
+TriMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(TRIANGLELIB)
+
+TriMeshProcessRifts_la_SOURCES = ../TriMeshProcessRifts/TriMeshProcessRifts.cpp\
 			  ../TriMeshProcessRifts/TriMeshProcessRifts.h
+TriMeshProcessRifts_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
 #}}}
