#
# Run 'make' to compile stand-alone version of LBP detector
#
# Requirements:
# * OpenCV 2.4 or above
# * libargtabe2
# * TreadPool
# * g++ with c++11 support
#
# LBP Detector Toolbox
# Roman Juranek <ijuranek@fit.vutbr.cz>
# Faculty of Information Technology, BUT, Brno
#

CXX = g++
CC = g++

# Production flags
CXXFLAGS = -Wall -pedantic -O2 -std=c++11  -pthread -msse5 -mavx
# Debug flags
#CXXFLAGS = -Wall -pedantic -O0 -std=c++11 -pthread -ggdb3 -g
RM = rm
	
LIBS = `pkg-config --libs opencv argtable2 jsoncpp` -lstdc++ -lm -lprotobuf
INCS = `pkg-config --cflags opencv argtable2 protobuf` -I../external/ThreadPool -I../external/Profiler/include

.PHONY: all clean
.PRECIOUS: %.pb.cc

all: detect_lbp detect_lbp_video minimal

%.o: %.cpp
	$(CXX) $(CXXFLAGS) $(INCS) -c $< -o $@

%.o: %.cc
	$(CXX) $(CXXFLAGS) $(INCS) -c $< -o $@

%.o: %.c
	$(CXX) $(CXXFLAGS) $(INCS) -c $< -o $@

%.pb.cc: %.proto
	protoc --cpp_out=. $^

lbpdetector.o:  lbpdetector.cpp lbpdetector.h
detector.o: detector.pb.o detector.cpp detector.h
lbpdetector.o: lbpdetector.cpp lbpdetector.h
lbpdetector_cv.o: lbpdetector_cv.cpp lbpdetector_cv.cpp
nms.o: nms.cpp nms.h

detect_lbp: detector.o detector.pb.o detect_lbp.o lbpdetector_cv.o lbpdetector.o nms.o
	$(CXX) $^ -o $@ $(CXXFLAGS) $(INCS) $(LIBS)
	md5sum $@ > $@.md5

detect_lbp_video: detector.o detector.pb.o detect_lbp_video.o lbpdetector_cv.o lbpdetector.o nms.o
	$(CXX) $^ -o $@ $(CXXFLAGS) $(INCS) $(LIBS)

jsontool: jsontool.o
	$(CXX) $^ -o $@ $(CXXFLAGS) $(INCS) $(LIBS)	

minimal: minimal.o lbpdetector.o
	$(CXX) $^ -o $@ $(CXXFLAGS) $(INCS) $(LIBS)
