include ../../../Makefile.conf
all: CFLAGS += -O3 -DNDEBUG -fopenmp
debug: CFLAGS += -g -Wall -Werror -fopenmp

.PHONY: all
all: libiglviewer
debug: libiglviewer

.PHONY: libviewer
libiglviewer: obj ../../../lib/libiglviewer.a

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

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

# EXPECTS THAT CFLAGS IS ALREADY SET APPROPRIATELY 

# Eigen dependency
EIGEN3_INC=-I$(DEFAULT_PREFIX)/include/eigen3 -I$(DEFAULT_PREFIX)/include/eigen3/unsupported
INC+=$(EIGEN3_INC)

# GLFW dependency
ifndef GLFW
	GLFW=../../../external/glfw/
endif
GLFW_INC=-I$(GLFW)/include
INC+=$(GLFW_INC)
ifndef ANTTWEAKBAR
	ANTTWEAKBAR=../../../external/AntTweakBar/
endif
# Viewer also uses source files from AntTweakBar for font rendering
ANTTWEAKBAR_INC=-I$(ANTTWEAKBAR)/include -I$(ANTTWEAKBAR)/src
INC+=$(ANTTWEAKBAR_INC)

obj: 
	mkdir -p obj

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

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

clean:
	rm -f obj/*.o
	rm -f ../../../lib/libiglmatlab.a
