AM_CPPFLAGS = @DAKOTAINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @PARMETISINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@ @AMPIINCL@ @ADJOINTMPIINCL@ @MEDIPACKINCL@ @CODIPACKINCL@
AUTOMAKE_OPTIONS = subdir-objects

EXEEXT=$(PYTHONWRAPPEREXT)

#define prefix (from http://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Defining-Directories.html)
AM_CPPFLAGS += -DISSM_PREFIX='"$(prefix)"'

#python io{{{
lib_LTLIBRARIES = libISSMPython.la

io_sources = \
	./io/CheckNumPythonArguments.cpp \
	./io/FetchPythonData.cpp \
	./io/WritePythonData.cpp

ALLCXXFLAGS= -fPIC -D_WRAPPERS_ $(CXXFLAGS) $(CXXOPTFLAGS)

libISSMPython_la_SOURCES = $(io_sources)
libISSMPython_la_CXXFLAGS= $(ALLCXXFLAGS)
#}}}
#api io{{{
lib_LTLIBRARIES += libISSMApi.la
api_sources		 = ./io/ApiPrintf.cpp

libISSMApi_la_SOURCES = $(api_sources)
libISSMApi_la_CXXFLAGS= $(ALLCXXFLAGS)
#}}}
#Wrappers {{{
lib_LTLIBRARIES += \
	BamgConvertMesh_python.la \
	BamgMesher_python.la \
	BamgTriangulate_python.la \
	ContourToMesh_python.la \
	ContourToNodes_python.la \
	ElementConnectivity_python.la \
	ExpToLevelSet_python.la \
	InterpFromGridToMesh_python.la \
	InterpFromMesh2d_python.la \
	InterpFromMeshToGrid_python.la \
	InterpFromMeshToMesh2d_python.la \
	InterpFromMeshToMesh3d_python.la \
	IssmConfig_python.la \
	MeshPartition_python.la \
	MeshProfileIntersection_python.la \
	NodeConnectivity_python.la \
	Triangle_python.la \
	ProcessRifts_python.la

if CHACO
lib_LTLIBRARIES += Chaco_python.la
endif
#}}}
#Flags and libraries {{{
deps = $(MATHLIB) ${PYTHONLIB}

#Triangle library
AM_CXXFLAGS = -DTRILIBRARY -DANSI_DECLARATORS -DNO_TIMER -D_WRAPPERS_

#Python part
AM_LDFLAGS = -module $(PYTHONLINK) -shrext ${EXEEXT} --export-dynamic -rdynamic -no-undefined

if !VERSION
AM_LDFLAGS += -avoid-version
endif

# NOTE:
# - On Linux, We probably do not need the -static flag as long as we only
#	generate static libraries for external packages. Dynamic system libraries
#	will be linked to, whether we like it or not, if no static version is
#	available.
# - On macOS, static linking of binaries is not supported.
#
if STANDALONE_MODULES
if MAC
AM_LDFLAGS += -Wl,-rpath,'@rpath'
else
AM_LDFLAGS += -Wl,-static -Wl,--disable-new-dtags -Wl,-rpath,'$$ORIGIN'
endif
endif

AM_LDFLAGS 	+= --no-warnings
AM_CXXFLAGS += -D_HAVE_PYTHON_MODULES_ -fPIC

if PYTHON3
AM_CXXFLAGS += -DNPY_NO_DEPRECATED_API
endif

deps += ./libISSMPython.la ../../c/libISSMModules.la ../../c/libISSMCore.la ./libISSMApi.la

if ADOLC
deps += $(ADOLCLIB)
endif

if FORTRAN
deps += $(FLIBS) $(FORTRANLIB)
endif

#Optimization flags:
AM_CXXFLAGS += $(CXXOPTFLAGS)
#}}}
# Module sources and dependencies {{{
libISSMPython_la_LIBADD = ./../../c/libISSMCore.la ./../../c/libISSMModules.la $(PETSCLIB) $(HDF5LIB) $(MPILIB) $(NEOPZLIB) $(MKLLIB) $(GSLLIB) $(PROJ4LIB) $(MATHLIB)

