# Makes all the libraries needed to compile the DAG Matcher Library (dml)

DAG_MATCHER_BASE = .

include $(DAG_MATCHER_BASE)/common.mk

ifeq "$(ARCH)" "Windows"
	#BUILD_SRTREE_STEPS = nmake BASIC_CXXFLAGS="$(BASIC_CXXFLAGS)"
	#CLEAN_SRTREE_STEPS = nmake clean
	BUILD_SRTREE_STEPS = make 
	CLEAN_SRTREE_STEPS = make clean
else
	BUILD_SRTREE_STEPS = ./configure; $(MAKE) includes; $(MAKE) all
	CLEAN_SRTREE_STEPS = $(MAKE) clean
endif

all: SRTreeLib NewmatLib ANNLib FluxSkeletonLib AFMMSkeletonLib DAGMatcherLib ShapeMatcherApp
	echo "Successful Build! The ShapeMatcher executable file is in ./bin/$(MODE)"

SRTreeLib:
	echo "Making SRTree (nearest neighbour database) library"
	cd $(HNSRTREE_ROOT); $(BUILD_SRTREE_STEPS)

NewmatLib:
	echo "Making Newmat (matrix manipulation) library"
	cd $(NEWMAT_ROOT); $(MAKE) ARCH="$(ARCH)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" MAKEFLAGS=" "

ANNLib:
	echo "Making Approx Nearest Neighbor (ANN) library"
	cd $(ANN_ROOT); $(MAKE) ARCH="$(ARCH)" MODE="$(MODE)"

FluxSkeletonLib:
	echo "Making Flux-Based Skeleton library: libsg.a"
	cd $(FLUX_SKELETON_ROOT); $(MAKE) ARCH="$(ARCH)" MODE="$(MODE)"

AFMMSkeletonLib:
	echo "Making A*-Fast-Marching-Method-Based Skeleton library"
	cd $(AFMM_SKELETON_ROOT); $(MAKE) ARCH="$(ARCH)" MODE="$(MODE)"

DAGMatcherLib: 
	echo "Making DAG matcher library"
	cd $(DAG_MATCHER_ROOT); $(MAKE) ARCH="$(ARCH)" MODE="$(MODE)"

ShapeMatcherApp:
	echo "Making Shape Matcher application"
	cd $(SHAPE_MATCHER_ROOT); $(MAKE) ARCH="$(ARCH)" MODE="$(MODE)"


clean: SRTreeClean NewmatClean ANNClean FluxSkeletonClean AFMMSkeletonClean DAGMatcherClean ShapeMatcherClean # VCClean
	echo "All libraries are clean!"

SRTreeClean:
	echo "Cleaning SRTree library"
	cd $(HNSRTREE_ROOT); $(CLEAN_SRTREE_STEPS)

NewmatClean:
	echo "Cleaning Newmat library"
	cd $(NEWMAT_ROOT); $(MAKE) clean MAKEFLAGS=" "

ANNClean:
	echo "Cleaning ANN library"
	cd $(ANN_ROOT); $(MAKE) clean ARCH="$(ARCH)"

FluxSkeletonClean:
	echo "Cleaning Flux-Based Skeleton library"
	cd $(FLUX_SKELETON_ROOT); $(MAKE) clean ARCH="$(ARCH)"

AFMMSkeletonClean:
	echo "Cleaning AFMM Skeleton library"
	cd $(AFMM_SKELETON_ROOT); $(MAKE) clean ARCH="$(ARCH)"
	
DAGMatcherClean:
	echo "Cleaning DAG matcher library"
	cd $(DAG_MATCHER_ROOT); $(MAKE) clean ARCH="$(ARCH)"
	
ShapeMatcherClean:
	echo "Cleaning Shape Matcher application"
	cd $(SHAPE_MATCHER_ROOT); $(MAKE) clean ARCH="$(ARCH)"
	
#VCClean:
#	cd $(VC_PROJECT); $(MAKE) clean ARCH="$(ARCH)"

