# Makefile for the Shape Matcher Application (SM)

LIB_NAME = ShapeMatcher
APP_NAME = sm
DAG_MATCHER_BASE = ..

include $(DAG_MATCHER_BASE)/common.mk

INCS = -I$(DAG_MATCHER_BASE) \
       -I$(DAG_MATCHER_ROOT) \
       -I$(NEWMAT_ROOT) \
       -I$(LEDAROOT)/incl/ \
       -I$(FLUX_SKELETON_ROOT)/include \
       -I$(HNSRTREE_ROOT)/include \
       -I$(AFMM_SKELETON_ROOT)/include \
       -I$(ANN_ROOT)/include \
       -I$(GLUT_ROOT)

LIBS = -$L$(DAG_MATCHER_ROOT) \
       -$L$(NEWMAT_ROOT) \
       -$L$(LEDAROOT) \
       -$L$(FLUX_SKELETON_ROOT)/lib \
       -$L$(HNSRTREE_ROOT)/lib \
       -$L$(AFMM_SKELETON_ROOT) \
       -$L$(ANN_ROOT)/lib \
       -$L$(GLUT_ROOT)


CPP_SRCS = $(wildcard *.cpp)
HEADERS = $(wildcard *.h)

OBJECTS = $(CPP_SRCS:%.cpp=$(OBJFILE))

ifeq "$(ARCH)" "Windows"	    
	OBJECTS += getopt.obj getopt1.obj
	LOCAL_LIBS = DAGMatch.lib HnSRTree.lib AFMMSkel.lib FluxSkel.lib ANN.lib newmat.lib glut32.lib
	
	ifeq "$(MODE)" "Debug"
		LEDA_LIBS = $(LEDAROOT)/leda_mdd.lib
		STD_LIBS = kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
	else
		LEDA_LIBS = $(LEDAROOT)/leda_md.lib
		STD_LIBS = kernel32.lib user32.lib gdi32.lib oleaut32.lib
	endif
	
	EXTRAS = $(subst /,\,$(wildcard *.exe) $(wildcard *.pdb) $(wildcard *.idb) $(wildcard *.manifest))
else
	LOCAL_LIBS = -lDAGMatch -lHnSRTree -lAFMMSkel -lFluxSkel -lANN -lnewmat
	#LEDA_LIBS = -lW -lP -lG -lL
	LEDA_LIBS = -lleda
	STD_LIBS = -lm -lpthread -lX11 -ldl
	
	EXTRAS = $(APP_NAME)
endif


$(APP_NAME): $(OBJECTS)
	$(LINK) $(LDFLAGS) -$(OUT)$(APP_FULL_NAME) $(OBJECTS) $(LIBS) $(LOCAL_LIBS) $(LEDA_LIBS) $(STD_LIBS)
	$(POST_BUILD_STEP)
	$(CP) $(APP_FULL_NAME) $(SM_BIN_ROOT)
	$(CP) $(APP_FULL_NAME) C:\Users\Diego\Documents\Workspace\ShapeMatcherBuilds\ShapeMatcher

$(LIB_NAME): $(OBJECTS)
	$(AR) $(ARFLAGS) $(OBJECTS)

$(OBJFILE): %.cpp $(HEADERS)
	$(CXX) -c $(CXXFLAGS) $(INCS) $<

getopt.obj: getopt.c getopt.h
	$(CXX) -c $(CXXFLAGS) $(INCS) getopt.c

getopt1.obj: getopt1.c getopt.h
	$(CXX) -c $(CXXFLAGS) $(INCS) getopt1.c

clean:
	$(RM) $(OBJECTS) $(EXTRAS) $(LIB_NAME)
