include Makefile.conf

.PHONY: all
all: libiglsvd3x3
debug: libiglsvd3x3

include Makefile.conf
all: OPTFLAGS += -O3 -DNDEBUG $(OPENMP)
debug: OPTFLAGS += -g -Wall
CFLAGS += $(OPTFLAGS) -std=c++11

.PHONY: libiglsvd3x3
libiglsvd3x3: obj ../lib/libiglsvd3x3.a

SRC_DIR=../include/igl/svd3x3/
CPP_FILES=$(wildcard $(SRC_DIR)*.cpp)
OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))

# include igl headers
INC+=-I../include/

# EXPECTS THAT CFLAGS IS ALREADY SET APPROPRIATELY 

# SVD 
SINGULAR_VALUE_DECOMPOSITION_INC=\
	-I../external/Singular_Value_Decomposition/
# Eigen dependency
EIGEN3_INC=-I$(DEFAULT_PREFIX)/include/eigen3 -I$(DEFAULT_PREFIX)/include/eigen3/unsupported
INC+=$(EIGEN3_INC) $(SINGULAR_VALUE_DECOMPOSITION_INC)

# Matlab dependency
ifndef MATLAB
  MATLAB=/Applications/MATLAB_R2013b.app/
  $(warning MATLAB undefined. Setting MATLAB=${MATLAB})
endif
MATLAB_INC=-I$(MATLAB)/extern/include/
MATLAB_LIB=-L$(MATLAB)/bin/maci64 -lmx -leng
INC+=$(MATLAB_INC)

obj: 
	mkdir -p obj

../lib/libiglsvd3x3.a: $(OBJ_FILES)
	rm -f $@
	ar cqs $@ $(OBJ_FILES)

obj/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/%.h
	$(GG) $(AFLAGS) $(CFLAGS) -c -o $@ $< $(INC)

clean:
	rm -f $(OBJ_FILES)
	rm -f ../lib/libiglsvd3x3.a
