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

SRC_DIR=../include/igl/viewer/
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

# 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: $(SRC_DIR)/%.cpp $(SRC_DIR)/%.h
	$(GG) $(AFLAGS) $(CFLAGS) -c -o $@ $< $(INC)

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