#-------------------------------------------------------------------------------
# Define Program, Program Directory, Program Version, Install Directories, and
# Target Names ... set mode to default (empty)
#-------------------------------------------------------------------------------
PROGRAM			= libslbm
PROG_NAM		= SLBM

SOURCES	= src\Brents.cc \
	src\CrustalProfile.cc \
	src\CrustalProfileStore.cc \
	src\DataBuffer.cc \
	src\GeoStack.cc \
	src\GreatCircle.cc \
	src\GreatCircle_Xg.cc \
	src\GreatCircle_Xn.cc \
	src\GreatCircleFactory.cc \
	src\Grid.cc \
	src\GridProfile.cc \
	src\IntegrateFunction.cc \
	src\InterpolatedProfile.cc \
	src\LayerProfile.cc \
	src\LayerProfileG.cc \
	src\Location.cc \
	src\MD50.cc \
	src\QueryProfile.cc \
	src\SlbmInterface.cc \
	src\SlbmInterfaceToJNI.cc \
	src\TauPSite.cc \
	src\TauPSiteFunctionals.cc \
	src\TPVelocityModels.cc \
	src\Triangle.cc \
	src\Uncertainty.cc \
	src\GridSLBM.cc \
	src\GeoTessModelSLBM.cc \
	src\GridGeoTess.cc \
	src\GridProfileGeoTess.cc \
	src\GridProfileSLBM.cc

OBJECTS=$(SOURCES:.cc=.obj)

INCLUDE_DIR	= include/
GEO_INC=..\GeoTessCPP\include
GEO_LIB=..\lib
CV = @

ifeq ($(ARCH),32bit)
MACHINE=/MACHINE:X86
else
MACHINE=/MACHINE:X64
endif

CC = cl
RM = del
CCFLAGS =  /W1 /Zi /O2 /Oi /GL /D "NDEBUG" /FD /MD /Gy /D "_USRDLL" /D "_WINDOWS" /D "SLBM_EXPORTS" /D "TAUP_EXPORTS" /errorReport:prompt \
	/D "UTIL_EXPORTS" /D "_CRT_SECURE_NO_DEPRECATE" /D "_WINDLL" /D "_UNICODE" /D "UNICODE"  /I"${INCLUDE_DIR}" /I"${INCLUDE}" /I"${GEO_INC}" /EHsc /nologo /Fo"$@"
COMMAND = ${CV} ${CC} ${CCFLAGS} ${OBJECTS} -link -LIBPATH:$(GEO_LIB) libgeotesscpp.lib -dll -out:"../lib/libslbm.dll" $(MACHINE) /MANIFEST && cd ..\lib && mt /nologo -manifest libslbm.dll.manifest -outputresource:libslbm.dll;2
VERSION_FLAG =


#-------------------------------------------------------------------------------
# targets
#-------------------------------------------------------------------------------


all : info slbm  done

%.obj: $($*:.obj=.cc)
	${CV} ${CC} ${CCFLAGS} -c $*.cc /Fo$*

slbm : slbmlib

slbmlib: ${OBJECTS}
	${CV} echo "building shared library slbm.so"
	${COMMAND}
	@ echo ""

cleanobjs :
	${CV} echo "removing object files"
	$(RM) $(OBJECTS)
	@ echo ""

info :
	@ echo "========================================="
	@ echo "Building" $(PROG_NAM) "on" $(OS)
	$(CC) $(VERSION_FLAG)

done :
	@echo "Done building" $(PROG_NAM)
	@ echo ""
