# author: isvoboda
# project: Potted Plant Detector - PPD
# Description
## Makefile for ppd library compilation on Linux/Windows(gcc) systems
## Requirements
### CXXFLAGS	- variable contains flags for compiler
### LIBS		- variable contains libraries to link (ticpp - tinyxml cpp, opencv libs)
### CPPFLAGS	- Path to include files
### LibraryPath
### ERASE		- delete/rm command

# Compiler
CC				= g++
MakeLib 		= ar
# CXXFLAGS - flags for compiler for c++ language 
CXXFLAGS 		= -Wall -fmessage-length=0

Program = libppd.a
Programd = libppdd.a

# Windows / Linux setting
ifeq ($(OS),Windows_NT)
	#Libraries - names on Windows system
	LIBS		= -lticpp -lopencv_highgui231 -lopencv_features2d231 -lopencv_imgproc231 -lopencv_core231 -lopencv_ml231
	
	# The include path for all languages of *.h and *.hpp
	CPPFLAGS	= -IC:\Users\isvoboda\Dropbox\Programs\OpenCv\OpenCv_2.3.1\include
	
	# Library path needed for linking in Windows
	LibraryPath	= -L.\XmlParser\lib -L"C:\Users\isvoboda\Dropbox\Programs\OpenCv\OpenCv_2.3.1\x86\mingw\lib"
	ERASE		= del
else
	#Libraries - names on Linux system
	LIBS		= -lticpp -lopencv_highgui -lopencv_features2d -lopencv_imgproc -lopencv_core -lopencv_ml 
	
	# Library path needed for linking on Linux
	LibraryPath = -L./XmlParser/lib
	ERASE		= rm -f
endif

OBJ				= bow.o read_dataset.o settings_reader.o classifier_svm.o detector.o svm.o

all: release

release: CXXFLAGS += -O3 -mtune=core2 -fopenmp
release: $(Program)

$(Program): $(OBJ)
	$(MakeLib) rcs $(Program) $(OBJ)

debug: CXXFLAGS += -O0 -g3
debug: $(Programd)

$(Programd): $(OBJ)
	$(MakeLib) rcs $(Programd) $(OBJ)

clean:
	$(ERASE) $(Program) $(Programd) $(OBJ)

# Not needed thanks to implicit rule
#main.o: main.cpp bow_generator.hpp
#bow_generator.o: bow_generator.cpp bow_generator.hpp read_dataset.hpp
#read_dataset.o: read_dataset.cpp read_dataset.hpp

#Shortcuts
# $@ : text in front of semicolon
# $< : Name of first prerequisit
# $< : Names of all prerequisits divided by space
# $? : Names of all prerequisits which are newer then target
# -c param of gcc to compile do not link
# -o fileName create file with fileName

# For *.o objects the implicit rule is used
# %.o: %.c
#	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<

# $(RM) - varibale of del-win (works with cygwin) and rm-linux
