#debug or release
ver = release

matlab_path=/usr/local/MATLAB/R2014b

cord_objs = cord.o evaluate.o
CXX=g++
HEADER_DIR = ./include
SRC_DIR = ./src
BIN_DIR = bin
ifeq ($(ver),debug)
  CFLAGS= -g -std=c++11 -I$(matlab_path)/extern/include -I ./include
else
  CFLAGS= -O3 -std=c++11 -I$(matlab_path)/extern/include -I ./include
endif
LIBS_DIR= -L$(matlab_path)/bin/glnxa64 -L/usr/local/lib -L./
LIBS := -lmat -lmx -llbfgs -larmadillo -Wl,-rpath=$(matlab_path)/bin/glnxa64 `pkg-config --cflags --libs tinyxml2`

main:$(cord_objs)
	$(CXX) $(CFLAGS) $(LIBS_DIR) $(cord_objs) -o cord  $(LIBS)
cord.o:$(SRC_DIR)/cord.cpp
	$(CXX) $(CFLAGS) -c $(SRC_DIR)/cord.cpp
	
evaluate.o:$(HEADER_DIR)/lbfgs.h $(SRC_DIR)/evaluate.cpp
	$(CXX) $(CFLAGS) -c $(SRC_DIR)/evaluate.cpp

clean:
	rm *.o cord