if STANDALONE_LIBRARIES
libISSMPython_la_LDFLAGS = -static
libISSMApi_la_LDFLAGS = -static
deps += $(DAKOTALIB) $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(HDF5LIB) $(TAOLIB) $(NEOPZLIB) $(M1QN3LIB) $(SEMICLIB) $(PLAPACKLIB) $(SUPERLULIB) $(SPOOLESLIB) $(TRIANGLELIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(CHACOLIB) $(SCOTCHLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(ADOLCLIB) $(AMPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(OSLIBS)
endif

libISSMApi_la_LIBADD = $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB) $(MATHLIB)

BamgConvertMesh_python_la_SOURCES = ../BamgConvertMesh/BamgConvertMesh.cpp
BamgConvertMesh_python_la_CXXFLAGS = ${AM_CXXFLAGS}
BamgConvertMesh_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

BamgMesher_python_la_SOURCES = ../BamgMesher/BamgMesher.cpp
BamgMesher_python_la_CXXFLAGS = ${AM_CXXFLAGS}
BamgMesher_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

BamgTriangulate_python_la_SOURCES = ../BamgTriangulate/BamgTriangulate.cpp
BamgTriangulate_python_la_CXXFLAGS = ${AM_CXXFLAGS}
BamgTriangulate_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

if CHACO
Chaco_python_la_SOURCES = ../Chaco/Chaco.cpp
Chaco_python_la_CXXFLAGS = ${AM_CXXFLAGS}
Chaco_python_la_LIBADD = ${deps} $(CHACOLIB) $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)
endif

ContourToMesh_python_la_SOURCES = ../ContourToMesh/ContourToMesh.cpp
ContourToMesh_python_la_CXXFLAGS = ${AM_CXXFLAGS}
ContourToMesh_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(MULTITHREADINGLIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

ContourToNodes_python_la_SOURCES = ../ContourToNodes/ContourToNodes.cpp
ContourToNodes_python_la_CXXFLAGS = ${AM_CXXFLAGS}
ContourToNodes_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

ElementConnectivity_python_la_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp
ElementConnectivity_python_la_CXXFLAGS = ${AM_CXXFLAGS}
ElementConnectivity_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

ExpToLevelSet_python_la_SOURCES = ../ExpToLevelSet/ExpToLevelSet.cpp
ExpToLevelSet_python_la_CXXFLAGS = ${AM_CXXFLAGS}
ExpToLevelSet_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB) $(NEOPZLIB)

InterpFromMesh2d_python_la_SOURCES = ../InterpFromMesh2d/InterpFromMesh2d.cpp
InterpFromMesh2d_python_la_CXXFLAGS = ${AM_CXXFLAGS}
InterpFromMesh2d_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(MULTITHREADINGLIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

InterpFromGridToMesh_python_la_SOURCES = ../InterpFromGridToMesh/InterpFromGridToMesh.cpp
InterpFromGridToMesh_python_la_CXXFLAGS = ${AM_CXXFLAGS}
InterpFromGridToMesh_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(MULTITHREADINGLIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

InterpFromMeshToGrid_python_la_SOURCES = ../InterpFromMeshToGrid/InterpFromMeshToGrid.cpp
InterpFromMeshToGrid_python_la_CXXFLAGS = ${AM_CXXFLAGS}
InterpFromMeshToGrid_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(MULTITHREADINGLIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

InterpFromMeshToMesh2d_python_la_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
InterpFromMeshToMesh2d_python_la_CXXFLAGS = ${AM_CXXFLAGS}
InterpFromMeshToMesh2d_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB)

InterpFromMeshToMesh3d_python_la_SOURCES = ../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp
InterpFromMeshToMesh3d_python_la_CXXFLAGS = ${AM_CXXFLAGS}
InterpFromMeshToMesh3d_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB)

IssmConfig_python_la_SOURCES = ../IssmConfig/IssmConfig.cpp
IssmConfig_python_la_CXXFLAGS = ${AM_CXXFLAGS}
IssmConfig_python_la_LIBADD = ${deps} $(DAKOTALIB) $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB)

MeshPartition_python_la_SOURCES = ../MeshPartition/MeshPartition.cpp
MeshPartition_python_la_CXXFLAGS = ${AM_CXXFLAGS}
MeshPartition_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(METISLIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

MeshProfileIntersection_python_la_SOURCES = ../MeshProfileIntersection/MeshProfileIntersection.cpp
MeshProfileIntersection_python_la_CXXFLAGS = ${AM_CXXFLAGS}
MeshProfileIntersection_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

NodeConnectivity_python_la_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp
NodeConnectivity_python_la_CXXFLAGS = ${AM_CXXFLAGS}
NodeConnectivity_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

Triangle_python_la_SOURCES = ../Triangle/Triangle.cpp
Triangle_python_la_CXXFLAGS = ${AM_CXXFLAGS}
Triangle_python_la_LIBADD = ${deps} $(TRIANGLELIB) $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)

ProcessRifts_python_la_SOURCES = ../ProcessRifts/ProcessRifts.cpp
ProcessRifts_python_la_CXXFLAGS = ${AM_CXXFLAGS}
ProcessRifts_python_la_LIBADD = ${deps} $(PETSCLIB) $(HDF5LIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJ4LIB)
#}}}
