BUILD_DIR=../bin

CXX = g++

INCLUDE = -I../include

LDFLAGS = -lm
LDFLAGS += -lboost_program_options-mt -lboost_filesystem-mt -lboost_system-mt -lboost_unit_test_framework-mt
LDFLAGS += -lfltk

CFLAGS = -Wall -W -Wextra
# -DUSE_OPENCV
UNAME = $(shell uname)

ifneq ($(OPENCV), 0)
	CFLAGS += -DUSE_OPENCV
	LDFLAGS += -lhighgui -lcxcore -lcv -lml
endif

ifeq ($(UNAME), Linux)
	LINUX_BOOST_PREFIX = /usr/local
	CFLAGS += -DLINUX
	EXE_EXTENSION=''
else # windows
	MINGW_HOME = 'C:\MinGW'
	LDFLAGS += -mconsole -mwindows -lole32 -lwsock32 -luuid
	EXE_EXTENSION='.exe'
endif

ifeq ($(DEBUG), 1)
	CFLAGS += -g -gstabs+ -DDEBUG
else
	CFLAGS += -O3 --fast-math
	CFLAGS += -DNDEBUG
endif

ifeq ($(PROFILING), 1)
	CFLAGS += -pg
endif

CXXFLAGS = $(INCLUDE) $(CFLAGS)

#GUI_OBJS = 
CV_OBJS = cvutils.o
#COMMON_OBJS = 
OBJS = $(COMMON_OBJS) $(CV_OBJS)
#TESTS_OBJS = 

default: builddir all

all: test-pixels optical-flow track-features

builddir:
	@createdirectory.sh $(BUILD_DIR)

track-features.o: track-features.cpp
	$(CXX) -I../../klt $(INCLUDE) $^ -c

track-features: track-features.o $(OBJS)
	$(CXX) $(CFLAGS) $(LIBS) -L../../klt $^ -o $(BUILD_DIR)/$@ $(LDFLAGS) -lklt

optical-flow: optical-flow.o $(OBJS)
	$(CXX) $(CFLAGS) $(LIBS) $^ -o $(BUILD_DIR)/$@ $(LDFLAGS)

test-pixels: test-pixels.o $(OBJS)
	$(CXX) $(CFLAGS) $(LIBS) $^ -o $(BUILD_DIR)/$@ $(LDFLAGS)

clean:
	rm -f *.gch */*.o *.o *.a  $(BUILD_DIR)/*
# $(DISTFILE_OUTPUT)
